def _listPath(cls, rootPath, recursive, **kwargs): listDirs = ArgsUtils.get('listDirs', False, kwargs) skipSVN = ArgsUtils.get('skipSVN', True, kwargs) skips = ArgsUtils.get('skips', None, kwargs) allowExtensions = ArgsUtils.getAsList('allowExtensions', kwargs) skipExtensions = ArgsUtils.getAsList('skipExtensions', kwargs) out = [] for item in os.listdir(rootPath): if (skipSVN and item == '.svn') or (skips and item in skips): continue absItem = os.path.join(rootPath, item) if os.path.isdir(absItem): path = (absItem + os.sep) if listDirs: out.append(path) absItem = None if recursive: out += cls._listPath(path, recursive, **kwargs) elif os.path.isfile(absItem): if skipExtensions and StringUtils.ends(item, skipExtensions): continue if allowExtensions and not StringUtils.ends(item, allowExtensions): continue if absItem: out.append(absItem) return out
def getSetupKwargs(self, **kwargs): """Doc...""" # Adds packages to python system path os.chdir(self.sourcePath) appName = ArgsUtils.get('appDisplayName', None, kwargs) self._iconPath = ArgsUtils.get('iconPath', '', kwargs) self._scriptPath = ArgsUtils.get('scriptPath', None, kwargs) self._paths = ArgsUtils.getAsList('resources', kwargs) self._includes = ArgsUtils.getAsList('includes', kwargs) for path in self._paths: sys.path.append(path) dataFiles = [] if OsUtils.isWindows(): dataFiles += self._addWindowsDataFiles() values = self._getSiteValues(dataFiles, [], []) window = {'script':self._scriptPath} #------------------------------------------------------------------------------------------- # [MAC] CLEANSE PACKAGES # Py2app does not allow subpackages. Instead the entire package must be copied so # any subpackage entries listed must be replaced by the top level package if not OsUtils.isWindows(): packs = [] for item in values['packages']: item = item.split('.')[0] if item not in packs: packs.append(item) values['packages'] = packs compType = 'py2exe' if OsUtils.isWindows() else 'py2app' options = { 'packages':values['packages'], 'includes':values['includes']} out = dict(options={compType:options}) if OsUtils.isWindows(): if self._iconPath: window['icon_resources'] = [(1, self._iconPath)] out['windows'] = [window] out['data_files'] = values['dataFiles'] else: if self._iconPath: options['iconfile'] = self._iconPath out['name'] = appName out['setup_requires'] = [compType] out['app'] = [window] options['resources'] = [ FileUtils.createPath(self.sourcePath, 'resources', isDir=True) ] return out
def __init__(self, **kwargs): """Creates a new instance of MarkupError.""" self._thrown = Logger.getFormattedStackTrace(2, 3) self._definition = ArgsUtils.get('errorDef', None, kwargs) self._tag = ArgsUtils.get('tag', None, kwargs) self._block = ArgsUtils.get('block', self._tag.block if self._tag else None, kwargs) self._processor = ArgsUtils.get('processor', self._tag.processor if self._tag else None, kwargs) self._code = ArgsUtils.get('code', self._definition.code, kwargs, allowNone=False) self.label = ArgsUtils.get('label', self._definition.label, kwargs, allowNone=False) self.message = ArgsUtils.get('message', self._definition.message, kwargs, allowNone=False) self._critical = ArgsUtils.get('critical', False, kwargs) replacements = ArgsUtils.getAsList('replacements', kwargs) replacements.append([u'#TAG#', unicode(self._tag.tagName if self._tag else u'???')]) for r in replacements: if self.message: self.message = self.message.replace(unicode(r[0]), unicode(r[1])) if self.label: self.label = self.label.replace(unicode(r[0]), unicode(r[1])) self._verbose = ArgsUtils.get('verbose', False, kwargs) self._line = None self._character = None self._source = None self._logSource = None self._populateData()
def __init__(self, shortFlag, longFlag, **kwargs): """Creates a new instance of NodeAttribute.""" OpenMaya.MObject.__init__(self) self._shortFlag = shortFlag self._longFlag = longFlag self._kwargs = kwargs self.name = None self.nodeClass = None self.attr = None self._affects = ArgsUtils.getAsList('affects', kwargs) self._computeName = ArgsUtils.get('compute', None, kwargs)
def __init__(self, name, pattern, blockType, terminator =None, **kwargs): """Creates a new instance of ClassTemplate.""" self.name = name self.pattern = pattern self.blockType = blockType self._terminator = terminator self.findState = ArgsUtils.get('findState', None, kwargs) self.matchReqs = ArgsUtils.get('matchReqs', None, kwargs) self.terminatorReqs = ArgsUtils.get('terminatorReqs', None, kwargs) self.chainBlocks = ArgsUtils.get('chainBlocks', False, kwargs) self.chainBreakers = ArgsUtils.getAsList('chainBreakers', kwargs) self.closeAtEnd = ArgsUtils.get('closeAtEnd', False, kwargs)
def __init__(self, name, pattern, blockType, terminator=None, **kwargs): """Creates a new instance of ClassTemplate.""" self.name = name self.pattern = pattern self.blockType = blockType self._terminator = terminator self.findState = ArgsUtils.get('findState', None, kwargs) self.matchReqs = ArgsUtils.get('matchReqs', None, kwargs) self.terminatorReqs = ArgsUtils.get('terminatorReqs', None, kwargs) self.chainBlocks = ArgsUtils.get('chainBlocks', False, kwargs) self.chainBreakers = ArgsUtils.getAsList('chainBreakers', kwargs) self.closeAtEnd = ArgsUtils.get('closeAtEnd', False, kwargs)
def _populateTools(self): """Doc...""" path = self.getAppResourcePath('ToolsManifest.json', isFile=True) try: f = open(path) definition = JSON.fromString(f.read()) f.close() except Exception as err: self.log.writeError('ERROR: Unable to read tools manifest file.', err) return for tool in ArgsUtils.getAsList('tools', definition): self._addTool(tool) self._toolBox.layout().addStretch()
def __init__(self, **kwargs): """Creates a new instance of MarkupAttributeError.""" self._attribute = ArgsUtils.get('attribute', None, kwargs) self._attrGroup = ArgsUtils.get('attributeGroup', None, kwargs) self._rawValue = ArgsUtils.get('rawValue', None, kwargs) self._value = ArgsUtils.get('value', self._rawValue, kwargs) self._attrData = ArgsUtils.get('attributeData', None, kwargs) self._attributeSource = None replacements = ArgsUtils.getAsList('replacements', kwargs) replacements.append( [u'#ATTR#', unicode(self.attribute if self.attribute else u'???')]) replacements.append( [u'#VAL#', unicode(self.value if self.value else u'???')]) kwargs['replacements'] = replacements ArgsUtils.addIfMissing('errorDef', self.INVALID_ATTRIBUTE, kwargs, True) MarkupError.__init__(self, **kwargs)
def _listPath(cls, rootPath, recursive, **kwargs): allowDots = kwargs.get('allowDots', True) rootPath = cls.cleanupPath(rootPath, isDir=True) listFiles = kwargs.get('listFiles', True) listDirs = kwargs.get('listDirs', False) skipSVN = kwargs.get('skipSVN', True) skips = kwargs.get('skips', None) absolute = kwargs.get('absolute', True) pieces = kwargs.get('pieces', False) topPath = ArgsUtils.extract('topPath', rootPath, kwargs) allowExtensions = ArgsUtils.getAsList('allowExtensions', kwargs) skipExtensions = ArgsUtils.getAsList('skipExtensions', kwargs) out = [] for item in os.listdir(rootPath): if not allowDots and item.startswith('.'): continue if (skipSVN and item == '.svn') or (skips and item in skips): continue absItem = os.path.join(rootPath, item) if os.path.isdir(absItem): path = absItem + os.sep if listDirs: out.append(path if absolute else item) absItem = None if recursive: out += cls._listPath(rootPath=path, recursive=recursive, topPath=topPath, **kwargs) elif os.path.isfile(absItem): skip = skipExtensions and StringUtils.ends( item, skipExtensions) if not listFiles or skip: continue if allowExtensions and not StringUtils.ends( item, allowExtensions): continue if not absItem: continue if not pieces and not absolute: out.append(item) continue relativeItem = absItem[len(topPath):].strip(os.sep).split(os.sep) if absolute: relativeItem.insert(0, topPath) if pieces: out.append(relativeItem) else: out.append(os.path.join(*relativeItem)) return out
def _listPath(cls, rootPath, recursive, **kwargs): allowDots = kwargs.get('allowDots', True) rootPath = cls.cleanupPath(rootPath, isDir=True) listFiles = kwargs.get('listFiles', True) listDirs = kwargs.get('listDirs', False) skipSVN = kwargs.get('skipSVN', True) skips = kwargs.get('skips', None) absolute = kwargs.get('absolute', True) pieces = kwargs.get('pieces', False) topPath = ArgsUtils.extract('topPath', rootPath, kwargs) allowExtensions = ArgsUtils.getAsList('allowExtensions', kwargs) skipExtensions = ArgsUtils.getAsList('skipExtensions', kwargs) out = [] for item in os.listdir(rootPath): if not allowDots and item.startswith('.'): continue if (skipSVN and item == '.svn') or (skips and item in skips): continue absItem = os.path.join(rootPath, item) if os.path.isdir(absItem): path = absItem + os.sep if listDirs: out.append(path if absolute else item) absItem = None if recursive: out += cls._listPath( rootPath=path, recursive=recursive, topPath=topPath, **kwargs) elif os.path.isfile(absItem): skip = skipExtensions and StringUtils.ends(item, skipExtensions) if not listFiles or skip: continue if allowExtensions and not StringUtils.ends(item, allowExtensions): continue if not absItem: continue if not pieces and not absolute: out.append(item) continue relativeItem = absItem[len(topPath):].strip(os.sep).split(os.sep) if absolute: relativeItem.insert(0, topPath) if pieces: out.append(relativeItem) else: out.append(os.path.join(*relativeItem)) return out