def fromFile(cls, filename, classPrefix, includeRestorationIDs=False): res = cls(lib.bareFilename(filename), classPrefix) root = ElementTree.parse(fn) segueIds = getAttrsForAllNodesWithAttr(root, 'identifier', 'segue') res._addIds(segueIds, cls.SEGUE) # This seems to be limited to view controllers, but we can't specify a tag, as different # UIViewController subclasses have different tags (e.g. nav controllers). viewControllerIds = getAttrsForAllNodesWithAttr( root, 'storyboardIdentifier') res._addIds(viewControllerIds, cls.VIEW_CONTROLLER) reuseIds = getAttrsForAllNodesWithAttr(root, 'reuseIdentifier') res._addIds(reuseIds, cls.REUSE) if includeRestorationIDs: restorationIds = getAttrsForAllNodesWithAttr( root, 'restorationIdentifier') restorationIds.extend( getRestorationIDsForVCsUsingStoryboardIDs(root)) res._addIds(restorationIds, cls.RESTORATION) return res
def fromFile(cls, filename, classPrefix, includeRestorationIDs = False): res = cls(lib.bareFilename(filename), classPrefix) root = ElementTree.parse(fn) segueIds = getAttrsForAllNodesWithAttr(root, 'identifier', 'segue') res._addIds(segueIds, cls.SEGUE) # This seems to be limited to view controllers, but we can't specify a tag, as different # UIViewController subclasses have different tags (e.g. nav controllers). viewControllerIds = getAttrsForAllNodesWithAttr(root, 'storyboardIdentifier') res._addIds(viewControllerIds, cls.VIEW_CONTROLLER) reuseIds = getAttrsForAllNodesWithAttr(root, 'reuseIdentifier') res._addIds(reuseIds, cls.REUSE) if includeRestorationIDs: restorationIds = getAttrsForAllNodesWithAttr(root, 'restorationIdentifier') restorationIds.extend(getRestorationIDsForVCsUsingStoryboardIDs(root)) res._addIds(restorationIds, cls.RESTORATION) return res
def classNameForCatalog(catalogDir, classPrefix): name = lib.bareFilename(catalogDir) return classPrefix + lib.variableNameForString(name, [classPrefix], ['AssetCatalog', 'Catalog'], lower = False) + 'Catalog'
def imageNamesInCatalog(catalogDir): imagesetDirs = glob(os.path.join(catalogDir, '*.imageset')) return [lib.bareFilename(d) for d in imagesetDirs]
# Don't run in continuous integration or if we're not a build for release if lib.inContinuousIntegration or not lib.isDistributionOrAdHocBuildForDevice: print('Not removing localizations; this is an internal build') exit(0) # The project object has a knownRegions property that is an array of # locale strings (e.g. "Base", "en") that were set up in Xcode. knownRegions = lib.getProjectKeypath('knownRegions') if not knownRegions: lib.warn('The project is reporting that there are no known localizations in your project.\nPlease report this at {}'.format(lib.REPORT_URL)) exit(0) print('Keeping localizations for regions: ' + ', '.join(knownRegions)) regionsAndFoldersToDelete = [] lprojFolders = glob(os.path.join(lib.getEnv('CODESIGNING_FOLDER_PATH'), '*.lproj')) for lprojFolder in lprojFolders: region = lib.bareFilename(lprojFolder) if not region in knownRegions: regionsAndFoldersToDelete.append((region, lprojFolder)) if regionsAndFoldersToDelete: print('Removing extraneous localizations: ' + ', '.join([t[0] for t in regionsAndFoldersToDelete])) try: for _, folder in regionsAndFoldersToDelete: rmtree(folder) except Exception, e: lib.warn('Error deleting localization directories: {!s}\n\nPlease report this at {}'.format(e, lib.REPORT_URL))
def classNameForCatalog(catalogDir, classPrefix): name = lib.bareFilename(catalogDir) return classPrefix + lib.variableNameForString(name, [classPrefix], ['AssetCatalog', 'Catalog'], lower=False) + 'Catalog'