модифицировал класс PatchCsproj чтобы он работал с csproj парсером
This commit is contained in:
parent
1a020db817
commit
3becc5945e
|
|
@ -15,4 +15,4 @@ base_dir = '/Users/rzaitov/Documents/Apps/BuildScript'
|
||||||
provider = path_provider.PathProvider(base_dir)
|
provider = path_provider.PathProvider(base_dir)
|
||||||
|
|
||||||
patcher = csproj.PatchCsproj(config, provider)
|
patcher = csproj.PatchCsproj(config, provider)
|
||||||
patcher.Execute()
|
patcher.execute()
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,4 @@ base_dir = '/Users/rzaitov/Documents/Apps/BuildScript',
|
||||||
provider = path_provider.PathProvider(base_dir)
|
provider = path_provider.PathProvider(base_dir)
|
||||||
|
|
||||||
patcher = plist.PatchInfoPlist(config, provider)
|
patcher = plist.PatchInfoPlist(config, provider)
|
||||||
patcher.Execute()
|
patcher.execute()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
__author__ = 'rzaitov'
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import unittest
|
||||||
|
from commands.ValueProvider import ValueProvider
|
||||||
|
|
||||||
|
|
||||||
|
class TestCase(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.__config = {
|
||||||
|
'key1': 'value1',
|
||||||
|
'key2': 'value2'
|
||||||
|
}
|
||||||
|
self.__provider = ValueProvider(self.__config)
|
||||||
|
|
||||||
|
def test_provideByLink(self):
|
||||||
|
value1 = self.__provider.getValueFor('@key1')
|
||||||
|
value2 = self.__provider.getValueFor('@key2')
|
||||||
|
|
||||||
|
self.assertEqual(value1, 'value1')
|
||||||
|
self.assertEqual(value2, 'value2')
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
class ValueProvider:
|
||||||
|
def __init__(self, config):
|
||||||
|
assert config is not None
|
||||||
|
|
||||||
|
self.__config = config
|
||||||
|
|
||||||
|
def getValueFor(self, link):
|
||||||
|
is_link = link.startswith('@')
|
||||||
|
result = link
|
||||||
|
|
||||||
|
if is_link:
|
||||||
|
key = link[1:]
|
||||||
|
result = self.__config[key]
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
@ -15,7 +15,7 @@ class BuildCommand:
|
||||||
self.SetCommandPrefix(cmd_prefix)
|
self.SetCommandPrefix(cmd_prefix)
|
||||||
|
|
||||||
|
|
||||||
def ParseConfig(self):
|
def _parseConfig(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -40,5 +40,5 @@ class BuildCommand:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def Execute(self):
|
def execute(self):
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,45 @@
|
||||||
import commands.build_command as bcmd
|
import commands.build_command as bcmd
|
||||||
|
from parser.CsprojParser.CsprojParser import CsprojParser
|
||||||
import utils.csproj.patcher as csproj
|
import utils.csproj.patcher as csproj
|
||||||
import parser.CsprojParser.CsprojLineParser as parser
|
|
||||||
|
|
||||||
class PatchCsproj(bcmd.BuildCommand):
|
class PatchCsproj(bcmd.BuildCommand):
|
||||||
def __init__(self, config, path_provider):
|
def __init__(self, config, path_provider, value_provider):
|
||||||
|
assert path_provider is not None
|
||||||
|
assert value_provider is not None
|
||||||
|
|
||||||
bcmd.BuildCommand.__init__(self, config, 'csproj')
|
bcmd.BuildCommand.__init__(self, config, 'csproj')
|
||||||
self._path_provider = path_provider
|
self._path_provider = path_provider
|
||||||
|
self._value_provider = value_provider
|
||||||
self._parser = None
|
self._parser = None
|
||||||
|
|
||||||
self.ParseConfig()
|
self._parseConfig()
|
||||||
|
|
||||||
def ParseConfig(self):
|
def _parseConfig(self):
|
||||||
csproj_keys = self.FetchAllKeysFromConfig()
|
csproj_keys = self.FetchAllKeysFromConfig()
|
||||||
self.FillPatchSettings(csproj_keys)
|
line_collection = self.__fetchLineCollection(csproj_keys)
|
||||||
|
|
||||||
|
self.__fillPatchSettings(line_collection)
|
||||||
|
|
||||||
def FillPatchSettings(self, key_tokens):
|
def __fetchLineCollection(self, keys):
|
||||||
self._parser = parser.CsprojLineParser(self._config)
|
assert keys is not None
|
||||||
|
|
||||||
for key_token in key_tokens:
|
line_collection = ["{0} '{1}'".format(k, self._config[k]) for k in keys]
|
||||||
self._parser.parse(key_token, self._config[key_token])
|
return line_collection
|
||||||
|
|
||||||
|
def __fillPatchSettings(self, line_collection):
|
||||||
|
assert line_collection is not None
|
||||||
|
|
||||||
def Execute(self):
|
self._parser = CsprojParser(line_collection, self._value_provider)
|
||||||
projects_list = self._parser.getProjects()
|
self._parser.parse()
|
||||||
|
|
||||||
for project in projects_list:
|
def execute(self):
|
||||||
self.PatchProject(project)
|
projects = self._parser.projects_dict.values()
|
||||||
|
|
||||||
def PatchProject(self, project):
|
for project in projects:
|
||||||
|
self.__patchProject(project)
|
||||||
|
|
||||||
|
def __patchProject(self, project):
|
||||||
csproj_abs_path = self._path_provider.resolveAbsPath(project.rel_path)
|
csproj_abs_path = self._path_provider.resolveAbsPath(project.rel_path)
|
||||||
|
|
||||||
patcher = csproj.Patcher(csproj_abs_path)
|
patcher = csproj.Patcher(csproj_abs_path)
|
||||||
patcher.AddOrReplace(project.settings, self._config['sln_config'])
|
patcher.AddOrReplace(project.settings, self._config['sln_config'])
|
||||||
|
|
@ -10,9 +10,9 @@ class PatchInfoPlist(bcmd.BuildCommand):
|
||||||
self._path_provider = path_provider
|
self._path_provider = path_provider
|
||||||
self._plist_dict = {}
|
self._plist_dict = {}
|
||||||
|
|
||||||
self.ParseConfig()
|
self._parseConfig()
|
||||||
|
|
||||||
def ParseConfig(self):
|
def _parseConfig(self):
|
||||||
self.FetchInfoPlistPath()
|
self.FetchInfoPlistPath()
|
||||||
self.FetchAllParams()
|
self.FetchAllParams()
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ class PatchInfoPlist(bcmd.BuildCommand):
|
||||||
def ParsePlistKeyFrom(self, config_key):
|
def ParsePlistKeyFrom(self, config_key):
|
||||||
return config_key[PatchInfoPlist._cmd_prefix_len:]
|
return config_key[PatchInfoPlist._cmd_prefix_len:]
|
||||||
|
|
||||||
def Execute(self):
|
def execute(self):
|
||||||
info_plist_abs_path = self._path_provider.resolveAbsPath(self._info_plist_rel_path)
|
info_plist_abs_path = self._path_provider.resolveAbsPath(self._info_plist_rel_path)
|
||||||
patcher = plist.Patcher(info_plist_abs_path)
|
patcher = plist.Patcher(info_plist_abs_path)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,5 @@ class PublishToTestFlightCommand(bcmd.BuildCommand):
|
||||||
def __init__(self, api_token, team_token, notes):
|
def __init__(self, api_token, team_token, notes):
|
||||||
self._publisher = tf.TestFlightPublisherBase(api_token, team_token, notes)
|
self._publisher = tf.TestFlightPublisherBase(api_token, team_token, notes)
|
||||||
|
|
||||||
def Execute(self):
|
def execute(self):
|
||||||
self._publisher.Publish()
|
self._publisher.Publish()
|
||||||
Loading…
Reference in New Issue