class StepsRunner: def __init__(self, config, compositeLineProcessor, valueProvider): assert config is not None assert compositeLineProcessor is not None assert valueProvider is not None self.lineConveyor = compositeLineProcessor self.valueProvider = valueProvider self.shCommandBuilder = ShCommandBuilder() self.removeProjectBuilder = RemoveProjectCommandBuilder() self.createDirs = MakeDirsCommandBuilder() self.patchCsproj = PatchCsprojCommandBuilder() self.patchInfoPlist = PatchInfoplistCommandBuilder(self.valueProvider) self.patchInfoPlistArray = PatchInfoPlistArrayCommandBuilder() self.patchManifest = PatchManifestCommandBuilder() self.copyBuilder = CopyCommandBuilder() self.testflightBuilder = TestflightCommandBuilder() ignoreBackup = config.get('backup_ignore', None) self.createBackupBuilder = CreateBackupCommandBuilder(ignoreBackup) self.restoreFromBackupBuilder = RestoreBackupCommandBuilder(ignoreBackup) self.deleteBackupBuilder = DeleteBackupCommandBuilder(ignoreBackup) profilePrefix = config['project_name'] self.installProfileBuilder = InstallProfileCommandBuilder(profilePrefix) buildUtilPath = config['build_tool'] self.cleanBuilder = CleanBuildCommandBuilder(buildUtilPath, 'clean') self.buildBuilder = CleanBuildCommandBuilder(buildUtilPath, 'build') self.signAndroid = SignApkCommandBuilder(buildUtilPath) def run(self, content): assert content is not None lines = content.splitlines() for line in lines: processedLine = self.lineConveyor.processText(line, self.lineConveyor) if len(processedLine) == 0: continue else: self.processLine(processedLine) def processLine(self, line): if self.shCommandBuilder.isShCommand(line): cmd = self.shCommandBuilder.getCommandFor(line) elif self.removeProjectBuilder.isRemoveProject(line): cmd = self.removeProjectBuilder.getCommandFor(line) elif self.cleanBuilder.isCleanBuild(line): cmd = self.cleanBuilder.getCommandFor(line) elif self.buildBuilder.isCleanBuild(line): cmd = self.buildBuilder.getCommandFor(line) elif self.signAndroid.isSignApk(line): cmd = self.signAndroid.getCommandFor(line) elif self.createBackupBuilder.isCreateBackup(line): cmd = self.createBackupBuilder.getCommandFor(line) elif self.createDirs.isMakeDirsCommand(line): cmd = self.createDirs.getCommandFor(line) elif self.patchCsproj.isPatchCsproj(line): cmd = self.patchCsproj.getCommandFor(line) elif self.patchInfoPlist.isPatchInfoPlist(line): cmd = self.patchInfoPlist.getCommandFor(line) elif self.patchInfoPlistArray.isPatchInfoPlist(line): cmd = self.patchInfoPlistArray.getCommandFor(line) elif self.patchManifest.isManifestCommand(line): cmd = self.patchManifest.getCommandFor(line) elif self.copyBuilder.isCopy(line): cmd =self.copyBuilder.getCommandFor(line) elif self.restoreFromBackupBuilder.isRestoreBackup(line): cmd = self.restoreFromBackupBuilder.getCommandFor(line) elif self.deleteBackupBuilder.isDeleteBackup(line): cmd =self.deleteBackupBuilder.getCommandFor(line) elif self.testflightBuilder.isTestflight(line): cmd = self.testflightBuilder.getCommandFor(line) elif self.installProfileBuilder.isInstallProfile(line): cmd = self.installProfileBuilder.getCommandFor(line) else: msg = "unrecognised step. Line: '{0}'".format(line) raise Exception(msg) print 'start: {0}'.format(line) cmd.execute() print 'finish: {0}'.format(line)
from CommandBuilders.PatchInfoplistCommandBuilder import PatchInfoplistCommandBuilder from commands.ValueProvider import ValueProvider config = { 'version': '0.1.2', 'app_name': 'TestAppName', # patch_info_plist 'plist app:CoolApp rel_path': 'BuildSample/Info.plist', 'plist app:CoolApp key:CFBundleVersion': '@version', # set CFBundleVersion 'plist app:CoolApp key:CFBundleDisplayName': '@app_name', # set CFBundleDisplayName } line = "inside 'BuildSample/BuildSample/Info.plist' set CFBundleDisplayName to 'MyCoolApp'" value_provider = ValueProvider() value_provider.setConfig(config) builder = PatchInfoplistCommandBuilder(value_provider) command = builder.getCommandFor(line) command.execute()