Для работы с таблицей символов внедрена зависимость valueProvider

This commit is contained in:
Rustam Zaitov
2013-10-07 01:30:48 +04:00
parent 0cc17356c3
commit 1a020db817
5 changed files with 24 additions and 8 deletions
@@ -3,6 +3,11 @@ from parser.CsprojParser.CsprojSetting.KeyValueSetting import KeyValueSetting
import re
class CsprojLineParser:
def __init__(self, value_provider):
assert value_provider is not None
self._value_provider = value_provider
def parse(self, line):
ws = ' '
csproj_regexp = "^(?P<cmd_name>csproj)"
@@ -56,7 +61,8 @@ class CsprojLineParser:
self.__guardMatch(match, statement)
key = match.group('key')
value = match.group('value')
value_link = match.group('value')
value = self._value_provider.getValueFor(value_link)
setting = KeyValueSetting(key, value)
return setting
@@ -69,7 +75,8 @@ class CsprojLineParser:
self.__guardMatch(match, statement)
attribute_name = match.group('attribute_name')
attribute_value = match.group('attribute_value')
value_link = match.group('attribute_value')
attribute_value = self._value_provider.getValueFor(value_link)
setting = AttributeSetting(attribute_name, attribute_value)
return setting
+6 -4
View File
@@ -3,16 +3,18 @@ from parser.CsprojParser.CsprojLineParser import CsprojLineParser
class CsprojParser:
def __init__(self, line_collection):
def __init__(self, line_collection, value_provider):
assert line_collection is not None
assert value_provider is not None
self.line_collection = line_collection
self._line_collection = line_collection
self._value_provider = value_provider
self.projects_dict = {}
def parse(self):
settings = []
for line in self.line_collection:
for line in self._line_collection:
settings.append(self.__parse_line(line))
for s in settings:
@@ -28,7 +30,7 @@ class CsprojParser:
return csproj
def __parse_line(self, line):
line_parser = CsprojLineParser()
line_parser = CsprojLineParser(self._value_provider)
setting = line_parser.parse(line)
return setting