diff options
author | 2023-08-07 01:05:27 +0100 | |
---|---|---|
committer | 2023-08-07 01:06:39 +0100 | |
commit | f1f43b235cec228fa0e478f389225729ae2ea3f8 (patch) | |
tree | f7122b3ad25a751ede7f486a9fb96a7359472a16 /setup.py | |
parent | Modernise shebang (diff) | |
download | mirrorselect-f1f43b235cec228fa0e478f389225729ae2ea3f8.tar.gz mirrorselect-f1f43b235cec228fa0e478f389225729ae2ea3f8.tar.bz2 mirrorselect-f1f43b235cec228fa0e478f389225729ae2ea3f8.zip |
Reformat with `black`
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 163 |
1 files changed, 80 insertions, 83 deletions
@@ -12,7 +12,7 @@ import io import unittest -__version__ = os.getenv('VERSION', default=os.getenv('PVR', default='9999')) +__version__ = os.getenv("VERSION", default=os.getenv("PVR", default="9999")) cwd = os.getcwd() @@ -22,108 +22,105 @@ EPREFIX = "@GENTOO_PORTAGE_EPREFIX@" # check and set it if it wasn't if "GENTOO_PORTAGE_EPREFIX" in EPREFIX: - EPREFIX = '' + EPREFIX = "" # Python files that need `version = ""` subbed, relative to this dir: -python_scripts = [os.path.join(cwd, path) for path in ( - 'mirrorselect/version.py', -)] +python_scripts = [os.path.join(cwd, path) for path in ("mirrorselect/version.py",)] -manpage = [os.path.join(cwd, path) for path in ( - 'mirrorselect.8', -)] +manpage = [os.path.join(cwd, path) for path in ("mirrorselect.8",)] class set_version(core.Command): - """Set python version to our __version__.""" - description = "hardcode scripts' version using VERSION from environment" - user_options = [] # [(long_name, short_name, desc),] - - def initialize_options (self): - pass - - def finalize_options (self): - pass - - def run(self): - ver = 'git' if __version__ == '9999' else __version__ - print("Setting version to %s" % ver) - def sub(files, pattern): - for f in files: - updated_file = [] - with open(f, 'r', 1, 'utf_8') as s: - for line in s: - newline = re.sub(pattern, '"%s"' % ver, line, 1) - if newline != line: - logging.info("{}: {}".format(f, newline)) - updated_file.append(newline) - with open(f, 'w', 1, 'utf_8') as s: - s.writelines(updated_file) - quote = r'[\'"]{1}' - python_re = r'(?<=^version = )' + quote + '[^\'"]*' + quote - sub(python_scripts, python_re) - man_re = r'(?<=^.TH "mirrorselect" "8" )' + quote + '[^\'"]*' + quote - sub(manpage, man_re) + """Set python version to our __version__.""" + + description = "hardcode scripts' version using VERSION from environment" + user_options = [] # [(long_name, short_name, desc),] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + ver = "git" if __version__ == "9999" else __version__ + print("Setting version to %s" % ver) + + def sub(files, pattern): + for f in files: + updated_file = [] + with open(f, "r", 1, "utf_8") as s: + for line in s: + newline = re.sub(pattern, '"%s"' % ver, line, 1) + if newline != line: + logging.info("{}: {}".format(f, newline)) + updated_file.append(newline) + with open(f, "w", 1, "utf_8") as s: + s.writelines(updated_file) + + quote = r'[\'"]{1}' + python_re = r"(?<=^version = )" + quote + "[^'\"]*" + quote + sub(python_scripts, python_re) + man_re = r'(?<=^.TH "mirrorselect" "8" )' + quote + "[^'\"]*" + quote + sub(manpage, man_re) class x_sdist(sdist): - """sdist defaulting to archive files owned by root.""" + """sdist defaulting to archive files owned by root.""" - def finalize_options(self): - if self.owner is None: - self.owner = 'root' - if self.group is None: - self.group = 'root' + def finalize_options(self): + if self.owner is None: + self.owner = "root" + if self.group is None: + self.group = "root" - sdist.finalize_options(self) + sdist.finalize_options(self) class TestCommand(Command): - user_options = [] + user_options = [] - def initialize_options(self): - pass + def initialize_options(self): + pass - def finalize_options(self): - pass + def finalize_options(self): + pass - def run(self): - suite = unittest.TestSuite() - tests = unittest.defaultTestLoader.discover('tests') - suite.addTests(tests) - result = unittest.TextTestRunner(verbosity=2).run(suite) - if result.errors or result.failures: - raise SystemExit(1) + def run(self): + suite = unittest.TestSuite() + tests = unittest.defaultTestLoader.discover("tests") + suite.addTests(tests) + result = unittest.TextTestRunner(verbosity=2).run(suite) + if result.errors or result.failures: + raise SystemExit(1) -test_data = { - 'mirrorselect': [ - ] -} +test_data = {"mirrorselect": []} core.setup( - name='mirrorselect', - version=__version__, - description='Tool for selecting Gentoo source and rsync mirrors.', - author='', - author_email='', - maintainer='Gentoo Portage Tools Team', - maintainer_email='tools-portage@gentoo.org', - url='http://www.gentoo.org/proj/en/portage/tools/index.xml', - download_url='http://distfiles.gentoo.org/distfiles/mirrorselect-%s.tar.gz'\ - % __version__, - packages=['mirrorselect'], - #package_data = test_data, - scripts=(['bin/mirrorselect']), - data_files=( - (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'usr/share/man/man8'), - ['mirrorselect.8']), - ), - cmdclass={ - 'test': TestCommand, - 'sdist': x_sdist, - 'set_version': set_version, - }, + name="mirrorselect", + version=__version__, + description="Tool for selecting Gentoo source and rsync mirrors.", + author="", + author_email="", + maintainer="Gentoo Portage Tools Team", + maintainer_email="tools-portage@gentoo.org", + url="http://www.gentoo.org/proj/en/portage/tools/index.xml", + download_url="http://distfiles.gentoo.org/distfiles/mirrorselect-%s.tar.gz" + % __version__, + packages=["mirrorselect"], + # package_data = test_data, + scripts=(["bin/mirrorselect"]), + data_files=( + ( + os.path.join(os.sep, EPREFIX.lstrip(os.sep), "usr/share/man/man8"), + ["mirrorselect.8"], + ), + ), + cmdclass={ + "test": TestCommand, + "sdist": x_sdist, + "set_version": set_version, + }, ) - |