Skip to content

Commit 965fbb8

Browse files
Cosmetic refactorings, Update of docs.
1 parent 53af64d commit 965fbb8

File tree

7 files changed

+45
-29
lines changed

7 files changed

+45
-29
lines changed

CHANGES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changes
2+
3+
## Version 2.0.6
4+
- use more recent setuptools.
5+
- use Typing and mypy.
6+
- require Python 3.10 or upper.
7+
8+
## Version 2.0.5 and below
9+
- Rewrite of https://github.com/pbauermeister/umlsequence in pure
10+
Python (+ reportlab).

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
umlsequence2
22
============
33

4-
UML Sequence Diagrams Generator - Commandline tool to generate
4+
UML Sequence Diagrams Generator, version 2<sup>[1]</sup> -
5+
Commandline tool to generate
56
diagrams as images in various formats (SVG, PNG, JPG, PDF, etc.) from
67
source text files.
78

8-
Source code: https://github.com/pbauermeister/umlsequence2
9+
- Source code: https://github.com/pbauermeister/umlsequence2
10+
- Package page: https://pypi.org/project/umlsequence2/
911

10-
(This is a pure-Python rewrite of the
12+
<sub>[1] This is a pure-Python rewrite of the
1113
https://github.com/pbauermeister/umlsequence project, which was itself
12-
based on umlgraph by Diomidis Spinellis.)
14+
based on umlgraph (in Java) by Diomidis Spinellis.</sub>
15+
16+
## Scope
17+
18+
"*A sequence diagram or system sequence diagram (SSD) shows process interactions
19+
arranged in time sequence in the field of software engineering. It depicts the
20+
processes involved and the sequence of messages exchanged between the processes
21+
needed to carry out the functionality.*"
22+
-- [Wikipedia](https://en.wikipedia.org/wiki/Sequence_diagram)
23+
## Summary
1324

1425
Source text files are in the so-called "umlsequence" syntax.
1526

@@ -20,21 +31,21 @@ Umlsequence syntax example:
2031
T : t:thread
2132
O : :Toolkit
2233
P :
23-
34+
2435
# messages and activations
2536
E -> T+ a1:run(3)
2637
T -> O+ run()
2738
O >callbackLoop()
28-
39+
2940
# creation
3041
O+ :> P p:Peer
31-
42+
3243
# message with response
3344
O- => P result=handleExpose()
34-
45+
3546
# destruction
3647
O #> P
37-
48+
3849
# deactivation
3950
T- O-
4051

TODO.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# TODO:
2+
3+
- in uml_builder, move keywords to constants defined in model
4+
- in parser, move preprocess to own module
5+
- in parser, refactor regex and handling
6+
- in parser, refactor horrendous do_line() in smaller functions.
7+

src/umlsequence2/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525

2626
from .config import get_config, set_config
2727
from .converter import convert
28-
from .model import Config
2928
from .parser import Parser
3029
from .uml_builder import UmlBuilder
31-
from . import error
30+
from . import error, model
3231

3332
VERSION = pkg_resources.require("umlsequence2")[0].version
3433

@@ -132,7 +131,7 @@ def parse_args() -> argparse.Namespace:
132131
if args.__dict__[k] is not None}
133132
if conf_args:
134133
cfg.update(conf_args)
135-
set_config(Config(**cfg))
134+
set_config(model.Config(**cfg))
136135

137136
return args
138137

@@ -194,7 +193,7 @@ def main() -> None:
194193
try:
195194
run(args)
196195
except model.UmlSequenceError as e:
197-
error.print_error(e)
196+
error.print_error(str(e))
198197
sys.exit(1)
199198

200199
sys.exit(0)

src/umlsequence2/parser.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
55
"""
66
import re
7+
from typing import Any
78

89
from . import model
9-
from typing import Any
1010

1111

1212
def escape(s: str) -> str:
@@ -37,24 +37,15 @@ class Parser:
3737
"([#A-Za-z_0-9]*)([\+\-\#~!]?)"
3838
" *"
3939
"(.*)")
40-
41-
#RE_MESSAGE_call = re.compile("([A-Za-z_0-9]+) *(=) *(.*)")
4240
RE_MESSAGE_call = re.compile("(.*?) *(=) *(.*)")
43-
4441
RE_OBJ_STATE = re.compile("([A-Za-z_0-9]+[\+\-\#~!]|:)+")
45-
4642
RE_CONSTRAINT = re.compile("([A-Za-z_0-9]*)([\+\-\#~!]?) *(_?)\{(.*)\}")
4743

4844
extensions = ['.dot']
4945

5046
def __init__(self, raw: str):
51-
# save call arguments for later use in format()
52-
#self.raw = raw.encode('utf-8')
53-
#self.raw = raw.encode('latin1')
5447
self.raw = raw
5548

56-
return
57-
5849
def parse1(self, lines: list[str]) -> list[model.Command]:
5950
cmds: list[model.Command] = []
6051

src/umlsequence2/svg_renderer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import Sequence
33

44
import svgwrite
5-
from svgwrite import cm, mm
65

76
from .config import get_config
87

src/umlsequence2/uml_builder.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
import re
55
import sys
6-
from collections import OrderedDict, namedtuple
7-
from subprocess import PIPE, Popen
8-
from typing import Any, TypeVar, Callable
6+
from collections import OrderedDict
7+
from typing import Any, Callable, TypeVar
98

109
from .config import get_config
1110
from .svg_renderer import SvgRenderer
@@ -33,10 +32,10 @@ def __init__(self, name: str, builder: UmlBuilder):
3332

3433
def __getitem__(self, key: str) -> T:
3534
try:
36-
return super().__getitem__(key)
35+
res = super().__getitem__(key)
3736
except KeyError:
3837
error(f'There is no {self.name} named "{key}"', self.builder)
39-
38+
return res
4039

4140
CODict = CheckedOrderedDict
4241

0 commit comments

Comments
 (0)