Skip to content

Commit 5be0866

Browse files
Run black -S.
1 parent 7f3af0b commit 5be0866

File tree

8 files changed

+440
-313
lines changed

8 files changed

+440
-313
lines changed

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
"test": ["coverage"],
4040
},
4141
package_data={
42-
# "umlsequence2": ["tbdpackage__data.dat"],
42+
# "umlsequence2": ["tbdpackage__data.dat"],
4343
},
44-
# data_files=[('data_flow_diagram', ["VERSION"])],
44+
# data_files=[('data_flow_diagram', ["VERSION"])],
4545
# The following would provide a command called `umlsequence2` which
4646
# executes the function `main` from this package when invoked:
4747
entry_points={
@@ -51,8 +51,8 @@
5151
},
5252
project_urls={
5353
"Bug Reports": "https://github.com/pbauermeister/umlsequence2/issues",
54-
# "Funding": "https://donate.pypi.org",
55-
# "Say Thanks!": "http://saythanks.io/to/example",
54+
# "Funding": "https://donate.pypi.org",
55+
# "Say Thanks!": "http://saythanks.io/to/example",
5656
"Source": "https://github.com/pbauermeister/umlsequence2",
5757
},
5858
)

src/umlsequence2/__init__.py

Lines changed: 125 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
VERSION = pkg_resources.require("umlsequence2")[0].version
3333

3434

35-
def generate_svg(input_fp: TextIO, output_path: str, percent_zoom: int,
36-
debug: bool, bgcolor: str) -> None:
35+
def generate_svg(
36+
input_fp: TextIO, output_path: str, percent_zoom: int, debug: bool, bgcolor: str
37+
) -> None:
3738
cmds, raw = Parser(input_fp.read()).parse()
3839

3940
if debug:
@@ -45,16 +46,27 @@ def generate_svg(input_fp: TextIO, output_path: str, percent_zoom: int,
4546
UmlBuilder(cmds, output_path, percent_zoom, bgcolor).run()
4647

4748

48-
def generate(input_fp: TextIO, output_path: str, percent_zoom: int,
49-
verbose: bool, debug: bool, bgcolor: str, format: str) -> None:
49+
def generate(
50+
input_fp: TextIO,
51+
output_path: str,
52+
percent_zoom: int,
53+
verbose: bool,
54+
debug: bool,
55+
bgcolor: str,
56+
format: str,
57+
) -> None:
5058
if debug:
51-
print(dict(input=input_fp.name,
52-
output=output_path,
53-
percent_zoom=percent_zoom,
54-
debug=debug,
55-
bgcolor=bgcolor,
56-
format=format,
57-
), file=sys.stderr)
59+
print(
60+
dict(
61+
input=input_fp.name,
62+
output=output_path,
63+
percent_zoom=percent_zoom,
64+
debug=debug,
65+
bgcolor=bgcolor,
66+
format=format,
67+
),
68+
file=sys.stderr,
69+
)
5870

5971
if verbose:
6072
print(f'umlsequence2: generating file \'{output_path}\'', file=sys.stderr)
@@ -73,70 +85,88 @@ def parse_args() -> argparse.Namespace:
7385

7486
parser = argparse.ArgumentParser(description=description, epilog=epilog)
7587

76-
parser.add_argument('INPUT_FILE',
77-
action='store',
78-
default=None, nargs='?',
79-
help='UML sequence input file; '
80-
'if omitted, stdin is used')
81-
82-
parser.add_argument('--output-file', '-o',
83-
required=False,
84-
help='output file name; pass \'-\' to use stdout; '
85-
'if omitted, use INPUT_FILE base name with \'.svg\' '
86-
'extension, or stdout')
87-
88-
parser.add_argument('--markdown', '-m',
89-
action='store_true',
90-
help='consider snippets between opening marker: '
91-
'```umlsequence OUTFILE, and closing marker: ```');
92-
93-
parser.add_argument('--format', '-f',
94-
required=False,
95-
default='svg',
96-
help='output format: gif, jpg, tiff, bmp, pnm, eps, '
97-
'pdf, svg (any supported by reportlab); default is svg')
98-
99-
parser.add_argument('--percent-zoom', '-p',
100-
required=False,
101-
default=100, type=int,
102-
help='magnification percentage; default is 100')
103-
104-
parser.add_argument('--background-color', '-b',
105-
required=False,
106-
default='white',
107-
help='background color name (including \'none\' for'
108-
' transparent) in web color notation; see'
109-
' https://developer.mozilla.org/en-US/docs/Web/CSS/color_value'
110-
' for a list of valid names; default is white')
111-
112-
parser.add_argument('--verbose',
113-
action='store_true',
114-
default=False,
115-
help='emits verbose messages')
116-
117-
parser.add_argument('--debug',
118-
action='store_true',
119-
default=False,
120-
help='emits debug messages')
121-
122-
parser.add_argument('--version', '-V',
123-
action='store_true',
124-
help='print the version and exit')
88+
parser.add_argument(
89+
'INPUT_FILE',
90+
action='store',
91+
default=None,
92+
nargs='?',
93+
help='UML sequence input file; ' 'if omitted, stdin is used',
94+
)
95+
96+
parser.add_argument(
97+
'--output-file',
98+
'-o',
99+
required=False,
100+
help='output file name; pass \'-\' to use stdout; '
101+
'if omitted, use INPUT_FILE base name with \'.svg\' '
102+
'extension, or stdout',
103+
)
104+
105+
parser.add_argument(
106+
'--markdown',
107+
'-m',
108+
action='store_true',
109+
help='consider snippets between opening marker: '
110+
'```umlsequence OUTFILE, and closing marker: ```',
111+
)
112+
113+
parser.add_argument(
114+
'--format',
115+
'-f',
116+
required=False,
117+
default='svg',
118+
help='output format: gif, jpg, tiff, bmp, pnm, eps, '
119+
'pdf, svg (any supported by reportlab); default is svg',
120+
)
121+
122+
parser.add_argument(
123+
'--percent-zoom',
124+
'-p',
125+
required=False,
126+
default=100,
127+
type=int,
128+
help='magnification percentage; default is 100',
129+
)
130+
131+
parser.add_argument(
132+
'--background-color',
133+
'-b',
134+
required=False,
135+
default='white',
136+
help='background color name (including \'none\' for'
137+
' transparent) in web color notation; see'
138+
' https://developer.mozilla.org/en-US/docs/Web/CSS/color_value'
139+
' for a list of valid names; default is white',
140+
)
141+
142+
parser.add_argument(
143+
'--verbose', action='store_true', default=False, help='emits verbose messages'
144+
)
145+
146+
parser.add_argument(
147+
'--debug', action='store_true', default=False, help='emits debug messages'
148+
)
149+
150+
parser.add_argument(
151+
'--version', '-V', action='store_true', help='print the version and exit'
152+
)
125153

126154
# add config float values, e.g. COLUMN_WIDTH as --COLUMN-WIDTH
127155
cfg = get_config().__dict__
128156
conf_keys = [k for k, v in cfg.items() if isinstance(v, float)]
129157
for k in conf_keys:
130-
parser.add_argument('--' + k.replace('_', '-'),
131-
metavar='FLOAT', type=float,
132-
help=f'change {k} (default {cfg[k]})')
158+
parser.add_argument(
159+
'--' + k.replace('_', '-'),
160+
metavar='FLOAT',
161+
type=float,
162+
help=f'change {k} (default {cfg[k]})',
163+
)
133164

134165
args = parser.parse_args()
135166
args.format = args.format.lower()
136167

137168
# parse back config modifiers args
138-
conf_args = {k:args.__dict__[k] for k in conf_keys
139-
if args.__dict__[k] is not None}
169+
conf_args = {k: args.__dict__[k] for k in conf_keys if args.__dict__[k] is not None}
140170
if conf_args:
141171
cfg.update(conf_args)
142172
set_config(model.Config(**cfg))
@@ -151,19 +181,26 @@ def run(args: argparse.Namespace) -> None:
151181
else:
152182
inp = open(args.INPUT_FILE)
153183

154-
155184
# markdown
156185
if args.markdown:
157-
rx = re.compile(r'^```\s*umlsequence\s+(?P<output>.*?)\s*'
158-
r'^(?P<src>.*?)^\s*```', re.DOTALL | re.M
186+
rx = re.compile(
187+
r'^```\s*umlsequence\s+(?P<output>.*?)\s*' r'^(?P<src>.*?)^\s*```',
188+
re.DOTALL | re.M,
159189
)
160190
md = inp.read()
161191
for snippet in rx.finditer(md):
162192
inp = io.StringIO(snippet['src'])
163193
name = snippet['output']
164194
inp.name = name
165-
generate(inp, name, args.percent_zoom, args.debug, args.verbose,
166-
args.background_color, args.format)
195+
generate(
196+
inp,
197+
name,
198+
args.percent_zoom,
199+
args.debug,
200+
args.verbose,
201+
args.background_color,
202+
args.format,
203+
)
167204
print(f'{sys.argv[0]}: generated {name}', file=sys.stderr)
168205
return
169206

@@ -180,14 +217,28 @@ def run(args: argparse.Namespace) -> None:
180217
# output to stdout
181218
with tempfile.TemporaryDirectory() as d:
182219
path = os.path.join(d, 'file.svg')
183-
generate(inp, path, args.percent_zoom, args.debug, args.verbose,
184-
args.background_color, args.format)
220+
generate(
221+
inp,
222+
path,
223+
args.percent_zoom,
224+
args.debug,
225+
args.verbose,
226+
args.background_color,
227+
args.format,
228+
)
185229
with open(path) as f:
186230
print(f.read())
187231
else:
188232
# output to file
189-
generate(inp, name, args.percent_zoom, args.debug, args.verbose,
190-
args.background_color, args.format)
233+
generate(
234+
inp,
235+
name,
236+
args.percent_zoom,
237+
args.debug,
238+
args.verbose,
239+
args.background_color,
240+
args.format,
241+
)
191242

192243

193244
def main() -> None:

src/umlsequence2/config.py

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,27 @@
99

1010
# Dimensions are in cm.
1111
_CONFIG = model.Config(
12-
ACTIVITY_WIDTH = 0.20,
13-
14-
ACTOR_ASCENT = 0.25,
15-
ACTOR_DESCENT = 0.45,
16-
ACTOR_LABEL_Y = 0.90,
17-
18-
ARROW_HEAD_SIZE = 0.30,
19-
20-
COLOR_GREY = '#aaaaaa',
21-
22-
COLUMN_SPACING = 0.25,
23-
COLUMN_WIDTH = 2.75,
24-
25-
CROSS_SIZE = 0.50,
26-
27-
MESSAGE_SPACING = 0.05,
28-
29-
OBJECT_HEIGHT = 0.60,
30-
OBJECT_LABEL_Y = 0.40,
31-
OBJECT_STEP = 0.90,
32-
33-
STEP_NORMAL = 0.60,
34-
STEP_SMALL = 0.30,
35-
36-
TEXT_CHAR_WIDTH = 0.145,
37-
TEXT_DOGEAR = 0.20,
38-
TEXT_HEIGHT = 0.40,
39-
TEXT_FONT = dict(font_family='Helvetica, Arial, sans-serif',
40-
font_size='10px'),
41-
TEXT_MARGIN_X = 0.20,
42-
TEXT_MARGIN_Y = 0.15,
12+
ACTIVITY_WIDTH=0.20,
13+
ACTOR_ASCENT=0.25,
14+
ACTOR_DESCENT=0.45,
15+
ACTOR_LABEL_Y=0.90,
16+
ARROW_HEAD_SIZE=0.30,
17+
COLOR_GREY='#aaaaaa',
18+
COLUMN_SPACING=0.25,
19+
COLUMN_WIDTH=2.75,
20+
CROSS_SIZE=0.50,
21+
MESSAGE_SPACING=0.05,
22+
OBJECT_HEIGHT=0.60,
23+
OBJECT_LABEL_Y=0.40,
24+
OBJECT_STEP=0.90,
25+
STEP_NORMAL=0.60,
26+
STEP_SMALL=0.30,
27+
TEXT_CHAR_WIDTH=0.145,
28+
TEXT_DOGEAR=0.20,
29+
TEXT_HEIGHT=0.40,
30+
TEXT_FONT=dict(font_family='Helvetica, Arial, sans-serif', font_size='10px'),
31+
TEXT_MARGIN_X=0.20,
32+
TEXT_MARGIN_Y=0.15,
4333
)
4434

4535

src/umlsequence2/error.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22

3+
34
def print_error(text: str) -> None:
45
if sys.stderr.isatty():
56
text = f'\033[31m{text}\033[0m'

0 commit comments

Comments
 (0)