diff --git a/scripts/parser/InstallProfileParser.py b/scripts/parser/InstallProfileParser.py new file mode 100644 index 0000000..2075bb3 --- /dev/null +++ b/scripts/parser/InstallProfileParser.py @@ -0,0 +1,34 @@ +import re +import os +from parser.CopyParser.CopyArguments import CopyArguments +from parser.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 + + profilePathRegexp = r"'(?P[^']+)'$" + regexpSource = self.startsWith('install') + self.than('profile') + profilePathRegexp + + regexp = re.compile(regexpSource, re.UNICODE) + + match = regexp.match(line) + 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