Skip to content

Commit f1222b5

Browse files
authored
Clean autocoders code (#1240)
* lint JSONDictionaryGen.py * lint implgen.py * clean if elif statements * lint AddSysPath * Update JSONDictionaryGen.py * Update gds_dictgen.py * Update tlm_packet_gen.py * Update pymod_dictgen.py * Update gds_dictgen.py * Update implgen.py
1 parent 8314f71 commit f1222b5

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

Autocoders/Python/bin/JSONDictionaryGen.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def pinit():
9090

9191

9292
def main():
93-
9493
parser = pinit()
9594
(opts, args) = parser.parse_args()
9695

@@ -116,7 +115,7 @@ def main():
116115
if not opts.build_root_overwrite is None:
117116
set_build_roots(opts.build_root_overwrite)
118117
else:
119-
if ("BUILD_ROOT" in os.environ.keys()) == False:
118+
if ("BUILD_ROOT" in os.environ.keys()) is False:
120119
print("ERROR: Build root not set to root build path...")
121120
sys.exit(-1)
122121
set_build_roots(os.environ["BUILD_ROOT"])
@@ -305,19 +304,19 @@ def main():
305304

306305
# Prepend instance name to commands, events, and channels with duplicate component types
307306
# PRINT.info(json.dumps(instanceIDs, indent=4))
308-
for telemetryType, idDict in list(instanceIDs.items()):
309-
for name, ids in list(idDict.items()):
307+
for telemetry_type, id_dict in list(instanceIDs.items()):
308+
for name, ids in list(id_dict.items()):
310309
if len(ids) > 1:
311310
for id in ids:
312-
telem = dictionary[deployment][telemetryType][id]
311+
telem = dictionary[deployment][telemetry_type][id]
313312
name = telem["name"]
314-
instanceName = telem["instance"]
315-
name = "_".join([instanceName, name])
313+
instance_name = telem["instance"]
314+
name = "_".join([instance_name, name])
316315
telem["name"] = name
317316

318317
# Stringify JSON -- indent option makes it readable, can be removed if file
319318
# size is an issue
320-
jsonStr = json.dumps(dictionary, indent=4)
319+
json_str = json.dumps(dictionary, indent=4)
321320

322321
# Create output directory if it doesn't exist
323322
directory = os.path.dirname(outFilepath)
@@ -326,7 +325,7 @@ def main():
326325

327326
# Write JSON to file
328327
outFile = open(outFilepath, "w")
329-
outFile.write(jsonStr)
328+
outFile.write(json_str)
330329
descriptionFile = open(descriptionFilename, "w")
331330
descriptionFile.write(outFilepath)
332331
PRINT.info("\nJSON output written to %s" % outFilepath)

Autocoders/Python/src/fprime_ac/utils/AddSysPath.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def AddSysPath(new_path):
3030
new_path = new_path.lower()
3131

3232
# Check against all currently available paths
33-
for x in sys.path:
34-
x = os.path.abspath(x)
33+
for item in sys.path:
34+
item = os.path.abspath(item)
3535

3636
if sys.platform == "win32":
37-
x = x.lower()
37+
item = item.lower()
3838

39-
if new_path in (x, x + os.sep):
39+
if new_path in (item, item + os.sep):
4040
return 0
4141

4242
sys.path.append(new_path)
@@ -47,8 +47,8 @@ def AddSysPath(new_path):
4747
if __name__ == "__main__":
4848

4949
print("Before:")
50-
for x in sys.path:
51-
print(x)
50+
for item in sys.path:
51+
print(item)
5252

5353
if sys.platform == "win32":
5454
print(AddSysPath("c:\\Temp"))
@@ -57,5 +57,5 @@ def AddSysPath(new_path):
5757
print(AddSysPath("/usr/lib"))
5858

5959
print("After:")
60-
for x in sys.path:
61-
print(x)
60+
for item in sys.path:
61+
print(item)

0 commit comments

Comments
 (0)