Skip to content
Snippets Groups Projects
Commit eb6e6bea authored by Christian Kento Rasmussen's avatar Christian Kento Rasmussen
Browse files

Add indentation logic for object and section start

parent ed318a75
No related branches found
No related tags found
2 merge requests!45Save files function,!44Load vol files
......@@ -306,6 +306,7 @@ class DataLoader:
with open(path, 'r') as f:
for line in f:
line = line.strip()
# {NAME} is start of a new object, so should indent
if line.startswith('{') and line.endswith('}'):
section_name = line[1:-1]
current_section[section_name] = {}
......@@ -313,6 +314,7 @@ class DataLoader:
current_section = current_section[section_name]
should_indent = True
# [NAME] is start of a section, so should not indent
elif line.startswith('[') and line.endswith(']'):
section_name = line[1:-1]
......@@ -325,6 +327,7 @@ class DataLoader:
current_section = current_section[section_name]
should_indent = False
# = is a key value pair
elif '=' in line:
key, value = line.split('=', 1)
current_section[key.strip()] = value.strip()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment