Skip to content

Commit b9ecd21

Browse files
authored
Merge pull request #9 from cms-l1-globaltrigger/devel-0.8.x
0.8.0
2 parents a6fbd87 + cffe452 commit b9ecd21

File tree

9 files changed

+244
-193
lines changed

9 files changed

+244
-193
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Install using pip (>= 19.0).
77

88
```bash
99
pip install --upgrade pip
10-
pip install git+https://github.com/cms-l1-globaltrigger/tm-diff.git@0.7.3
10+
pip install git+https://github.com/cms-l1-globaltrigger/tm-diff.git@0.8.0
1111
```
1212

1313
## Basic usage

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
tm-python @ git+https://github.com/cms-l1-globaltrigger/tm-python@0.10.0
1+
tm-python @ git+https://github.com/cms-l1-globaltrigger/tm-python@0.11.0

setup.cfg

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[metadata]
2+
name = tm-diff
3+
version = attr: tmDiff.__version__
4+
author = Bernhard Arnold
5+
author_email = bernhard.arnold@cern.ch
6+
description = Compare the content of two XML trigger menus.
7+
long_description = file: README.md
8+
long_description_content_type = text/markdown
9+
license = GPLv3
10+
classifiers =
11+
"Topic :: Software Development"
12+
"Topic :: Utilities"
13+
14+
[options]
15+
python_requires = >=3.6
16+
packages = find:
17+
install_requires =
18+
tm-python @ git+https://github.com/cms-l1-globaltrigger/tm-python@0.11.0
19+
test_suite = tests
20+
21+
[options.packages.find]
22+
exclude=tests
23+
24+
[options.entry_points]
25+
console_scripts =
26+
tm-diff = tmDiff.__main__:main
27+
28+
[mypy]
29+
30+
[mypy-tmTable.*]
31+
ignore_missing_imports = True

setup.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

tmDiff/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.7.3'
1+
__version__ = "0.8.0"

tmDiff/__main__.py

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,106 @@
11
import argparse
2-
import sys, os
2+
import os
3+
import sys
4+
from typing import Callable, Dict, List
35

46
from . import menudiff
57
from . import __version__
68

7-
FMT_UNIFIED = 'unified'
8-
FMT_CONTEXT = 'context'
9-
FMT_HTML = 'html'
10-
FMT_REPORT = 'report'
11-
FMT_DEFAULT = FMT_UNIFIED
12-
FMT_CHOICES = [FMT_UNIFIED, FMT_CONTEXT, FMT_HTML, FMT_REPORT]
13-
14-
SKIP_MODULE = 'module'
15-
SKIP_COMMENT = 'comment'
16-
SKIP_LABELS = 'labels'
17-
SKIP_CHOICES = [SKIP_MODULE, SKIP_COMMENT, SKIP_LABELS]
18-
19-
SORT_INDEX = 'index'
20-
SORT_NAME = 'name'
21-
SORT_EXPRESSION = 'expression'
22-
SORT_DEFAULT = SORT_INDEX
23-
SORT_CHOICES = [SORT_INDEX, SORT_NAME, SORT_EXPRESSION]
24-
25-
DIFF_FUNCTIONS = {
9+
FMT_UNIFIED: str = "unified"
10+
FMT_CONTEXT: str = "context"
11+
FMT_HTML: str = "html"
12+
FMT_REPORT: str = "report"
13+
FMT_DEFAULT: str = FMT_UNIFIED
14+
FMT_CHOICES: List[str] = [FMT_UNIFIED, FMT_CONTEXT, FMT_HTML, FMT_REPORT]
15+
16+
SKIP_MODULE: str = "module"
17+
SKIP_COMMENT: str = "comment"
18+
SKIP_LABELS: str = "labels"
19+
SKIP_CHOICES: List[str] = [SKIP_MODULE, SKIP_COMMENT, SKIP_LABELS]
20+
21+
SORT_INDEX: str = "index"
22+
SORT_NAME: str = "name"
23+
SORT_EXPRESSION: str = "expression"
24+
SORT_DEFAULT: str = SORT_INDEX
25+
SORT_CHOICES: List[str] = [SORT_INDEX, SORT_NAME, SORT_EXPRESSION]
26+
27+
DIFF_FUNCTIONS: Dict[str, Callable] = {
2628
FMT_UNIFIED: menudiff.unified_diff,
2729
FMT_CONTEXT: menudiff.context_diff,
2830
FMT_HTML: menudiff.html_diff,
2931
FMT_REPORT: menudiff.report_diff,
3032
}
3133

32-
def parse_args():
34+
35+
def parse_args() -> argparse.Namespace:
3336
parser = argparse.ArgumentParser()
34-
parser.add_argument('file',
37+
parser.add_argument("file",
3538
nargs=2,
3639
help="XML menu files 'FILE1 FILE2'"
3740
)
38-
parser.add_argument('-f', '--format',
39-
metavar='<format>',
41+
parser.add_argument("-f", "--format",
42+
metavar="<format>",
4043
choices=FMT_CHOICES,
4144
default=FMT_DEFAULT,
42-
help="select output format, default is '{0}'".format(FMT_DEFAULT)
45+
help=f"select output format, default is '{FMT_DEFAULT}'"
4346
)
44-
parser.add_argument('-s', '--skip',
45-
metavar='<mode>',
46-
action='append',
47+
parser.add_argument("-s", "--skip",
48+
metavar="<mode>",
49+
action="append",
4750
choices=SKIP_CHOICES,
4851
default=[],
4952
help="skip information"
5053
)
51-
parser.add_argument('--sort',
52-
metavar='<key>',
54+
parser.add_argument("--sort",
55+
metavar="<key>",
5356
choices=SORT_CHOICES,
5457
default=SORT_DEFAULT,
55-
help="select key for algorithm sorting, default is '{0}'".format(SORT_DEFAULT)
58+
help=f"select key for algorithm sorting, default is '{SORT_DEFAULT}'"
5659
)
57-
parser.add_argument('-d', '--dump',
58-
action='store_true',
59-
help="dump the extracted intermediate content"
60+
parser.add_argument("-d", "--dump",
61+
action="store_true",
62+
help="dump the extracted intermediate content"
6063
)
61-
parser.add_argument('-o',
62-
dest='ostream',
63-
metavar='<file>',
64-
type=argparse.FileType('w'),
64+
parser.add_argument("-o",
65+
dest="ostream",
66+
metavar="<file>",
67+
type=argparse.FileType("wt"),
6568
default=sys.stdout,
6669
help="write output to file"
6770
)
68-
parser.add_argument('-v', '--verbose',
69-
action='count',
71+
parser.add_argument("-v", "--verbose",
72+
action="count",
7073
help="increase output verbosity"
7174
)
72-
parser.add_argument('--version',
73-
action='version',
75+
parser.add_argument("--version",
76+
action="version",
7477
version="%(prog)s {0}".format(__version__)
7578
)
7679
return parser.parse_args()
7780

78-
def main():
81+
82+
def main() -> int:
7983
args = parse_args()
8084

81-
from_file = args.file[0]
82-
to_file = args.file[1]
85+
from_file: str = args.file[0]
86+
to_file: str = args.file[1]
8387

84-
skip = []
88+
skip: List[str] = []
8589

8690
# Skip module specific attributes
8791
if SKIP_MODULE in args.skip:
88-
skip.append('uuid_firmware')
89-
skip.append('n_modules')
90-
skip.append('module_id')
91-
skip.append('module_index')
92+
skip.append("uuid_firmware")
93+
skip.append("n_modules")
94+
skip.append("module_id")
95+
skip.append("module_index")
9296

9397
# Skip comments
9498
if SKIP_COMMENT in args.skip:
95-
skip.append('comment')
99+
skip.append("comment")
96100

97101
# Skip comments
98102
if SKIP_LABELS in args.skip:
99-
skip.append('labels')
103+
skip.append("labels")
100104

101105
# Extract information from XMLs
102106
from_menu = menudiff.Menu(from_file)
@@ -121,5 +125,6 @@ def main():
121125

122126
return 0
123127

124-
if __name__ == '__main__':
128+
129+
if __name__ == "__main__":
125130
sys.exit(main())

0 commit comments

Comments
 (0)