cmakelists_parsing
cmakelists_parsing copied to clipboard
AttributeError: 'Command' object has no attribute 'comments'
Example run:
import cmakelists_parsing.parsing as cmp
cmp.parse("""include_directories(
# aa
include
)""")
Result:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python3.8/site-packages/cmakelists_parsing/parsing.py", line 50, in parse
nums_items = list(parse_file(nums_toks))
File "/home/user/.local/lib/python3.8/site-packages/cmakelists_parsing/parsing.py", line 107, in parse_file
line_nums, cmd = parse_command(line_num, tok_contents, toks)
File "/home/user/.local/lib/python3.8/site-packages/cmakelists_parsing/parsing.py", line 142, in parse_command
cmd.comments.append(c)
AttributeError: 'Command' object has no attribute 'comments'
Parser is misusing its own API: Command-objects have attribute comment
not comments
.
I met the same issue.
Just wanted to add that I am getting the same error.
Furthermore, if you change comments
to comment
then now the error becomes:
File "/home/<redacted>/git_clones/ros2-support/scripts/catkin-to-ament.py", line 235, in port
cmake = cmkp.parse(content)
File "/home/<redacted>/.local/lib/python3.8/site-packages/parse_cmake/parsing.py", line 104, in parse
nums_items = list(parse_file(nums_toks))
File "/home/<redacted>/.local/lib/python3.8/site-packages/parse_cmake/parsing.py", line 212, in parse_file
line_nums, cmd = parse_command(line_num, tok_contents, toks)
File "/home/<redacted>/.local/lib/python3.8/site-packages/parse_cmake/parsing.py", line 252, in parse_command
cmd.comment.append(c)
AttributeError: 'NoneType' object has no attribute 'append'
Okay. To correct the issue:
L127 in parsing.py
cmd = Command(name=command_name, body=[], comment=[])
L142 in parsing.py
cmd.comment.append(c)