модифицировал построитель комманды для патчинга csproj файла
This commit is contained in:
parent
22d3abd817
commit
ced2f2f364
|
|
@ -1,26 +1,21 @@
|
|||
from commands.PatchCsprojCommand import PatchCsprojCommand
|
||||
from parsers.InsideParser.InsideSetParser import InsideSetParser
|
||||
from parsers.InsideParser.InsideCsprojSetParser import InsideCsprojSetParser
|
||||
|
||||
|
||||
class PatchCsprojCommandBuilder:
|
||||
def __init__(self, config, valueProvider):
|
||||
assert config is not None
|
||||
assert valueProvider is not None
|
||||
|
||||
self.__config = config
|
||||
self.__valueProvider = valueProvider
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def getCommandFor(self, line):
|
||||
assert line is not None
|
||||
|
||||
parser = InsideSetParser('csproj')
|
||||
parser = self.getParser()
|
||||
result = parser.parseLine(line)
|
||||
|
||||
csprojPath = result[0]
|
||||
key = result[1]
|
||||
value = self.__valueProvider.getValueFor(result[2])
|
||||
|
||||
slnConfig = self.__config['sln_config']
|
||||
value = result[2]
|
||||
slnConfig = result[3]
|
||||
|
||||
command = PatchCsprojCommand(csprojPath, key, value, slnConfig)
|
||||
return command
|
||||
|
|
@ -28,8 +23,10 @@ class PatchCsprojCommandBuilder:
|
|||
def isPatchCsproj(self, line):
|
||||
assert line is not None
|
||||
|
||||
parser = InsideSetParser('csproj')
|
||||
parser = self.getParser()
|
||||
isValid = parser.isValidLine(line)
|
||||
|
||||
return isValid
|
||||
|
||||
def getParser(self):
|
||||
return InsideCsprojSetParser('csproj')
|
||||
|
|
@ -27,7 +27,7 @@ class StepsRunner:
|
|||
self.restoreFromBackupBuilder = RestoreBackupCommandBuilder()
|
||||
self.deleteBackupBuilder = DeleteBackupCommandBuilder()
|
||||
self.createDirs = MakeDirsCommandBuilder()
|
||||
self.patchCsproj = PatchCsprojCommandBuilder(config, self.valueProvider)
|
||||
self.patchCsproj = PatchCsprojCommandBuilder()
|
||||
self.patchInfoPlist = PatchInfoplistCommandBuilder(self.valueProvider)
|
||||
self.copyBuilder = CopyCommandBuilder()
|
||||
self.testflightBuilder = TestflightCommandBuilder()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from CommandBuilders.PatchCsprojCommandBuilder import PatchCsprojCommandBuilder
|
||||
from commands.ValueProvider import ValueProvider
|
||||
|
||||
config = {'sln_config' : 'Release|iPhone'}
|
||||
line = "inside 'BuildSample/BuildSample/CoolApp.csproj' set OutputPath to 'Output'"
|
||||
line = "inside 'BuildSample/BuildSample/CoolApp.csproj' set OutputPath to 'Output' for 'Release|iPhone'"
|
||||
|
||||
value_provider = ValueProvider(config)
|
||||
|
||||
builder = PatchCsprojCommandBuilder(config, value_provider)
|
||||
builder = PatchCsprojCommandBuilder()
|
||||
command = builder.getCommandFor(line)
|
||||
command.execute()
|
||||
|
|
@ -1,17 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
from commands.ValueProvider import ValueProvider
|
||||
from parsers.InsideParser.InsideSetParser import InsideSetParser
|
||||
from parsers.InsideParser.InsideCsprojSetParser import InsideCsprojSetParser
|
||||
|
||||
|
||||
class TestCsprojParser(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.parser = InsideSetParser('csproj')
|
||||
self.parser = InsideCsprojSetParser('csproj')
|
||||
|
||||
|
||||
def test_isValid(self):
|
||||
line = "inside 'CoolApp.csproj' set KEY to 'VALUE'"
|
||||
line = "inside 'CoolApp.csproj' set KEY to 'VALUE' for 'Sln|Config'"
|
||||
isValid = self.parser.isValidLine(line)
|
||||
|
||||
self.assertEqual(True, isValid)
|
||||
|
|
@ -23,9 +22,10 @@ class TestCsprojParser(unittest.TestCase):
|
|||
self.assertEqual(False, isValid)
|
||||
|
||||
def test_parse(self):
|
||||
line = "inside 'Dir/../Some Folder/CoolApp.csproj' set OutputPath to 'Output'"
|
||||
line = "inside 'Dir/../Some Folder/CoolApp.csproj' set OutputPath to 'Output' for 'Release|iPhone'"
|
||||
result = self.parser.parseLine(line)
|
||||
|
||||
self.assertEqual('Dir/../Some Folder/CoolApp.csproj', result[0])
|
||||
self.assertEqual('OutputPath', result[1])
|
||||
self.assertEqual('Output', result[2])
|
||||
self.assertEqual('Output', result[2])
|
||||
self.assertEqual('Release|iPhone', result[3])
|
||||
|
|
@ -33,7 +33,7 @@ class InsideCsprojSetParser(LineParser):
|
|||
slnConfigRegexp = r"'(?P<config>[a-zA-Z|]+)'$"
|
||||
|
||||
regexpSource = self.startsWith('inside') + filePathRegexp + self.keywordToken('set') + keyRegexp + \
|
||||
self.keywordToken('to') + valueRegexp + self.than('for') + slnConfigRegexp
|
||||
self.keywordToken('to') + valueRegexp + self.keywordToken('for') + slnConfigRegexp
|
||||
regexp = re.compile(regexpSource, re.UNICODE)
|
||||
|
||||
match = regexp.match(line)
|
||||
|
|
|
|||
Loading…
Reference in New Issue