Browse Source

Initial properties parser

master
Raphael Roberts 5 years ago
parent
commit
7f93a91931
  1. 21
      backup_parser.py

21
backup_parser.py

@ -1,7 +1,14 @@
# Eample cases
# var=value
# var2=value
# valuevalues
# values
# Value
# var3=
import re
def parse_property_text(text):
properties = dict()
key_value_regex = re.compile(r"(?P<key>^[^=]+)=(?P<value>.*)")
lines = text.split("\n")
for line in lines:
match = key_value_regex.match(line)
if match:
key = match.group("key")
value = match.group("value")
properties[key] = value
return properties
Loading…
Cancel
Save