From e0e6ed61eb4281031e39f4b1f84678e080052089 Mon Sep 17 00:00:00 2001 From: rzaitov Date: Thu, 14 Nov 2013 14:33:05 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81?= =?UTF-8?q?=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D1=81=D0=B2=D1=8F=D0=B7?= =?UTF-8?q?=D0=B0=D0=BD=D0=BD=D1=83=D1=8E=20=D1=81=20=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B3=D1=83=D0=BB=D1=8F=D1=80=D0=BD=D1=8B=D1=85=20=D0=B2=D1=8B?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B8=D0=B7=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20LineParser=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20RegexpBuilder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InstallProfileCommandBuilder.py | 24 ++++++++++++--- .../InstallProfile/test_installProfile.py | 5 ++-- .../TouchinBuild/parsers/CleanBuildParser.py | 8 +++-- .../parsers/CopyParser/CopyLineParser.py | 4 ++- .../parsers/InstallProfileParser.py | 15 +--------- scripts/TouchinBuild/parsers/LineParser.py | 29 +++++-------------- .../TouchinBuild/parsers/MakeDirsParser.py | 4 ++- .../ParserBackup/CreateBackupParser.py | 4 ++- .../ParserBackup/DeleteBackupParser.py | 4 ++- .../ParserBackup/RestoreBackupParser.py | 4 ++- scripts/TouchinBuild/parsers/RegexpBuilder.py | 20 +++++++++++++ .../SettingsParser/SettingsLineParser.py | 5 ++++ scripts/TouchinBuild/parsers/ShParser.py | 4 ++- .../TouchinBuild/parsers/TestflightParser.py | 12 +++++--- .../TouchinBuild/utils/IncludeProcessor.py | 4 ++- 15 files changed, 89 insertions(+), 57 deletions(-) create mode 100644 scripts/TouchinBuild/parsers/RegexpBuilder.py diff --git a/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py index 1e9668b..4b31f80 100644 --- a/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py @@ -1,21 +1,37 @@ +import os from commands.CopyCommand import CopyCommand +from parsers.CopyParser.CopyArguments import CopyArguments from parsers.InstallProfileParser import InstallProfileParser class InstallProfileCommandBuilder: def __init__(self): - pass + self.profileStorageDir = '~/Library/MobileDevice/Provisioning Profiles/' def isInstallProfile(self, line): assert line is not None - return line.startswith('install profile') + parser = InstallProfileParser() + isValid = parser.isValidLine(line) + + return isValid def getCommandFor(self, line): assert line is not None - + parser = InstallProfileParser() - cpArgs = parser.parseLine(line) + + srcPath = parser.parseLine(line) + dstPath = self.getDestinationPath(srcPath) + + cpArgs = CopyArguments() + cpArgs.setArguments(srcPath, dstPath) command = CopyCommand(cpArgs) return command + + def getDestinationPath(self, sourcePath): + profileFileName = os.path.basename(sourcePath) + destination = os.path.join(self.profileStorageDir, profileFileName) + + return destination diff --git a/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfile.py b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfile.py index ba9313f..a6e9d82 100644 --- a/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfile.py +++ b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfile.py @@ -8,7 +8,6 @@ class TestInstallProfile(unittest.TestCase): def test_parse(self): line = "install profile 'Path/To/Profile.mobileprovision'" - copyArgs = self.parser.parseLine(line) + src = self.parser.parseLine(line) - self.assertEqual('Path/To/Profile.mobileprovision', copyArgs.source) - self.assertEqual('~/Library/MobileDevice/Provisioning Profiles/Profile.mobileprovision', copyArgs.target) \ No newline at end of file + self.assertEqual('Path/To/Profile.mobileprovision', src) diff --git a/scripts/TouchinBuild/parsers/CleanBuildParser.py b/scripts/TouchinBuild/parsers/CleanBuildParser.py index 2f7ed14..f65cf93 100644 --- a/scripts/TouchinBuild/parsers/CleanBuildParser.py +++ b/scripts/TouchinBuild/parsers/CleanBuildParser.py @@ -1,6 +1,7 @@ import re from parsers.LineParser import LineParser +from parsers.RegexpBuilder import RegexpBuilder class CleanBuildParser(LineParser): @@ -8,7 +9,7 @@ class CleanBuildParser(LineParser): LineParser.__init__(self) assert commandToken is not None - self.__commandToken = commandToken + self.commandToken = commandToken def parseLine(self, line): assert line is not None @@ -16,7 +17,8 @@ class CleanBuildParser(LineParser): filePathRegexp = r"'(?P[./ a-zA-Z]+\.sln)'" slnConfigRegexp = r"'(?P[a-zA-Z|]+)'$" - regexpSource = self.startsWith(self.__commandToken) + filePathRegexp + self.keywordToken('for') + slnConfigRegexp + rb = RegexpBuilder() + regexpSource = rb.startsWith(self.commandToken) + filePathRegexp + rb.keywordToken('for') + slnConfigRegexp regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) @@ -30,5 +32,5 @@ class CleanBuildParser(LineParser): def isValidLine(self, line): assert line is not None - isValid = line.startswith(self.__commandToken) + isValid = line.startswith(self.commandToken) return isValid diff --git a/scripts/TouchinBuild/parsers/CopyParser/CopyLineParser.py b/scripts/TouchinBuild/parsers/CopyParser/CopyLineParser.py index 9a99db9..8b865f5 100644 --- a/scripts/TouchinBuild/parsers/CopyParser/CopyLineParser.py +++ b/scripts/TouchinBuild/parsers/CopyParser/CopyLineParser.py @@ -2,6 +2,7 @@ import re from parsers.CopyParser.CopyArguments import CopyArguments from parsers.LineParser import LineParser +from parsers.RegexpBuilder import RegexpBuilder class CopyLineParser(LineParser): @@ -15,7 +16,8 @@ class CopyLineParser(LineParser): srcFileNameRegexp = r"'(?P[^']+)'" dstFileNameRegexp = r"'(?P[^']+)'$" - regexpSource = self.startsWith('copy') + srcFileNameRegexp + self.keywordToken('to') + dstFileNameRegexp + rb = RegexpBuilder() + regexpSource = rb.startsWith('copy') + srcFileNameRegexp + rb.keywordToken('to') + dstFileNameRegexp regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/InstallProfileParser.py b/scripts/TouchinBuild/parsers/InstallProfileParser.py index d70797c..c7e227c 100644 --- a/scripts/TouchinBuild/parsers/InstallProfileParser.py +++ b/scripts/TouchinBuild/parsers/InstallProfileParser.py @@ -1,14 +1,10 @@ import re -import os -from parsers.CopyParser.CopyArguments import CopyArguments from parsers.LineParser import LineParser class InstallProfileParser(LineParser): def __init__(self): LineParser.__init__(self) - self.__copyArguments = CopyArguments() - self.__profileStorageDir = '~/Library/MobileDevice/Provisioning Profiles/' def parseLine(self, line): assert line is not None @@ -22,13 +18,4 @@ class InstallProfileParser(LineParser): self._guardMatch(match, line, regexpSource) srcPath = match.group('path') - dstPath = self.getDestinationPath(srcPath) - - self.__copyArguments.setArguments(srcPath, dstPath) - return self.__copyArguments - - def getDestinationPath(self, sourcePath): - profileFileName = os.path.basename(sourcePath) - destination = os.path.join(self.__profileStorageDir, profileFileName) - - return destination \ No newline at end of file + return srcPath \ No newline at end of file diff --git a/scripts/TouchinBuild/parsers/LineParser.py b/scripts/TouchinBuild/parsers/LineParser.py index db0581e..8747007 100644 --- a/scripts/TouchinBuild/parsers/LineParser.py +++ b/scripts/TouchinBuild/parsers/LineParser.py @@ -1,35 +1,20 @@ +import abc + + class LineParser: + __metaclass__ = abc.ABCMeta + def __init__(self): pass + @abc.abstractmethod def parseLine(self, line): - assert line is not None pass + @abc.abstractmethod def isValidLine(self, line): - assert line is not None return False - def keywordToken(self, keyword): - assert keyword is not None - return r'\s+' + keyword + r'\s+' - - def startsWith(self, keyword): - assert keyword is not None - return r'^' + keyword + r'\s+' - - def spaceEndsWith(self, keyword): - assert keyword is not None - return r'\s+' + keyword + '$' - - def endsWith(self, keyword): - assert keyword is not None - return keyword + '$' - - def than(self, keyword): - assert keyword is not None - return keyword + r'\s+' - def _guardMatch(self, match_object, source, regexpSource = None): if match_object is None: msg = 'Recognition exception: "{0}" for "{1}"'.format(source, regexpSource) diff --git a/scripts/TouchinBuild/parsers/MakeDirsParser.py b/scripts/TouchinBuild/parsers/MakeDirsParser.py index 8345596..fa30ff9 100644 --- a/scripts/TouchinBuild/parsers/MakeDirsParser.py +++ b/scripts/TouchinBuild/parsers/MakeDirsParser.py @@ -1,6 +1,7 @@ import re from parsers.LineParser import LineParser +from parsers.RegexpBuilder import RegexpBuilder class MakeDirsParser(LineParser): @@ -10,7 +11,8 @@ class MakeDirsParser(LineParser): def parseLine(self, line): pathRegexp = r"'(?P[^']+)'$" - regexpSource = self.startsWith('create dirs') + pathRegexp + rb = RegexpBuilder() + regexpSource = rb.startsWith('create dirs') + pathRegexp regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupParser.py b/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupParser.py index de31ee3..774fede 100644 --- a/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupParser.py +++ b/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupParser.py @@ -1,6 +1,7 @@ import re from parsers.ParserBackup.ParserBackupBase import ParserBackupBase +from parsers.RegexpBuilder import RegexpBuilder class CreateBackupParser(ParserBackupBase): @@ -10,7 +11,8 @@ class CreateBackupParser(ParserBackupBase): def getMatchInfo(self, line): assert line is not None - regexpSource = self.startsWith('create') + self.endsWith('backup') + rb = RegexpBuilder() + regexpSource = rb.startsWith('create') + rb.endsWith('backup') regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/ParserBackup/DeleteBackupParser.py b/scripts/TouchinBuild/parsers/ParserBackup/DeleteBackupParser.py index 936f4ec..c6238c5 100644 --- a/scripts/TouchinBuild/parsers/ParserBackup/DeleteBackupParser.py +++ b/scripts/TouchinBuild/parsers/ParserBackup/DeleteBackupParser.py @@ -1,6 +1,7 @@ import re from parsers.ParserBackup.ParserBackupBase import ParserBackupBase +from parsers.RegexpBuilder import RegexpBuilder class DeleteBackupParser(ParserBackupBase): @@ -10,7 +11,8 @@ class DeleteBackupParser(ParserBackupBase): def getMatchInfo(self, line): assert line is not None - regexpSource = self.startsWith('delete') + self.endsWith('backup') + rb = RegexpBuilder() + regexpSource = rb.startsWith('delete') + rb.endsWith('backup') regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/ParserBackup/RestoreBackupParser.py b/scripts/TouchinBuild/parsers/ParserBackup/RestoreBackupParser.py index 3f1ca81..2f5ed4b 100644 --- a/scripts/TouchinBuild/parsers/ParserBackup/RestoreBackupParser.py +++ b/scripts/TouchinBuild/parsers/ParserBackup/RestoreBackupParser.py @@ -1,6 +1,7 @@ import re from parsers.ParserBackup.ParserBackupBase import ParserBackupBase +from parsers.RegexpBuilder import RegexpBuilder class RestoreBackupParser(ParserBackupBase): @@ -10,7 +11,8 @@ class RestoreBackupParser(ParserBackupBase): def getMatchInfo(self, line): assert line is not None - regexpSource = self.startsWith('restore') + self.than('from') + self.endsWith('backup') + rb = RegexpBuilder() + regexpSource = rb.startsWith('restore') + rb.than('from') + rb.endsWith('backup') regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/RegexpBuilder.py b/scripts/TouchinBuild/parsers/RegexpBuilder.py new file mode 100644 index 0000000..ffa28f4 --- /dev/null +++ b/scripts/TouchinBuild/parsers/RegexpBuilder.py @@ -0,0 +1,20 @@ +class RegexpBuilder: + def keywordToken(self, keyword): + assert keyword is not None + return r'\s+' + keyword + r'\s+' + + def startsWith(self, keyword): + assert keyword is not None + return r'^' + keyword + r'\s+' + + def spaceEndsWith(self, keyword): + assert keyword is not None + return r'\s+' + keyword + '$' + + def endsWith(self, keyword): + assert keyword is not None + return keyword + '$' + + def than(self, keyword): + assert keyword is not None + return keyword + r'\s+' \ No newline at end of file diff --git a/scripts/TouchinBuild/parsers/SettingsParser/SettingsLineParser.py b/scripts/TouchinBuild/parsers/SettingsParser/SettingsLineParser.py index 755d4be..425d9f4 100644 --- a/scripts/TouchinBuild/parsers/SettingsParser/SettingsLineParser.py +++ b/scripts/TouchinBuild/parsers/SettingsParser/SettingsLineParser.py @@ -26,6 +26,11 @@ class SettingsLineParser(LineParser): return result + def isValidLine(self, line): + assert line is not None + + return '=' in line + def splitToPathAndValue(self, line): # some.path = some_value result = line.split('=') diff --git a/scripts/TouchinBuild/parsers/ShParser.py b/scripts/TouchinBuild/parsers/ShParser.py index 6e39807..39f41e4 100644 --- a/scripts/TouchinBuild/parsers/ShParser.py +++ b/scripts/TouchinBuild/parsers/ShParser.py @@ -1,6 +1,7 @@ import re from parsers.LineParser import LineParser +from parsers.RegexpBuilder import RegexpBuilder class ShParser(LineParser): @@ -10,9 +11,10 @@ class ShParser(LineParser): def parseLine(self, line): assert line + rb = RegexpBuilder() cmdTextRegexp = r'(?P.*)' - regexpSource = self.startsWith('sh') + cmdTextRegexp + regexpSource = rb.startsWith('sh') + cmdTextRegexp regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/TestflightParser.py b/scripts/TouchinBuild/parsers/TestflightParser.py index b27f471..94caf65 100644 --- a/scripts/TouchinBuild/parsers/TestflightParser.py +++ b/scripts/TouchinBuild/parsers/TestflightParser.py @@ -1,5 +1,7 @@ from parsers.LineParser import LineParser import re +from parsers.RegexpBuilder import RegexpBuilder + class TestflightParser(LineParser): def __init__(self): @@ -8,15 +10,17 @@ class TestflightParser(LineParser): def parseLine(self, line): assert line is not None + rb = RegexpBuilder() + notesRegexp = r"'(?P[^']+)'" apiTokenRegexp = r"'(?P[^']+)'" teamTokenRegexp = r"'(?P[^']+)'" filePathRegexp = r"'(?P[^']+)'" - regexpSource = self.startsWith('publish') + filePathRegexp + self.keywordToken('to') + self.than('testflight') + \ - self.than('notes') + self.than('=') + notesRegexp + \ - self.keywordToken('api_token') + self.than('=') + apiTokenRegexp + \ - self.keywordToken('team_token') + self.than('=') + teamTokenRegexp + regexpSource = rb.startsWith('publish') + filePathRegexp + rb.keywordToken('to') + rb.than('testflight') + \ + rb.than('notes') + rb.than('=') + notesRegexp + \ + rb.keywordToken('api_token') + rb.than('=') + apiTokenRegexp + \ + rb.keywordToken('team_token') + rb.than('=') + teamTokenRegexp regexp = re.compile(regexpSource, re.UNICODE) diff --git a/scripts/TouchinBuild/utils/IncludeProcessor.py b/scripts/TouchinBuild/utils/IncludeProcessor.py index c0fa623..4f16fc9 100644 --- a/scripts/TouchinBuild/utils/IncludeProcessor.py +++ b/scripts/TouchinBuild/utils/IncludeProcessor.py @@ -1,5 +1,6 @@ import re from parsers.LineParser import LineParser +from parsers.RegexpBuilder import RegexpBuilder class IncludeProcessor(LineParser): @@ -9,7 +10,8 @@ class IncludeProcessor(LineParser): def getIncludesInfo(self, text): assert text is not None - regexpSource = '<\s*' + self.than('include') + r"'[^']+'" + '\s*>' + rb = RegexpBuilder() + regexpSource = '<\s*' + rb.than('include') + r"'[^']+'" + '\s*>' regexp = re.compile(regexpSource, re.UNICODE) results = regexp.findall(text) From 7c11a708f0d0552db18d59ee445fb3e413f2ff30 Mon Sep 17 00:00:00 2001 From: rzaitov Date: Thu, 14 Nov 2013 14:42:41 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=9F=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=82=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../parsers/InsideParser/InsideCsprojSetParser.py | 6 ++++-- .../parsers/InsideParser/InsideParserBase.py | 4 +--- .../parsers/InsideParser/InsideSetArrayParser.py | 6 ++++-- .../TouchinBuild/parsers/InstallProfileParser.py | 15 +++++++++++++-- scripts/TouchinBuild/utils/IncludeProcessor.py | 4 ++-- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/scripts/TouchinBuild/parsers/InsideParser/InsideCsprojSetParser.py b/scripts/TouchinBuild/parsers/InsideParser/InsideCsprojSetParser.py index 095e557..08c2b47 100644 --- a/scripts/TouchinBuild/parsers/InsideParser/InsideCsprojSetParser.py +++ b/scripts/TouchinBuild/parsers/InsideParser/InsideCsprojSetParser.py @@ -1,5 +1,6 @@ import re from parsers.InsideParser.InsideParserBase import InsideParserBase +from parsers.RegexpBuilder import RegexpBuilder class InsideCsprojSetParser(InsideParserBase): @@ -23,8 +24,9 @@ class InsideCsprojSetParser(InsideParserBase): valueRegexp = r"'(?P[^']+)'" slnConfigRegexp = r"'(?P[a-zA-Z|]*)'$" - regexpSource = self.startsWith('inside') + self.filePathRegexp + self.keywordToken('set') + keyRegexp + \ - self.keywordToken('to') + valueRegexp + self.keywordToken('for') + slnConfigRegexp + rb = RegexpBuilder() + regexpSource = rb.startsWith('inside') + self.filePathRegexp + rb.keywordToken('set') + keyRegexp + \ + rb.keywordToken('to') + valueRegexp + rb.keywordToken('for') + slnConfigRegexp regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/InsideParser/InsideParserBase.py b/scripts/TouchinBuild/parsers/InsideParser/InsideParserBase.py index 9515110..fe138ea 100644 --- a/scripts/TouchinBuild/parsers/InsideParser/InsideParserBase.py +++ b/scripts/TouchinBuild/parsers/InsideParser/InsideParserBase.py @@ -2,9 +2,7 @@ import abc from parsers.LineParser import LineParser -class InsideParserBase(object, LineParser): - __metaclass__ = abc.ABCMeta - +class InsideParserBase(LineParser): def __init__(self, fileExt): LineParser.__init__(self) diff --git a/scripts/TouchinBuild/parsers/InsideParser/InsideSetArrayParser.py b/scripts/TouchinBuild/parsers/InsideParser/InsideSetArrayParser.py index d0de972..e133719 100644 --- a/scripts/TouchinBuild/parsers/InsideParser/InsideSetArrayParser.py +++ b/scripts/TouchinBuild/parsers/InsideParser/InsideSetArrayParser.py @@ -1,5 +1,6 @@ import re from parsers.InsideParser.InsideParserBase import InsideParserBase +from parsers.RegexpBuilder import RegexpBuilder class InsideSetArrayParser(InsideParserBase): @@ -25,8 +26,9 @@ class InsideSetArrayParser(InsideParserBase): keyRegexp = r'(?P[a-zA-Z]+)' valueRegexp = r"'(?P[^']+)'$" - regexpSource = self.startsWith('inside') + self.filePathRegexp + self.keywordToken('set') + keyRegexp + \ - self.keywordToken('with') + self.than('values') + valueRegexp + rb = RegexpBuilder() + regexpSource = rb.startsWith('inside') + self.filePathRegexp + rb.keywordToken('set') + keyRegexp + \ + rb.keywordToken('with') + rb.than('values') + valueRegexp regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/InstallProfileParser.py b/scripts/TouchinBuild/parsers/InstallProfileParser.py index c7e227c..85c8b89 100644 --- a/scripts/TouchinBuild/parsers/InstallProfileParser.py +++ b/scripts/TouchinBuild/parsers/InstallProfileParser.py @@ -1,5 +1,6 @@ import re from parsers.LineParser import LineParser +from parsers.RegexpBuilder import RegexpBuilder class InstallProfileParser(LineParser): @@ -9,8 +10,9 @@ class InstallProfileParser(LineParser): def parseLine(self, line): assert line is not None + rb = RegexpBuilder() profilePathRegexp = r"'(?P[^']+)'$" - regexpSource = self.startsWith('install') + self.than('profile') + profilePathRegexp + regexpSource = rb.startsWith('install') + rb.than('profile') + profilePathRegexp regexp = re.compile(regexpSource, re.UNICODE) @@ -18,4 +20,13 @@ class InstallProfileParser(LineParser): self._guardMatch(match, line, regexpSource) srcPath = match.group('path') - return srcPath \ No newline at end of file + return srcPath + + def isValidLine(self, line): + rb = RegexpBuilder() + + regexpSource = rb.startsWith('install') + rb.than('profile') + regexp = re.compile(regexpSource, re.UNICODE) + + match = regexp.match(line) + return match is not None diff --git a/scripts/TouchinBuild/utils/IncludeProcessor.py b/scripts/TouchinBuild/utils/IncludeProcessor.py index 4f16fc9..8357997 100644 --- a/scripts/TouchinBuild/utils/IncludeProcessor.py +++ b/scripts/TouchinBuild/utils/IncludeProcessor.py @@ -3,9 +3,9 @@ from parsers.LineParser import LineParser from parsers.RegexpBuilder import RegexpBuilder -class IncludeProcessor(LineParser): +class IncludeProcessor: def __init__(self): - LineParser.__init__(self) + pass def getIncludesInfo(self, text): assert text is not None From 826140a7ebe610a128258838e72b74a0046b1a08 Mon Sep 17 00:00:00 2001 From: rzaitov Date: Thu, 14 Nov 2013 14:55:17 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=BF=D1=80=D0=BE=D1=84?= =?UTF-8?q?=D0=B8=D0=BB=D1=8F=20=D0=BF=D1=80=D0=B8=20=D1=83=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InstallProfileCommandBuilder.py | 17 +++++++++++++---- .../test_installProfileBuilder.py | 16 ++++++++++++++++ ...lProfile.py => test_installProfileParser.py} | 0 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py rename scripts/TouchinBuild/Tests/UnitTests/InstallProfile/{test_installProfile.py => test_installProfileParser.py} (100%) diff --git a/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py index 4b31f80..535f44a 100644 --- a/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py @@ -5,7 +5,10 @@ from parsers.InstallProfileParser import InstallProfileParser class InstallProfileCommandBuilder: - def __init__(self): + def __init__(self, profileFilePrefix): + assert profileFilePrefix is not None + + self.profileFilePrefix = profileFilePrefix self.profileStorageDir = '~/Library/MobileDevice/Provisioning Profiles/' def isInstallProfile(self, line): @@ -31,7 +34,13 @@ class InstallProfileCommandBuilder: return command def getDestinationPath(self, sourcePath): - profileFileName = os.path.basename(sourcePath) - destination = os.path.join(self.profileStorageDir, profileFileName) + dstProfileFileName = self.fetchDstFileName(sourcePath) + dstProfilePath = os.path.join(self.profileStorageDir, dstProfileFileName) - return destination + return dstProfilePath + + def fetchDstFileName(self, srcFilePath): + profileFileName = os.path.basename(srcFilePath) + profileFileName = '{0}.{1}'.format(self.profileFilePrefix, profileFileName) + + return profileFileName diff --git a/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py new file mode 100644 index 0000000..13c5656 --- /dev/null +++ b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py @@ -0,0 +1,16 @@ +import unittest +from CommandBuilders.InstallProfileCommandBuilder import InstallProfileCommandBuilder + + +class TestInstallProfileBuilder(unittest.TestCase): + def setUp(self): + self.prefix = 'MyProject' + self.builder = InstallProfileCommandBuilder(self.prefix) + + def test_dstFileName(self): + dstFileName = self.builder.fetchDstFileName('/Some/Path/MyProfile.ext') + self.assertEqual(dstFileName, '{0}.MyProfile.ext'.format(self.prefix)) + + def test_dstPath(self): + dstPath = self.builder.getDestinationPath('/Some/Path/MyProfile.ext') + self.assertEqual('~/Library/MobileDevice/Provisioning Profiles/{0}.MyProfile.ext'.format(self.prefix), dstPath) \ No newline at end of file diff --git a/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfile.py b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileParser.py similarity index 100% rename from scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfile.py rename to scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileParser.py From 35ee02c6d846e984bb2b2b91489f8954a6adcd64 Mon Sep 17 00:00:00 2001 From: rzaitov Date: Thu, 14 Nov 2013 15:01:50 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=9F=D1=80=D0=B5=D1=84=D0=B8=D0=BA=D1=81?= =?UTF-8?q?=20=D0=BA=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8F=D0=BC=20?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D1=8F=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA?= =?UTF-8?q?=D0=BE=D0=B9=20project=5Fname?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/TouchinBuild/Core/StepsRunner.py | 4 +++- scripts/TouchinBuild/Tests/ManualTests/install_profile.py | 2 +- .../UnitTests/InstallProfile/test_installProfileBuilder.py | 2 +- .../TouchinBuild/parsers/InsideParser/InsideRemoveParser.py | 5 ++++- .../TouchinBuild/parsers/InsideParser/InsideSetParser.py | 6 ++++-- scripts/TouchinBuild/parsers/RegexpBuilder.py | 3 +++ scripts/TouchinBuild/utils/IncludeProcessor.py | 1 - 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/scripts/TouchinBuild/Core/StepsRunner.py b/scripts/TouchinBuild/Core/StepsRunner.py index 4e5894b..7441b89 100644 --- a/scripts/TouchinBuild/Core/StepsRunner.py +++ b/scripts/TouchinBuild/Core/StepsRunner.py @@ -33,7 +33,9 @@ class StepsRunner: self.patchInfoPlistArray = PatchInfoPlistArrayCommandBuilder() self.copyBuilder = CopyCommandBuilder() self.testflightBuilder = TestflightCommandBuilder() - self.installProfileBuilder = InstallProfileCommandBuilder() + + profilePrefix = config['project_name'] + self.installProfileBuilder = InstallProfileCommandBuilder(profilePrefix) buildUtilPath = config['build_tool'] self.cleanBuilder = CleanBuildCommandBuilder(buildUtilPath, 'clean') diff --git a/scripts/TouchinBuild/Tests/ManualTests/install_profile.py b/scripts/TouchinBuild/Tests/ManualTests/install_profile.py index 1f588f6..e86e39c 100644 --- a/scripts/TouchinBuild/Tests/ManualTests/install_profile.py +++ b/scripts/TouchinBuild/Tests/ManualTests/install_profile.py @@ -2,7 +2,7 @@ from CommandBuilders.InstallProfileCommandBuilder import InstallProfileCommandBu line = "install profile 'BuildSample/BuildSample/Profiles/8F606DAE-F9C9-4A19-8EFF-34B990D76C28.mobileprovision'" -builder = InstallProfileCommandBuilder() +builder = InstallProfileCommandBuilder('BsProject') command = builder.getCommandFor(line) command.execute() \ No newline at end of file diff --git a/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py index 13c5656..063374a 100644 --- a/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py +++ b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py @@ -13,4 +13,4 @@ class TestInstallProfileBuilder(unittest.TestCase): def test_dstPath(self): dstPath = self.builder.getDestinationPath('/Some/Path/MyProfile.ext') - self.assertEqual('~/Library/MobileDevice/Provisioning Profiles/{0}.MyProfile.ext'.format(self.prefix), dstPath) \ No newline at end of file + self.assertEqual('~/Library/MobileDevice/Provisioning Profiles/{0}.MyProfile.ext'.format(self.prefix), dstPath) diff --git a/scripts/TouchinBuild/parsers/InsideParser/InsideRemoveParser.py b/scripts/TouchinBuild/parsers/InsideParser/InsideRemoveParser.py index 435acd2..3ec570e 100644 --- a/scripts/TouchinBuild/parsers/InsideParser/InsideRemoveParser.py +++ b/scripts/TouchinBuild/parsers/InsideParser/InsideRemoveParser.py @@ -1,5 +1,6 @@ import re from parsers.InsideParser.InsideParserBase import InsideParserBase +from parsers.RegexpBuilder import RegexpBuilder class InsideRemoveParser(InsideParserBase): @@ -20,7 +21,9 @@ class InsideRemoveParser(InsideParserBase): filePathRegexp = r"'(?P[./ a-zA-Z]+\.{0})'".format(self.fileExt) projectNameRegexp = r'(?P[.a-zA-Z]+)' - regexpSource = self.startsWith('inside') + filePathRegexp + self.keywordToken('remove') + projectNameRegexp + self.spaceEndsWith('project') + rb = RegexpBuilder() + regexpSource = rb.startsWith('inside') + filePathRegexp + rb.keywordToken('remove') + projectNameRegexp + \ + rb.spaceEndsWith('project') regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/InsideParser/InsideSetParser.py b/scripts/TouchinBuild/parsers/InsideParser/InsideSetParser.py index 2c9f883..aadf89d 100644 --- a/scripts/TouchinBuild/parsers/InsideParser/InsideSetParser.py +++ b/scripts/TouchinBuild/parsers/InsideParser/InsideSetParser.py @@ -1,5 +1,6 @@ import re from parsers.InsideParser.InsideParserBase import InsideParserBase +from parsers.RegexpBuilder import RegexpBuilder class InsideSetParser(InsideParserBase): @@ -21,8 +22,9 @@ class InsideSetParser(InsideParserBase): keyRegexp = r'(?P[a-zA-Z]+)' valueRegexp = r"'(?P[^']+)'$" - regexpSource = self.startsWith('inside') + self.filePathRegexp + self.keywordToken('set') + keyRegexp + \ - self.keywordToken('to') + valueRegexp + rb = RegexpBuilder() + regexpSource = rb.startsWith('inside') + self.filePathRegexp + rb.keywordToken('set') + keyRegexp + \ + rb.keywordToken('to') + valueRegexp regexp = re.compile(regexpSource, re.UNICODE) match = regexp.match(line) diff --git a/scripts/TouchinBuild/parsers/RegexpBuilder.py b/scripts/TouchinBuild/parsers/RegexpBuilder.py index ffa28f4..90df74d 100644 --- a/scripts/TouchinBuild/parsers/RegexpBuilder.py +++ b/scripts/TouchinBuild/parsers/RegexpBuilder.py @@ -1,4 +1,7 @@ class RegexpBuilder: + def __init__(self): + pass + def keywordToken(self, keyword): assert keyword is not None return r'\s+' + keyword + r'\s+' diff --git a/scripts/TouchinBuild/utils/IncludeProcessor.py b/scripts/TouchinBuild/utils/IncludeProcessor.py index 8357997..41b9ffe 100644 --- a/scripts/TouchinBuild/utils/IncludeProcessor.py +++ b/scripts/TouchinBuild/utils/IncludeProcessor.py @@ -1,5 +1,4 @@ import re -from parsers.LineParser import LineParser from parsers.RegexpBuilder import RegexpBuilder From e0322fa7e9a45f07814ebb38b0cf92ff124c32ae Mon Sep 17 00:00:00 2001 From: rzaitov Date: Thu, 14 Nov 2013 15:09:26 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=82=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BB=20=D1=83=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BA=D1=83=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9=20=D0=BE=D0=B1=D0=B5=D1=81=D0=BF=D0=B5=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/IosSetupSteps.txt | 4 +--- scripts/IosSteps.txt | 6 ------ scripts/settings.txt | 5 +++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/scripts/IosSetupSteps.txt b/scripts/IosSetupSteps.txt index 262d6c6..443ffa1 100644 --- a/scripts/IosSetupSteps.txt +++ b/scripts/IosSetupSteps.txt @@ -1,5 +1,3 @@ -sh echo 'IosSetupSteps.txt' - # restore from backup # восстанавливаем из бэкапа (исходники от сборки предыдущей конфигурации могут быть модифицированными) # create backup @@ -11,7 +9,7 @@ inside 'BuildSample/BuildSample/CoolApp.csproj' set OutputPath to 'Output' for ' inside 'BuildSample/BuildSample/CoolApp.csproj' set AssemblyName to '{@assembly_name}' for '' inside 'BuildSample/BuildSample/Info.plist' set CFBundleVersion to '{@version}' -inside 'BuildSample/BuildSample/Info.plist' set CFBundleDisplayName to 'CoolApp' +inside 'BuildSample/BuildSample/Info.plist' set CFBundleDisplayName to '{@project_name}' inside 'BuildSample/BuildSample/Info.plist' set CFBundleIconFiles with values '{@icons}' diff --git a/scripts/IosSteps.txt b/scripts/IosSteps.txt index e748de9..72b4dff 100644 --- a/scripts/IosSteps.txt +++ b/scripts/IosSteps.txt @@ -1,11 +1,5 @@ -sh echo 'IosSteps.txt' -sh echo '{@builder_path}' - -sh echo hello from '{@author}' -sh echo version: '{@version}' - clean 'BuildSample/BuildSample.sln' for '{@sln_config}' build 'BuildSample/BuildSample.sln' for '{@sln_config}' diff --git a/scripts/settings.txt b/scripts/settings.txt index 8edf250..d37a95d 100644 --- a/scripts/settings.txt +++ b/scripts/settings.txt @@ -2,6 +2,7 @@ build_tool='/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool' version=0.0.0 # комментарий в тойже строке configs = 'appstore, staging' +project_name = CoolApp # ios platform settings ios.sln_config = Release|iPhone @@ -16,10 +17,10 @@ ios.tf_team_token = 'c5c3cf7a6dae2bea4382dfbd181a2075_Mjc4ODkwMjAxMy0wOS0yOSAxND # android.steps = 'scripts/AndroidSteps.txt' # config settings -ios.appstore.app_name = 'CoolApp' +ios.appstore.app_name = {@project_name} ios.appstore.author = 'Rustam' ios.appstore.icons = 'Content/Icons/icon-iphone@2x:Content/Icons/icon-iphone' -ios.staging.app_name = 'CoolApp staging' +ios.staging.app_name = '{@project_name} staging' ios.staging.author = 'Fedor' ios.staging.icons = 'Content/Icons/icon-iphone-staging@2x.png:Content/Icons/icon-iphone-staging.png'