[SEBA-412] Automated reformat of Python code
Passes of modernize, autopep8, black, then check with flake8
flake8 + manual fixes:
lib/xos-config
lib/xos-kafka
lib/xos-util
xos/coreapi
xos/api
xos/xos_client
Change-Id: Ib23cf84cb13beb3c6381fa0d79594dc9131dc815
diff --git a/lib/xos-util/xosutil/autoversion_setup.py b/lib/xos-util/xosutil/autoversion_setup.py
index 5a7ea44..e027d5c 100644
--- a/lib/xos-util/xosutil/autoversion_setup.py
+++ b/lib/xos-util/xosutil/autoversion_setup.py
@@ -1,4 +1,3 @@
-
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,42 +32,47 @@
import inspect
from autodiscover_version import autodiscover_version
+
class SdistCommand(sdist):
def copy_file(self, infile, outfile, *args, **kwargs):
if kwargs.get("dry_run"):
return (outfile, 1)
- if (os.path.split(outfile)[1] == "version.py"):
- open(outfile, "w").write("# do not edit. Autogenerated file.\n" \
- "__version__ = '%s'\n" % self.distribution.metadata.version)
+ if os.path.split(outfile)[1] == "version.py":
+ open(outfile, "w").write(
+ "# do not edit. Autogenerated file.\n"
+ "__version__ = '%s'\n" % self.distribution.metadata.version
+ )
return (outfile, 1)
else:
return sdist.copy_file(self, infile, outfile, *args, **kwargs)
+
class BuildPyCommand(build_py):
def copy_file(self, infile, outfile, *args, **kwargs):
if kwargs.get("dry_run"):
return (outfile, 1)
- if (os.path.split(outfile)[1] == "version.py"):
- open(outfile, "w").write("# do not edit. Autogenerated file.\n" \
- "__version__ = '%s'\n" % self.distribution.metadata.version)
+ if os.path.split(outfile)[1] == "version.py":
+ open(outfile, "w").write(
+ "# do not edit. Autogenerated file.\n"
+ "__version__ = '%s'\n" % self.distribution.metadata.version
+ )
return (outfile, 1)
else:
return build_py.copy_file(self, infile, outfile, *args, **kwargs)
+
def setup_with_auto_version(*args, **kwargs):
# Learn the module that called this function, so we can search for any VERSION files in it.
frame = inspect.stack()[1]
caller_module = inspect.getmodule(frame[0])
# Search for a VERSION file and extract the version number from it.
- version = autodiscover_version(caller_filename = caller_module.__file__)
+ version = autodiscover_version(caller_filename=caller_module.__file__)
if version:
kwargs["version"] = version
cmdclass = kwargs.get("cmdclass", {}).copy()
- cmdclass.update( {"sdist": SdistCommand,
- "build_py": BuildPyCommand} )
+ cmdclass.update({"sdist": SdistCommand, "build_py": BuildPyCommand})
kwargs["cmdclass"] = cmdclass
return setup(*args, **kwargs)
-