当前位置: 首页>>代码示例>>Python>>正文


Python DictUtils.iter方法代码示例

本文整理汇总了Python中pyaid.dict.DictUtils.DictUtils.iter方法的典型用法代码示例。如果您正苦于以下问题:Python DictUtils.iter方法的具体用法?Python DictUtils.iter怎么用?Python DictUtils.iter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyaid.dict.DictUtils.DictUtils的用法示例。


在下文中一共展示了DictUtils.iter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _writeError

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def _writeError(self, data):
        """ Writes import error data to the logger, formatting it for human readable display. """
        source = {}

        if 'data' in data:
            for n,v in DictUtils.iter(data['data']):
                source[' '.join(n.split('_')).title()] = v

        indexPrefix = ''
        if 'index' in data:
            indexPrefix = ' [INDEX: %s]:' % data.get('index', 'Unknown')

        result  = [
            'IMPORT ERROR%s: %s' % (indexPrefix, data['message']),
            'DATA: ' + DictUtils.prettyPrint(source)]

        if 'existing' in data:
            source = {}
            snapshot = data['existing'].snapshot
            if snapshot:
                snapshot = JSON.fromString(snapshot)
            if snapshot:
                for n,v in DictUtils.iter(snapshot):
                    source[' '.join(n.split('_')).title()] = v
            result.append('CONFLICT: ' + DictUtils.prettyPrint(source))

        if 'error' in data:
            self._logger.writeError(result, data['error'])
        else:
            self._logger.write(result)
开发者ID:sernst,项目名称:Cadence,代码行数:32,代码来源:TrackCsvImporter.py

示例2: _postAnalyze

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def _postAnalyze(self):
        self.logger.write('TRACKWAY COUNT: %s' % self._weightedStats.count)
        self._weightedStats.save()
        self._unweightedStats.save()

        for key, csv in DictUtils.iter(self._quartileStats):
            csv.save()

        for label, paths in DictUtils.iter(self._densityPlots):
            self.mergePdfs(paths, '%s-Densities.pdf' % label.replace(' ', '-'))
开发者ID:sernst,项目名称:Cadence,代码行数:12,代码来源:TrackwayStatsStage.py

示例3: compileAllOnPath

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def compileAllOnPath(path, rootPath=None, recursive=False, debug=False, trace=False, force=False, compress=False):

        CoffeescriptBuilder._results = ""
        CoffeescriptBuilder._missing = {}
        if recursive:
            print("RECURSIVE COMPILE AT: " + path)

            def walker(paths, dirName, names):
                out = CoffeescriptBuilder._compileAllInDirectory(
                    os.path.join(paths[0], dirName), paths[1], debug=debug, trace=trace, force=force, compress=compress
                )
                CoffeescriptBuilder._results += out["res"]
                for n, v in DictUtils.iter(out["missing"]):
                    if n in CoffeescriptBuilder._missing:
                        continue
                    CoffeescriptBuilder._missing[n] = v

            FileUtils.walkPath(path, walker, [path, rootPath])
            print("\n\nCOMPILATION RESULTS:" + CoffeescriptBuilder._results)

            if CoffeescriptBuilder._missing:
                print("\n\nMISSING IMPORTS:" + "\n\n")
                for n, v in DictUtils.iter(CoffeescriptBuilder._missing):
                    print(v["class"] + " [LINE: #" + str(v["line"]) + " | " + v["package"] + "]")
        else:
            print("COMPILING DIRECTORY: " + path)
            CoffeescriptBuilder._compileAllInDirectory(
                path, rootPath, debug=debug, trace=trace, force=force, compress=compress
            )
开发者ID:sernst,项目名称:PyAid,代码行数:31,代码来源:CoffeescriptBuilder.py

示例4: _postAnalyze

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def _postAnalyze(self):
        """_postAnalyze doc..."""

        ratios = []

        for name, curve in DictUtils.iter(self.data):
            segments = curve.segments

            for i in ListUtils.rangeOn(segments):
                segment = segments[i]
                segmentLine = segment.line

                # If this is an extrapolated segment, use the length from the neighboring segment
                # instead of the artificial length of this segment.
                if segment == segments[0]:
                    segmentLine = segments[i + 1].line
                elif segment == segments[-1]:
                    segmentLine = segments[i - 1].line

                for pairData in segment.pairs:
                    projectionLine = pairData["line"]
                    ratios.append(100.0 * projectionLine.length.raw / segmentLine.length.raw)

        h = Histogram(
            data=ratios,
            binCount=50,
            xLabel="Projection/Stride Ratio (%)",
            title="Relative Stride to Projection Length Ratios",
        )
        h.shaveDataToXLimits()
        self._paths.append(h.save(path=self.getTempFilePath(extension="pdf")))

        self.mergePdfs(self._paths, "Curve-Projection.pdf")
开发者ID:sernst,项目名称:Cadence,代码行数:35,代码来源:CurveProjectionStage.py

示例5: currentChildWidgetID

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
 def currentChildWidgetID(self):
     if not self._currentWidget:
         return None
     for key, widget in DictUtils.iter(self._widgets):
         if widget == self._currentWidget:
             return key
     return None
开发者ID:sernst,项目名称:PyGlass,代码行数:9,代码来源:PyGlassWidget.py

示例6: save

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def save(self, path =None):
        """ Saves the CSV file data to the specified path """
        if path is None:
            path = self.path

        if self.removeIfSavedEmpty and not self.rows:
            self.remove()
            return

        index = 0
        names = self.fieldNames
        if self.autoIndexFieldName:
            names.insert(0, self.autoIndexFieldName)

        try:
            with open(path, 'wb') as f:
                writer = csv.DictWriter(f, fieldnames=names, dialect=csv.excel)
                writer.writeheader()
                for row in self.rows:
                    result = dict()

                    if self.autoIndexFieldName:
                        index += 1
                        result[self.autoIndexFieldName] = index

                    for key, spec in DictUtils.iter(self._fields):
                        value = row.get(key, spec.get('empty', ''))
                        name = spec.get('name', key)
                        if StringUtils.isTextType(value):
                            value = value.encode('latin-1')
                        result[name] = value
                    writer.writerow(result)
            return True
        except Exception:
            return False
开发者ID:sernst,项目名称:Cadence,代码行数:37,代码来源:CsvWriter.py

示例7: addChannels

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
 def addChannels(self, channels):
     if isinstance(channels, list):
         for v in channels:
             self.addChannel(v)
     elif isinstance(channels, dict):
         for n, v in DictUtils.iter(channels):
             self.addChannel(v)
开发者ID:sernst,项目名称:Cadence,代码行数:9,代码来源:CadenceData.py

示例8: __init__

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def __init__(self, **kwargs):
        """Creates a new instance of ConfigReader."""
        self._configs     = ArgsUtils.get('configs', dict(), kwargs)
        self._filenames   = ArgsUtils.get('filenames', None, kwargs)
        self._configPath  = ArgsUtils.get(
            'rootConfigPath',
            CadenceEnvironment.getConfigPath(),
            kwargs
        )

        if self._filenames:
            for n,v in DictUtils.iter(self._filenames):
                if not v:
                    continue

                path = os.path.join(self._configPath, v)
                if not path.endswith('.cfg'):
                    path += '.cfg'

                parser = ConfigParser.ConfigParser()
                if os.path.exists(path):
                    parser.read(path)
                else:
                    raise Exception(path + ' config file does not exist!')

                self._configs[n] = self._configParserToDict(parser)

        self._overrides = dict()
        self.setOverrides(ArgsUtils.get('overrides', None, kwargs))
开发者ID:sernst,项目名称:Cadence,代码行数:31,代码来源:ConfigReader.py

示例9: getChannel

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def getChannel(self, kind):
        """Doc..."""
        for n,v in DictUtils.iter(self._channels):
            if n == kind:
                return v

        return None
开发者ID:sernst,项目名称:Cadence,代码行数:9,代码来源:TargetData.py

示例10: echo

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
 def echo(self):
     print('TARGET:',self.target)
     print('GAIT PHASE OFFSET:',self._phaseOffset)
     print('DUTY FACTOR:',self._dutyFactor)
     print('CHANNELS:')
     for n,v in DictUtils.iter(self._channels):
         print(v.toString())
开发者ID:sernst,项目名称:Cadence,代码行数:9,代码来源:TargetData.py

示例11: echoModel

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def echoModel(self):
        """ An example using a Ziggurat database model. Here a new entry of the ZigguratTest_Test
            model is created and added to the database and its index in differing radices is
            returned in the response.

            NOTE: The model class is imported in-line in this example simply to allow use of the
                Hello Ziggurat examples without model support for those not in an environment
                without the required database support. """

        try:
            from ziggHello.models.zigguratTest.ZigguratTest_Test import ZigguratTest_Test
            model = ZigguratTest_Test.MASTER

            out = dict()
            for name, value in DictUtils.iter(self._router.ziggurat.environ):
                if name.upper() == name:
                    out[name] = StringUtils.toUnicode(value)

            entry = model()
            entry.infoData = out
            model.session.add(entry)
            model.session.flush()
        except Exception as err:
            self._router.response['error'] = str(err)
            self._router.logger.writeError(u'MODEL ERROR', err)
            return

        self._router.response['index'] = [entry.i, entry.i16, entry.i36, entry.i64]
开发者ID:sernst,项目名称:Ziggurat,代码行数:30,代码来源:HelloController.py

示例12: _handleResponseReady

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def _handleResponseReady(self, request, response):
        """Event handler for the response object being ready for use."""

        if self._cacheControlPublic:
            response.cache_control = "public"

        # -------------------------------------------------------------------------------------------
        # Cache Expiration: Set the caching values according to the _expires property
        rep = self._explicitResponse
        if rep is None or (isinstance(rep, ViewResponse) and rep.allowCaching):
            response.cache_control.max_age = self.expires if not self.expires is None else 0
        else:
            response.cache_control.max_age = 0

        # -------------------------------------------------------------------------------------------
        # Cache Validators
        if self._etag is not None:
            response.etag = StringUtils.toUnicode(self._etag)

        if self._lastModified is not None:
            response.last_modified = self._lastModified

        # If required encode the response headers as strings to prevent unicode errors. This is
        # necessary for certain WSGI server applications, e.g. flup.
        if self.ziggurat.strEncodeEnviron:
            for n, v in DictUtils.iter(response.headers):
                if StringUtils.isStringType(v):
                    response.headers[n] = StringUtils.toStr2(v)

        # Clean up per-thread sessions.
        ConcreteModelsMeta.cleanupSessions()
开发者ID:sernst,项目名称:Ziggurat,代码行数:33,代码来源:ZigguratBaseView.py

示例13: getColorNameAndValue

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def getColorNameAndValue(self):
        """ Finds the nearest named color by comparing all named colors """
        if self._rawColor == 0:
            return {
                'name':'Black',
                'value':0,
                'key':'black',
                'residual':0.0 }

        maxRange = 560.0
        nearestValue = None
        nearestName  = None
        range   = 360
        myColor = self.asHsl(output=list)
        poolColor = self.__class__(0)
        for name, value in DictUtils.iter(ColorNames.NAMES):
            poolColor.load(value)
            color = poolColor.asHsl(output=list)

            test = (myColor[0] - color[0])*(myColor[0] - color[0]) \
                + (myColor[1] - color[1])*(myColor[1] - color[1]) \
                + (myColor[2] - color[2])*(myColor[2] - color[2])
            if test < range:
                nearestValue = value
                nearestName  = name
                range        = test
            if range < 1:
                break

        return {
            'name':StringUtils.capitalizeWords(nearestName.replace('_', ' ')),
            'value':nearestValue,
            'key':nearestName,
            'residual':100.0*range/maxRange }
开发者ID:sernst,项目名称:PyAid,代码行数:36,代码来源:ColorValue.py

示例14: setFromDict

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
    def setFromDict(self, keysAndValues):
        if not keysAndValues:
            return

        self._loadSettings()
        for key, value in DictUtils.iter(keysAndValues):
            self._updateSetting(key, value)
        self._saveSettings()
开发者ID:sernst,项目名称:PyAid,代码行数:10,代码来源:SettingsConfig.py

示例15: echoImportFlags

# 需要导入模块: from pyaid.dict.DictUtils import DictUtils [as 别名]
# 或者: from pyaid.dict.DictUtils.DictUtils import iter [as 别名]
 def echoImportFlags(self, separator =' | '):
     """echoImportFlags doc..."""
     out = []
     d = Reflection.getReflectionDict(ImportFlagsEnum)
     for key, value in DictUtils.iter(d):
         if value & self.importFlags:
             out.append(key)
     return ('[%s]' % separator.join(out)) if out else '--'
开发者ID:sernst,项目名称:Cadence,代码行数:10,代码来源:TracksTrackDefault.py


注:本文中的pyaid.dict.DictUtils.DictUtils.iter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。