diff options
author | Gavin Mak <gavinmak@google.com> | 2023-03-11 06:46:20 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-22 17:46:28 +0000 |
commit | ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1 (patch) | |
tree | dc33ba0e56825b3e007d0589891756724725a465 /subcmds/__init__.py | |
parent | 1604cf255f8c1786a23388db6d5277ac7949a24a (diff) | |
download | git-repo-ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1.tar.gz |
Format codebase with black and check formatting in CQ
Apply rules set by https://gerrit-review.googlesource.com/c/git-repo/+/362954/ across the codebase and fix any lingering errors caught
by flake8. Also check black formatting in run_tests (and CQ).
Bug: b/267675342
Change-Id: I972d77649dac351150dcfeb1cd1ad0ea2efc1956
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/363474
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'subcmds/__init__.py')
-rw-r--r-- | subcmds/__init__.py | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/subcmds/__init__.py b/subcmds/__init__.py index 051dda06..4e41afc0 100644 --- a/subcmds/__init__.py +++ b/subcmds/__init__.py | |||
@@ -19,31 +19,29 @@ all_commands = {} | |||
19 | 19 | ||
20 | my_dir = os.path.dirname(__file__) | 20 | my_dir = os.path.dirname(__file__) |
21 | for py in os.listdir(my_dir): | 21 | for py in os.listdir(my_dir): |
22 | if py == '__init__.py': | 22 | if py == "__init__.py": |
23 | continue | 23 | continue |
24 | 24 | ||
25 | if py.endswith('.py'): | 25 | if py.endswith(".py"): |
26 | name = py[:-3] | 26 | name = py[:-3] |
27 | 27 | ||
28 | clsn = name.capitalize() | 28 | clsn = name.capitalize() |
29 | while clsn.find('_') > 0: | 29 | while clsn.find("_") > 0: |
30 | h = clsn.index('_') | 30 | h = clsn.index("_") |
31 | clsn = clsn[0:h] + clsn[h + 1:].capitalize() | 31 | clsn = clsn[0:h] + clsn[h + 1 :].capitalize() |
32 | 32 | ||
33 | mod = __import__(__name__, | 33 | mod = __import__(__name__, globals(), locals(), ["%s" % name]) |
34 | globals(), | 34 | mod = getattr(mod, name) |
35 | locals(), | 35 | try: |
36 | ['%s' % name]) | 36 | cmd = getattr(mod, clsn) |
37 | mod = getattr(mod, name) | 37 | except AttributeError: |
38 | try: | 38 | raise SyntaxError( |
39 | cmd = getattr(mod, clsn) | 39 | "%s/%s does not define class %s" % (__name__, py, clsn) |
40 | except AttributeError: | 40 | ) |
41 | raise SyntaxError('%s/%s does not define class %s' % ( | 41 | |
42 | __name__, py, clsn)) | 42 | name = name.replace("_", "-") |
43 | 43 | cmd.NAME = name | |
44 | name = name.replace('_', '-') | 44 | all_commands[name] = cmd |
45 | cmd.NAME = name | ||
46 | all_commands[name] = cmd | ||
47 | 45 | ||
48 | # Add 'branch' as an alias for 'branches'. | 46 | # Add 'branch' as an alias for 'branches'. |
49 | all_commands['branch'] = all_commands['branches'] | 47 | all_commands["branch"] = all_commands["branches"] |