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

better parsing to avoid bugs when variables name contain whitespaces #529

Merged
merged 16 commits into from
Jul 25, 2024
Merged
8 changes: 7 additions & 1 deletion snap7/util/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ def parse_specification(db_specification: str) -> Dict[str, Any]:

for line in db_specification.split("\n"):
if line and not line.lstrip().startswith("#"):
index, var_name, _type = line.lstrip().split("#")[0].split()
parsed_text = line.lstrip().split("#")[0].split()
Novecento99 marked this conversation as resolved.
Show resolved Hide resolved

index = parsed_text[0]
_type = parsed_text[-1]
var_name_list = parsed_text[1:-1]
var_name = ''.join(var_name_list)

parsed_db_specification[var_name] = (index, _type)

return parsed_db_specification
Expand Down
Loading