From 7f93a91931f167afbee65f04f585e10c9b924933 Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Sat, 23 Jan 2021 01:14:06 -0600 Subject: [PATCH] Initial properties parser --- backup_parser.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/backup_parser.py b/backup_parser.py index f24d87e..99b89a2 100644 --- a/backup_parser.py +++ b/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^[^=]+)=(?P.*)") + 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