summaryrefslogtreecommitdiffstats
path: root/tasks.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-09-06 04:12:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-09-06 04:13:23 +0000
commit3fb37a1d0237869e8e37864d06c0dfd94bb43189 (patch)
treeda8700e80772bd4c9605f263a3299a54d96f636b /tasks.py
parentReleasing debian version 2.1.0-2. (diff)
downloadcli-helpers-3fb37a1d0237869e8e37864d06c0dfd94bb43189.tar.xz
cli-helpers-3fb37a1d0237869e8e37864d06c0dfd94bb43189.zip
Merging upstream version 2.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tasks.py')
-rw-r--r--tasks.py54
1 files changed, 29 insertions, 25 deletions
diff --git a/tasks.py b/tasks.py
index aaed0f3..3a7e1e3 100644
--- a/tasks.py
+++ b/tasks.py
@@ -13,7 +13,7 @@ class BaseCommand(Command, object):
user_options = []
- default_cmd_options = ('verbose', 'quiet', 'dry_run')
+ default_cmd_options = ("verbose", "quiet", "dry_run")
def __init__(self, *args, **kwargs):
super(BaseCommand, self).__init__(*args, **kwargs)
@@ -40,54 +40,58 @@ class BaseCommand(Command, object):
def apply_options(self, cmd, options=()):
"""Apply command-line options."""
- for option in (self.default_cmd_options + options):
- cmd = self.apply_option(cmd, option,
- active=getattr(self, option, False))
+ for option in self.default_cmd_options + options:
+ cmd = self.apply_option(cmd, option, active=getattr(self, option, False))
return cmd
def apply_option(self, cmd, option, active=True):
"""Apply a command-line option."""
- return re.sub(r'{{{}\:(?P<option>[^}}]*)}}'.format(option),
- r'\g<option>' if active else '', cmd)
+ return re.sub(
+ r"{{{}\:(?P<option>[^}}]*)}}".format(option),
+ r"\g<option>" if active else "",
+ cmd,
+ )
class lint(BaseCommand):
"""A PEP 8 lint command that optionally fixes violations."""
- description = 'check code against PEP 8 (and fix violations)'
+ description = "check code against PEP 8 (and fix violations)"
user_options = [
- ('branch=', 'b', 'branch or revision to compare against (e.g. master)'),
- ('fix', 'f', 'fix the violations in place')
+ ("branch=", "b", "branch or revision to compare against (e.g. master)"),
+ ("fix", "f", "fix the violations in place"),
]
def initialize_options(self):
"""Set the default options."""
- self.branch = 'master'
+ self.branch = "master"
self.fix = False
super(lint, self).initialize_options()
def run(self):
"""Run the linter."""
- cmd = 'pep8radius {branch} {{fix: --in-place}}{{verbose: -vv}}'
+ cmd = "black ."
cmd = cmd.format(branch=self.branch)
- self.call_and_exit(self.apply_options(cmd, ('fix', )))
+ self.call_and_exit(self.apply_options(cmd, ("fix",)))
class test(BaseCommand):
"""Run the test suites for this project."""
- description = 'run the test suite'
+ description = "run the test suite"
user_options = [
- ('all', 'a', 'test against all supported versions of Python'),
- ('coverage', 'c', 'measure test coverage')
+ ("all", "a", "test against all supported versions of Python"),
+ ("coverage", "c", "measure test coverage"),
]
- unit_test_cmd = ('pytest{quiet: -q}{verbose: -v}{dry_run: --setup-only}'
- '{coverage: --cov-report= --cov=cli_helpers}')
- test_all_cmd = 'tox{verbose: -v}{dry_run: --notest}'
- coverage_cmd = 'coverage report'
+ unit_test_cmd = (
+ "pytest{quiet: -q}{verbose: -v}{dry_run: --setup-only}"
+ "{coverage: --cov-report= --cov=cli_helpers}"
+ )
+ test_all_cmd = "tox{verbose: -v}{dry_run: --notest}"
+ coverage_cmd = "coverage report"
def initialize_options(self):
"""Set the default options."""
@@ -101,20 +105,20 @@ class test(BaseCommand):
cmd = self.apply_options(self.test_all_cmd)
self.call_and_exit(cmd)
else:
- cmds = (self.apply_options(self.unit_test_cmd, ('coverage', )), )
+ cmds = (self.apply_options(self.unit_test_cmd, ("coverage",)),)
if self.coverage:
- cmds += (self.apply_options(self.coverage_cmd), )
+ cmds += (self.apply_options(self.coverage_cmd),)
self.call_in_sequence(cmds)
class docs(BaseCommand):
"""Use Sphinx Makefile to generate documentation."""
- description = 'generate the Sphinx HTML documentation'
+ description = "generate the Sphinx HTML documentation"
- clean_docs_cmd = 'make -C docs clean'
- html_docs_cmd = 'make -C docs html'
- view_docs_cmd = 'open docs/build/html/index.html'
+ clean_docs_cmd = "make -C docs clean"
+ html_docs_cmd = "make -C docs html"
+ view_docs_cmd = "open docs/build/html/index.html"
def run(self):
"""Generate and view the documentation."""