Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
meltingrabbit committed Jul 16, 2024
1 parent 84a4af6 commit 646ba6e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
23 changes: 20 additions & 3 deletions code-generator/my_mod/tlm_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ def GenerateTlmDef(settings, tlm_db):

# tlm field のバリデーション
if not my_mod.util.ValidateTlmField(name):
print("Error: Tlm Field must match `[A-Z_][0-9A-Z_]*` at " + name + " in " + tlm["tlm_name"].upper() + ".", file=sys.stderr)
print(
"Error: Tlm Field must match `[A-Z_][0-9A-Z_]*` at "
+ name
+ " in "
+ tlm["tlm_name"].upper()
+ ".",
file=sys.stderr,
)
sys.exit(1)

pos = int(pos)
Expand Down Expand Up @@ -95,10 +102,20 @@ def GenerateTlmDef(settings, tlm_db):
func_code += "TF_copy_double"
max_pos = pos + 8
elif var_type == "raw":
print("Error: Var. Type `raw` of " + name + " is forbidden in Telemetry Generator at " + tlm["tlm_name"].upper() + ".", file=sys.stderr)
print(
"Error: Var. Type `raw` of "
+ name
+ " is forbidden in Telemetry Generator at "
+ tlm["tlm_name"].upper()
+ ".",
file=sys.stderr,
)
sys.exit(1)
else:
print("Error: Tlm DB Err at " + name + " in " + tlm["tlm_name"].upper() + ".", file=sys.stderr)
print(
"Error: Tlm DB Err at " + name + " in " + tlm["tlm_name"].upper() + ".",
file=sys.stderr,
)
sys.exit(1)
func_code += "(&packet[" + str(pos) + "], " + code + ");\n"

Expand Down
4 changes: 2 additions & 2 deletions code-generator/my_mod/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@


def ValidateTlmField(name):
pattern = re.compile(r'[A-Z_][0-9A-Z_]*')
parts = name.split('.')
pattern = re.compile(r"[A-Z_][0-9A-Z_]*")
parts = name.split(".")
return all(pattern.fullmatch(part) for part in parts)


Expand Down

0 comments on commit 646ba6e

Please sign in to comment.