Skip to content

Commit 35f98ba

Browse files
committed
Added "job_compassplus/tx_parse_xml/count_TODO_NOTE_FIXME_of_ADS_classes.py"
1 parent a0cf239 commit 35f98ba

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = "ipetrash"
5+
6+
7+
import xml.etree.ElementTree as ET
8+
9+
from collections import defaultdict
10+
from pathlib import Path
11+
12+
13+
NS = dict(
14+
xsc="http://schemas.radixware.org/xscml.xsd",
15+
)
16+
17+
18+
def process(path: str):
19+
if isinstance(path, str):
20+
path = Path(path)
21+
22+
if not path.exists():
23+
raise Exception(f"Not exists: {path}")
24+
25+
assignee_by_number: dict[str, int] = defaultdict(int)
26+
type_by_number: dict[str, int] = defaultdict(int)
27+
28+
for layer_dir in path.glob("*"):
29+
if not layer_dir.is_dir():
30+
continue
31+
32+
layer_ads_dir = layer_dir / "ads"
33+
if not layer_ads_dir.is_dir():
34+
continue
35+
36+
for module_path in layer_ads_dir.glob("*/src"):
37+
for class_path in module_path.glob("*.xml"):
38+
model = ET.fromstring(class_path.read_bytes())
39+
for task_el in model.findall(".//xsc:Task", namespaces=NS):
40+
assignee = task_el.attrib["Assignee"].strip()
41+
if not assignee:
42+
assignee = "<unknown>"
43+
44+
assignee_by_number[assignee] += 1
45+
46+
task_type = task_el.attrib["Type"]
47+
type_by_number[task_type] += 1
48+
49+
indent1 = " "
50+
51+
print(f"assignee_by_number ({len(assignee_by_number)}):")
52+
for assignee, number in sorted(
53+
assignee_by_number.items(), key=lambda x: x[1], reverse=True
54+
):
55+
print(f"{indent1}{assignee}: {number}")
56+
print()
57+
58+
print(f"type_by_number ({len(type_by_number)}):")
59+
for task_type, number in sorted(
60+
type_by_number.items(), key=lambda x: x[1], reverse=True
61+
):
62+
print(f"{indent1}{task_type}: {number}")
63+
64+
65+
if __name__ == "__main__":
66+
import argparse
67+
68+
parser = argparse.ArgumentParser(
69+
description="Count TODO, NOTE, FIXME of ADS classes.py"
70+
)
71+
parser.add_argument(
72+
"path_trunk",
73+
metavar="/PATH/TO/TRUNK",
74+
help="Path to source tree (the directory containing branch.xml)",
75+
)
76+
args = parser.parse_args()
77+
78+
process(args.path_trunk)

0 commit comments

Comments
 (0)