Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

Commit 2140b23

Browse files
committed
Run black formatting on the code
1 parent cb4cfc3 commit 2140b23

6 files changed

Lines changed: 213 additions & 239 deletions

File tree

setup.py

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,48 @@
11
import os
22
from setuptools import setup
33

4-
with open('README.md') as f:
4+
with open("README.md") as f:
55
readme = f.read()
66

77
setup(
88
name="sgit",
99
version="0.1.0",
10-
description='CLI tool ',
10+
description="CLI tool ",
1111
long_description=readme,
12-
long_description_content_type='text/markdown',
12+
long_description_content_type="text/markdown",
1313
author="Johan Andersson",
1414
author_email="[email protected]",
15-
maintainer='Johan Andersson',
16-
maintainer_email='[email protected]',
15+
maintainer="Johan Andersson",
16+
maintainer_email="[email protected]",
1717
license="Apache License 2.0",
18-
packages=['sgit'],
19-
url='http://github.com/dynamist/sgit',
18+
packages=["sgit"],
19+
url="http://github.com/dynamist/sgit",
2020
entry_points={
21-
'console_scripts': [
22-
'sgit = sgit.cli:cli_entrypoint',
23-
'git-sub = sgit.cli:cli_entrypoint',
24-
],
21+
"console_scripts": [
22+
"sgit = sgit.cli:cli_entrypoint",
23+
"git-sub = sgit.cli:cli_entrypoint",
24+
]
2525
},
26-
install_requires=[
27-
'docopt>=0.6.2',
28-
'ruamel.yaml>=0.16.0',
29-
'gitpython>=3.1.0',
30-
],
26+
install_requires=["docopt>=0.6.2", "ruamel.yaml>=0.16.0", "gitpython>=3.1.0"],
3127
python_requires=">=3.6",
32-
extras_require={
33-
'dev': [
34-
"pytest",
35-
"pytest-mock",
36-
"pylint",
37-
"mock"
38-
],
39-
},
28+
extras_require={"dev": ["pytest", "pytest-mock", "pylint", "mock"]},
4029
classifiers=[
4130
# 'Development Status :: 1 - Planning',
4231
# 'Development Status :: 2 - Pre-Alpha',
43-
'Development Status :: 3 - Alpha',
32+
"Development Status :: 3 - Alpha",
4433
# 'Development Status :: 4 - Beta',
4534
# 'Development Status :: 5 - Production/Stable',
4635
# 'Development Status :: 6 - Mature',
4736
# 'Development Status :: 7 - Inactive',
48-
'Intended Audience :: Developers',
49-
'Operating System :: OS Independent',
37+
"Intended Audience :: Developers",
38+
"Operating System :: OS Independent",
5039
"License :: OSI Approved :: Apache Software License",
51-
'Environment :: Console',
52-
'Programming Language :: Python',
53-
'Programming Language :: Python :: 3',
54-
'Programming Language :: Python :: 3.6',
55-
'Programming Language :: Python :: 3.7',
56-
'Programming Language :: Python :: 3.8',
40+
"Environment :: Console",
41+
"Programming Language :: Python",
42+
"Programming Language :: Python :: 3",
43+
"Programming Language :: Python :: 3.6",
44+
"Programming Language :: Python :: 3.7",
45+
"Programming Language :: Python :: 3.8",
5746
"Natural Language :: English",
5847
],
5948
)

sgit/__init__.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import logging.config
88
import os
99

10-
__author__ = 'Johan Andersson <[email protected]>'
10+
__author__ = "Johan Andersson <[email protected]>"
1111
__version_info__ = (0, 1, 0)
12-
__version__ = '.'.join(map(str, __version_info__))
12+
__version__ = ".".join(map(str, __version_info__))
1313

1414

1515
log_level_to_string_map = {
@@ -18,7 +18,7 @@
1818
3: "WARNING",
1919
2: "ERROR",
2020
1: "CRITICAL",
21-
0: "INFO"
21+
0: "INFO",
2222
}
2323

2424

@@ -28,27 +28,24 @@ def init_logging(log_level):
2828
"""
2929
log_level = log_level_to_string_map[min(log_level, 5)]
3030

31-
msg = "%(levelname)s - %(name)s:%(lineno)s - %(message)s" if log_level in os.environ else "%(levelname)s - %(message)s"
31+
msg = (
32+
"%(levelname)s - %(name)s:%(lineno)s - %(message)s"
33+
if log_level in os.environ
34+
else "%(levelname)s - %(message)s"
35+
)
3236

3337
logging_conf = {
3438
"version": 1,
35-
"root": {
36-
"level": log_level,
37-
"handlers": ["console"]
38-
},
39+
"root": {"level": log_level, "handlers": ["console"]},
3940
"handlers": {
4041
"console": {
4142
"class": "logging.StreamHandler",
4243
"level": log_level,
4344
"formatter": "simple",
44-
"stream": "ext://sys.stdout"
45+
"stream": "ext://sys.stdout",
4546
}
4647
},
47-
"formatters": {
48-
"simple": {
49-
"format": " {0}".format(msg)
50-
}
51-
}
48+
"formatters": {"simple": {"format": " {0}".format(msg)}},
5249
}
5350

5451
logging.config.dictConfig(logging_conf)

sgit/cli.py

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -100,78 +100,62 @@ def parse_cli():
100100
sys.exit(1)
101101

102102
# In some cases there is no additional sub args of things to extract
103-
if cli_args['<args>']:
103+
if cli_args["<args>"]:
104104
sub_args["<sub_command>"] = cli_args["<args>"][0]
105105

106106
return (cli_args, sub_args)
107107

108+
108109
def run(cli_args, sub_args):
109110
"""Execute the CLI."""
110111
retcode = 0
111112

112-
if 'DEBUG' in os.environ:
113+
if "DEBUG" in os.environ:
113114
print(cli_args)
114115
print(sub_args)
115116

116117
from sgit.core import Sgit
117118

118-
if cli_args['<command>'] == 'repo':
119+
if cli_args["<command>"] == "repo":
119120
core = Sgit()
120121

121-
if sub_args['add']:
122+
if sub_args["add"]:
122123
retcode = core.repo_add(
123-
sub_args['<name>'],
124-
sub_args['<url>'],
125-
sub_args['<rev>'] or 'master',
124+
sub_args["<name>"], sub_args["<url>"], sub_args["<rev>"] or "master"
126125
)
127-
elif sub_args['remove']:
128-
retcode = core.repo_remove(
129-
sub_args['<name>'],
130-
)
131-
elif sub_args['set']:
132-
if sub_args['tag']:
133-
retcode = core.repo_set(
134-
sub_args['<name>'],
135-
'tag',
136-
sub_args['<tag>'],
137-
)
138-
elif sub_args['branch']:
139-
retcode = core.repo_set(
140-
sub_args['<name>'],
141-
'branch',
142-
sub_args['<branch>'],
143-
)
144-
elif sub_args['url']:
126+
elif sub_args["remove"]:
127+
retcode = core.repo_remove(sub_args["<name>"])
128+
elif sub_args["set"]:
129+
if sub_args["tag"]:
130+
retcode = core.repo_set(sub_args["<name>"], "tag", sub_args["<tag>"])
131+
elif sub_args["branch"]:
145132
retcode = core.repo_set(
146-
sub_args['<name>'],
147-
'url',
148-
sub_args['<url>'],
133+
sub_args["<name>"], "branch", sub_args["<branch>"]
149134
)
135+
elif sub_args["url"]:
136+
retcode = core.repo_set(sub_args["<name>"], "url", sub_args["<url>"])
150137
else:
151138
retcode = 1
152-
elif sub_args['rename']:
153-
from_name = sub_args['<from>']
154-
to_name = sub_args['<to>']
139+
elif sub_args["rename"]:
140+
from_name = sub_args["<from>"]
141+
to_name = sub_args["<to>"]
155142

156-
retcode = core.repo_rename(
157-
from_name,
158-
to_name,
159-
)
143+
retcode = core.repo_rename(from_name, to_name)
160144

161-
if cli_args['<command>'] == 'list':
145+
if cli_args["<command>"] == "list":
162146
core = Sgit()
163147
retcode = core.repo_list()
164148

165-
if cli_args['<command>'] == 'update':
149+
if cli_args["<command>"] == "update":
166150
core = Sgit()
167151

168-
if sub_args['update']:
169-
repo = sub_args['<repo>']
170-
repo = repo if repo else 'all'
152+
if sub_args["update"]:
153+
repo = sub_args["<repo>"]
154+
repo = repo if repo else "all"
171155

172156
retcode = core.update(repo)
173157

174-
if cli_args['<command>'] == 'init':
158+
if cli_args["<command>"] == "init":
175159
core = Sgit()
176160

177161
retcode = core.init_repo()

0 commit comments

Comments
 (0)