From 76cd40e26282e7b26559dfda5ae552bcf1fbf8c5 Mon Sep 17 00:00:00 2001 From: rzaitov Date: Thu, 31 Oct 2013 16:14:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8E=20=D0=BF=D0=B0?= =?UTF-8?q?=D1=80=D1=81=D0=B5=D1=80=D0=B0=20=D0=BD=D0=B0=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B9=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettingsParser/SettingsLineParser.py | 27 +++++++++++++++++++ .../parser/SettingsParser/SettingsParser.py | 4 +++ scripts/parser/SettingsParser/__init__.py | 1 + 3 files changed, 32 insertions(+) create mode 100644 scripts/parser/SettingsParser/SettingsLineParser.py create mode 100644 scripts/parser/SettingsParser/SettingsParser.py create mode 100644 scripts/parser/SettingsParser/__init__.py diff --git a/scripts/parser/SettingsParser/SettingsLineParser.py b/scripts/parser/SettingsParser/SettingsLineParser.py new file mode 100644 index 0000000..72909b6 --- /dev/null +++ b/scripts/parser/SettingsParser/SettingsLineParser.py @@ -0,0 +1,27 @@ +from parser.LineParser import LineParser +import re + +class SettingsLineParser(LineParser): + def parseLine(self, line): + assert line is not None + + pathAndValue = self.splitToPathAndValue(line) + propertyPath = pathAndValue[0] + value = [1] + + + def splitToPathAndValue(self, line): + + propPathRegexp = r"^(?P[\w.]+)" + valueRegexp = "'(?P.*)'" + + regexpSource = propPathRegexp + self.keywordToken('=') + valueRegexp + regexp = re.compile(regexpSource, re.UNICODE) + + match = regexp.match(line) + self._guardMatch(match, line, regexpSource) + + propPath = match.group('prop_path') + value = match.group('value') + + return (propPath, value) \ No newline at end of file diff --git a/scripts/parser/SettingsParser/SettingsParser.py b/scripts/parser/SettingsParser/SettingsParser.py new file mode 100644 index 0000000..559794e --- /dev/null +++ b/scripts/parser/SettingsParser/SettingsParser.py @@ -0,0 +1,4 @@ +class SettingsParser: + def __init__(self, content): + assert content is not None + pass diff --git a/scripts/parser/SettingsParser/__init__.py b/scripts/parser/SettingsParser/__init__.py new file mode 100644 index 0000000..cc31abc --- /dev/null +++ b/scripts/parser/SettingsParser/__init__.py @@ -0,0 +1 @@ +__author__ = 'rzaitov'