Files
ACP/scan_devices.py
T
2026-08-06 14:04:28 +08:00

41 lines
1.3 KiB
Python

import re, glob, json
files = glob.glob(r'C:\Users\kk\Desktop\ACP\极电子程序\*.ats')
full_names = set()
method_names = {}
for f in files:
content = open(f, encoding='utf-8-sig').read()
# Find all FullName values
for m in re.finditer(r'"FullName":\s*"([^"]+)"', content):
full_names.add(m.group(1))
# Find all Method Name + FullName pairs
data = json.loads(content)
def extract_methods(steps):
for step in steps:
method = step.get('Method')
if method and method.get('Name') and method.get('FullName'):
key = method['FullName']
if key not in method_names:
method_names[key] = set()
method_names[key].add(method['Name'])
# Check SubProgram (nested steps)
sub = step.get('SubProgram')
if sub and isinstance(sub, dict):
sub_steps = sub.get('StepCollection', [])
extract_methods(sub_steps)
steps = data.get('StepCollection', [])
extract_methods(steps)
print("=== All FullName values ===")
for name in sorted(full_names):
print(f" {name}")
print("\n=== Methods per device ===")
for device in sorted(method_names.keys()):
print(f"\n {device}:")
for method in sorted(method_names[device]):
print(f" - {method}")