Начал реализацию парсера настройки.

This commit is contained in:
rzaitov 2013-10-31 16:14:35 +04:00
parent 67185a9915
commit 76cd40e262
3 changed files with 32 additions and 0 deletions

View File

@ -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<prop_path>[\w.]+)"
valueRegexp = "'(?P<value>.*)'"
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)

View File

@ -0,0 +1,4 @@
class SettingsParser:
def __init__(self, content):
assert content is not None
pass

View File

@ -0,0 +1 @@
__author__ = 'rzaitov'