Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean autocoders code #1240

Merged
merged 10 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Autocoders/Python/bin/JSONDictionaryGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def pinit():


def main():

parser = pinit()
(opts, args) = parser.parse_args()

Expand All @@ -116,7 +115,7 @@ def main():
if not opts.build_root_overwrite is None:
set_build_roots(opts.build_root_overwrite)
else:
if ("BUILD_ROOT" in os.environ.keys()) == False:
if ("BUILD_ROOT" in os.environ.keys()) is False:
print("ERROR: Build root not set to root build path...")
sys.exit(-1)
set_build_roots(os.environ["BUILD_ROOT"])
Expand Down Expand Up @@ -305,19 +304,19 @@ def main():

# Prepend instance name to commands, events, and channels with duplicate component types
# PRINT.info(json.dumps(instanceIDs, indent=4))
for telemetryType, idDict in list(instanceIDs.items()):
for name, ids in list(idDict.items()):
for telemetry_type, id_dict in list(instanceIDs.items()):
for name, ids in list(id_dict.items()):
if len(ids) > 1:
for id in ids:
telem = dictionary[deployment][telemetryType][id]
telem = dictionary[deployment][telemetry_type][id]
name = telem["name"]
instanceName = telem["instance"]
name = "_".join([instanceName, name])
instance_name = telem["instance"]
name = "_".join([instance_name, name])
telem["name"] = name

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

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

# Write JSON to file
outFile = open(outFilepath, "w")
outFile.write(jsonStr)
outFile.write(json_str)
descriptionFile = open(descriptionFilename, "w")
descriptionFile.write(outFilepath)
PRINT.info("\nJSON output written to %s" % outFilepath)
Expand Down
16 changes: 8 additions & 8 deletions Autocoders/Python/src/fprime_ac/utils/AddSysPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def AddSysPath(new_path):
new_path = new_path.lower()

# Check against all currently available paths
for x in sys.path:
x = os.path.abspath(x)
for item in sys.path:
item = os.path.abspath(item)

if sys.platform == "win32":
x = x.lower()
item = item.lower()

if new_path in (x, x + os.sep):
if new_path in (item, item + os.sep):
return 0

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

print("Before:")
for x in sys.path:
print(x)
for item in sys.path:
print(item)

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

print("After:")
for x in sys.path:
print(x)
for item in sys.path:
print(item)