diff extensions/kwarchive.py @ 114:a51822141ccf

Style: handled some more flake8 warnings: consistent command declaration list formatting
author Franz Glasner <hg@dom66.de>
date Thu, 16 Aug 2018 18:53:11 +0200
parents 1744b36c39b7
children 06a60e2a9887
line wrap: on
line diff
--- a/extensions/kwarchive.py	Thu Aug 16 18:44:02 2018 +0200
+++ b/extensions/kwarchive.py	Thu Aug 16 18:53:11 2018 +0200
@@ -62,16 +62,18 @@
 command = cmdutil.command(cmdtable)
 
 
-@command('kwarchive',
-    [('', 'no-decode', None, _('do not pass files through decoders')),
-     ('p', 'prefix', '', _('directory prefix for files in archive'), _('PREFIX')),
-     ('r', 'rev', '', _('revision to distribute'), _('REV')),
-     ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
-     ('', 'path', 'default', _('the canonical repository to use'), _('PATH')),
-     ('', "kwconfig", '', _('an alternate pattern configuration configuration file'), _('PATTERNCONFIG')),
-     ('', "no-shorten-path", None, _("don't shorten the path urls")),
-     ('', "path-filter", "short", _("determine how the path will be printed")),
-     ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER")),
+@command(
+    'kwarchive',
+    [
+        ('', 'no-decode', None, _('do not pass files through decoders')),
+        ('p', 'prefix', '', _('directory prefix for files in archive'), _('PREFIX')),
+        ('r', 'rev', '', _('revision to distribute'), _('REV')),
+        ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
+        ('', 'path', 'default', _('the canonical repository to use'), _('PATH')),
+        ('', "kwconfig", '', _('an alternate pattern configuration configuration file'), _('PATTERNCONFIG')),
+        ('', "no-shorten-path", None, _("don't shorten the path urls")),
+        ('', "path-filter", "short", _("determine how the path will be printed")),
+        ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER"))
     ] + cmdutil.subrepoopts + cmdutil.walkopts,
     _('[OPTION]... DEST'))
 def kwarchive(ui, repo, dest, **opts):
@@ -191,14 +193,16 @@
     #            output match filters (see archival.archive()).
 
 
-@command('kwprint',
-    [('r', 'rev', '', _('revision to distribute'), _('REV')),
-     ('', 'path', 'default', _('the canonical repository to use'), _('PATH')),
-     ('', "no-shorten-path", None, _("don't shorten the path urls")),
-     ('', "path-filter", "short", _("determine how the path will be printed")),
-     ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER")),
-     ('', "reST", None, _("output in reST substitution definition syntax")),
-     ('', "no-file", None, _("don't show file-dependent keywords")),
+@command(
+    'kwprint',
+    [
+        ('r', 'rev', '', _('revision to distribute'), _('REV')),
+        ('', 'path', 'default', _('the canonical repository to use'), _('PATH')),
+        ('', "no-shorten-path", None, _("don't shorten the path urls")),
+        ('', "path-filter", "short", _("determine how the path will be printed")),
+        ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER")),
+        ('', "reST", None, _("output in reST substitution definition syntax")),
+        ('', "no-file", None, _("don't show file-dependent keywords")),
     ] + cmdutil.subrepoopts + cmdutil.walkopts,
     _('[OPTION]...'))
 def kwprint(ui, repo, **opts):
@@ -398,7 +402,8 @@
                     path_uri = util.hidepassword(ui.paths[hgpath].loc)
                 elif path_filter == "short":
                     path_url = util.url(ui.paths[hgpath].loc)
-                    path_url.scheme = SHORTENED_HG_SCHEMES.get(path_url.scheme, "hg")
+                    path_url.scheme = SHORTENED_HG_SCHEMES.get(path_url.scheme,
+                                                               "hg")
                     path_url.user = None
                     path_url.passwd = None
                     path_url.host = stripped_hostname(path_url.host)
@@ -408,7 +413,8 @@
                     path_url = str(util.url(ui.paths[hgpath].loc)).split("/")
                     path_uri = bytes(path_url[-1])
                 else:
-                    raise error.Abort("path-filter `%s' not implemented" % path_filter)
+                    raise error.Abort("path-filter `%s' not implemented"
+                                      % path_filter)
             except LookupError:
                 raise error.Abort(_('repository %s not found') % hgpath)
     else:
@@ -416,7 +422,8 @@
     if path_uri.startswith(b"\\\\"):
         # Make an URL from a Windows UNC path
         path_uri = b"file:///" + path_uri.replace(b'\\', b'/')
-    elif len(path_uri) >= 2 and (b'A' <= path_uri[0].upper() <= b'Z') and path_uri[1] == b':':
+    elif len(path_uri) >= 2 and (b'A' <= path_uri[0].upper() <= b'Z') \
+            and path_uri[1] == b':':
         # make an URL from a Windows path with drive letter
         path_uri = b"file:///" + path_uri.replace(b'\\', b'/')
     elif path_uri.startswith(b'/'):
@@ -432,7 +439,8 @@
     if user_filter == "user":
         keywords["Author"] = templatefilters.emailuser(ctx.user())
     elif user_filter == "person":
-        keywords["Author"] = templatefilters.utf8(templatefilters.person(ctx.user()).replace(' ', '+'))
+        keywords["Author"] = templatefilters.utf8(
+            templatefilters.person(ctx.user()).replace(' ', '+'))
     elif user_filter == "email":
         keywords["Author"] = templatefilters.email(ctx.user())
     elif user_filter in ("full", "none",):
@@ -474,15 +482,17 @@
 def get_checked_user_filter(opts):
     uf = opts.get("user_filter")
     # "none" is retained for compatibility reasons and now an alias for "full"
-    if not uf in ("person", "user", "email", "full", "none"):
-        raise error.Abort(_("user filter must be any of `user', `person' or `email'"))
+    if uf not in ("person", "user", "email", "full", "none"):
+        raise error.Abort(
+            _("user filter must be any of `user', `person' or `email'"))
     return uf
 
 
 def get_checked_path_filter(opts):
     pf = opts.get("path_filter")
-    if not pf in ("full", "nopwd", "short", "last"):
-        raise error.Abort(_("path filter must be any of `full', `nopwd', `short' or `last'"))
+    if pf not in ("full", "nopwd", "short", "last"):
+        raise error.Abort(
+            _("path filter must be any of `full', `nopwd', `short' or `last'"))
     return pf