Skip to content

Commit f1045f5

Browse files
committed
Final cleanups
1 parent 2299504 commit f1045f5

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

nemoguardrails/colang/v1_0/lang/comd_parser.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -360,22 +360,24 @@ def parse_md_file(file_name, content=None):
360360
continue
361361

362362
# Make sure we have the type of the symbol in the name of the symbol
363-
if sym is not None:
364-
sym = _get_typed_symbol_name(sym, symbol_type)
363+
if not sym or not isinstance(sym, str):
364+
raise ValueError(f"sym must be a non-empty string, found {sym}")
365+
366+
sym = _get_typed_symbol_name(sym, symbol_type)
365367

366-
# For objects, we translate the "string" type to "kb:Object:prop|partial"
367-
param_type = _get_param_type(parts[1])
368-
if symbol_type == "object" and param_type in ["string", "text"]:
369-
object_name = split_max(sym, ":", 1)[1]
370-
param_type = f"kb:{object_name}:{parts[0]}|partial"
368+
# For objects, we translate the "string" type to "kb:Object:prop|partial"
369+
param_type = _get_param_type(parts[1])
370+
if symbol_type == "object" and param_type in ["string", "text"]:
371+
object_name = split_max(sym, ":", 1)[1]
372+
param_type = f"kb:{object_name}:{parts[0]}|partial"
371373

372-
# TODO: figure out a cleaner way to deal with this
373-
# For the "type:time" type, we transform it into "lookup:time"
374-
if param_type == "type:time":
375-
param_type = "lookup:time"
374+
# TODO: figure out a cleaner way to deal with this
375+
# For the "type:time" type, we transform it into "lookup:time"
376+
if param_type == "type:time":
377+
param_type = "lookup:time"
376378

377-
result["mappings"].append((f"{sym}:{parts[0]}", param_type))
378-
symbol_params.append(parts[0])
379+
result["mappings"].append((f"{sym}:{parts[0]}", param_type))
380+
symbol_params.append(parts[0])
379381

380382
elif line.startswith("-") or line.startswith("*"):
381383
if sym is None:

0 commit comments

Comments
 (0)