diff --git a/scripts/UnitTests/CsprojParser/ValueProvider.py b/scripts/UnitTests/CsprojParser/ValueProvider.py new file mode 100644 index 0000000..646266d --- /dev/null +++ b/scripts/UnitTests/CsprojParser/ValueProvider.py @@ -0,0 +1,3 @@ +class ValueProvider: + def getValueFor(self, link): + return link diff --git a/scripts/UnitTests/CsprojParser/test_csprojLineParser.py b/scripts/UnitTests/CsprojParser/test_csprojLineParser.py index 4e8ea65..97b65cc 100644 --- a/scripts/UnitTests/CsprojParser/test_csprojLineParser.py +++ b/scripts/UnitTests/CsprojParser/test_csprojLineParser.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- import unittest +from UnitTests.CsprojParser.ValueProvider import ValueProvider from parser.CsprojParser.CsprojLineParser import CsprojLineParser class TestCsprojParser(unittest.TestCase): def setUp(self): - self.parser = CsprojLineParser() + value_provider = ValueProvider() + self.parser = CsprojLineParser(value_provider) def test_parseAppStatement(self): statement = "app:SomeAppName" diff --git a/scripts/UnitTests/CsprojParser/test_csprojParser.py b/scripts/UnitTests/CsprojParser/test_csprojParser.py index a8a6de9..8fa6806 100644 --- a/scripts/UnitTests/CsprojParser/test_csprojParser.py +++ b/scripts/UnitTests/CsprojParser/test_csprojParser.py @@ -1,4 +1,5 @@ import unittest +from UnitTests.CsprojParser.ValueProvider import ValueProvider from parser.CsprojParser.CsprojParser import CsprojParser @@ -15,9 +16,10 @@ class TestCase(unittest.TestCase): "csproj app:second attr1 'attr_val1'", "csproj app:second attr2 'attr_val2'"] self.__parser = None + self.__value_provider = ValueProvider() def __do_parse(self): - self.__parser = CsprojParser(self.__lineCollection) + self.__parser = CsprojParser(self.__lineCollection, self.__value_provider) self.__parser.parse() def test_projectCount(self): diff --git a/scripts/parser/CsprojParser/CsprojLineParser.py b/scripts/parser/CsprojParser/CsprojLineParser.py index 2237070..f50d7c3 100644 --- a/scripts/parser/CsprojParser/CsprojLineParser.py +++ b/scripts/parser/CsprojParser/CsprojLineParser.py @@ -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 = "^(?Pcsproj)" @@ -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 diff --git a/scripts/parser/CsprojParser/CsprojParser.py b/scripts/parser/CsprojParser/CsprojParser.py index d6c238a..25e54bd 100644 --- a/scripts/parser/CsprojParser/CsprojParser.py +++ b/scripts/parser/CsprojParser/CsprojParser.py @@ -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 \ No newline at end of file