Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/build_config/update_templates.py
169674 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2015-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file update_templates.py
15
# @author Jakob Erdmann
16
# @date Jan 2025
17
18
"""
19
This script finds tools that should be added to templates.py
20
"""
21
22
import os
23
import sys
24
from os import path
25
import glob
26
from templates import TOOLS, generateToolTemplates
27
28
toolDir = path.join(path.dirname(__file__), '..')
29
pyfiles = glob.glob("**/*.py", root_dir=toolDir, recursive=True)
30
print("found %s python files" % len(pyfiles))
31
32
candidates = []
33
for fname in pyfiles:
34
with open(os.path.join(toolDir, fname)) as f:
35
for line in f:
36
if "ArgumentParser" in line:
37
candidates.append(fname)
38
break
39
print("found %s files that use ArgumentParser" % len(candidates))
40
41
candidates = [f for f in candidates if path.dirname(f) not in ('build_config', 'devel', 'game', 'purgatory')]
42
print("found %s tools in eligble directories" % len(candidates))
43
44
usedTools = set(TOOLS)
45
candidates = [f for f in candidates if f not in usedTools]
46
print("found %s tools that are not listed in templates.py" % len(candidates))
47
48
failed = generateToolTemplates(toolDir, candidates, False, True)
49
if failed:
50
print("%s tools fail at template generation:" % len(failed))
51
print('\n'.join(failed), file=sys.stderr)
52
failedSet = set(failed)
53
missing = [f for f in candidates if f not in failedSet]
54
print("found %s usable tools:" % len(missing))
55
print('\n'.join(missing))
56
57