• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.toString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中misc.util.toString函数的典型用法代码示例。如果您正苦于以下问题:Python toString函数的具体用法?Python toString怎么用?Python toString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: tree

    def tree(self, treegen=treegenerator, force=False):

        cache = self.context["cache"]
        console = self.context["console"]
        tradeSpaceForSpeed = (
            False
        )  # Caution: setting this to True seems to make builds slower, at least on some platforms!?
        cacheId = "tree%s-%s-%s" % (treegen.tag, self.path, util.toString({}))
        self.treeId = cacheId

        # Lookup for unoptimized tree
        tree, _ = cache.read(cacheId, self.path, memory=tradeSpaceForSpeed)

        # Tree still undefined?, create it!
        if tree == None or force:
            console.debug("Parsing file: %s..." % self.id)
            console.indent()

            fileContent = filetool.read(self.path, self.encoding)
            tokens = tokenizer.parseStream(fileContent, self.id)

            console.outdent()
            console.debug("Generating tree: %s..." % self.id)
            console.indent()
            tree = treegen.createSyntaxTree(tokens)  # allow exceptions to propagate

            # store unoptimized tree
            # print "Caching %s" % cacheId
            cache.write(cacheId, tree, memory=tradeSpaceForSpeed, writeToFile=True)

            console.outdent()
        return tree
开发者ID:w495,项目名称:acv,代码行数:32,代码来源:MClassCode.py


示例2: getCode

    def getCode(self, compOptions, treegen=treegenerator, featuremap={}):

        # source versions
        if not compOptions.optimize:
            compiled = filetool.read(self.path)
            # assure trailing \n (e.g. to utilise ASI)
            if compiled[-1:] != "\n":
                compiled += '\n'
        # compiled versions
        else:
            optimize  = compOptions.optimize
            variants  = compOptions.variantset
            format_   = compOptions.format
            classVariants     = self.classVariants()
            # relevantVariants is the intersection between the variant set of this job
            # and the variant keys actually used in the class
            relevantVariants  = self.projectClassVariantsToCurrent(classVariants, variants)
            variantsId        = util.toString(relevantVariants)
            optimizeId        = self._optimizeId(optimize)
            cache             = self.context["cache"]

            cacheId = "compiled-%s-%s-%s-%s" % (self.path, variantsId, optimizeId, format_)
            compiled, _ = cache.read(cacheId, self.path)

            if compiled == None:
                tree = self.optimize(None, optimize, variants, featuremap)
                compiled = self.serializeTree(tree, optimize, format_)
                if not "statics" in optimize:
                    cache.write(cacheId, compiled)

        return compiled
开发者ID:1and1,项目名称:qooxdoo,代码行数:31,代码来源:MClassCode.py


示例3: getAssets

    def getAssets(self, assetMacros={}):

        # Memoizing needs assetMacros in the key, otherwise you get wrong
        # results with multiple builds in one generator run.
        macroskey = util.toString(assetMacros)
        macroskey = sha_construct(macroskey).hexdigest()
        if macroskey not in self._assetRegex:
            # prepare a regex encompassing all asset hints, asset macros resolved
            classAssets = self.getHints()['assetDeps'][:]
            iresult  = []  # [AssetHint]
            for res in classAssets:
                # expand file glob into regexp
                res = re.sub(r'\*', ".*", res)
                # expand macros
                if res.find('${')>-1:
                    expres = self._expandMacrosInMeta(assetMacros, res)
                else:
                    expres = [res]
                # collect resulting asset objects
                for e in expres:
                    assethint = AssetHint(res)
                    assethint.clazz = self
                    assethint.expanded = e
                    assethint.regex = re.compile(e)
                    if assethint not in iresult:
                        iresult.append(assethint)
            self._assetRegex[macroskey] = iresult

        return self._assetRegex[macroskey]
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:29,代码来源:MClassResources.py


示例4: messageStrings

    def messageStrings(self, variants):
        # this duplicates codef from Locale.getTranslation

        classVariants     = self.classVariants()
        relevantVariants  = self.projectClassVariantsToCurrent(classVariants, variants)
        variantsId        = util.toString(relevantVariants)
        cacheId           = "messages-%s" % (variantsId,)
        cached            = True
        console           = self.context['console']

        #messages, _ = cache.readmulti(cacheId, self.path)
        classInfo, cacheModTime = self._getClassCache()
        messages = classInfo[cacheId] if cacheId in classInfo else None
        if messages != None:
            return messages, cached

        console.debug("Looking for message strings: %s..." % self.id)
        console.indent()
        cached = False

        tree = self.tree()

        try:
            messages = self._findTranslationBlocks(tree, [])
        except NameError, detail:
            raise RuntimeError("Could not extract message strings from %s!\n%s" % (self.id, detail))
开发者ID:1and1,项目名称:qooxdoo,代码行数:26,代码来源:MClassI18N.py


示例5: tree

    def tree(self, treegen=treegenerator, force=False):

        cache = self.context['cache']
        console = self.context['console']
        tradeSpaceForSpeed = False  # Caution: setting this to True seems to make builds slower, at least on some platforms!?
        cacheId = "tree%s-%s-%s" % (treegen.tag, self.path, util.toString({}))
        self.treeId = cacheId

        # Lookup for unoptimized tree
        tree, _ = cache.read(cacheId, self.path, memory=tradeSpaceForSpeed)

        # Tree still undefined?, create it!
        if tree == None or force:
            console.debug("Parsing file: %s..." % self.id)
            console.indent()

            # Tokenize
            fileContent = filetool.read(self.path, self.encoding)
            fileId = self.path if self.path else self.id
            try:
                tokens = tokenizer.Tokenizer().parseStream(fileContent, self.id)
            except SyntaxException, e:
                # add file info
                e.args = (e.args[0] + "\nFile: %s" % fileId,) + e.args[1:]
                raise e

            # Parse
            try:
                tree = treegen.createFileTree(tokens, fileId)
            except SyntaxException, e:
                # add file info
                e.args = (e.args[0] + "\nFile: %s" % fileId,) + e.args[1:]
                raise
开发者ID:1and1,项目名称:qooxdoo,代码行数:33,代码来源:MClassCode.py


示例6: getCompiledSize

    def getCompiledSize(self, fileId, variants, optimize=None, recompile=True):
        if optimize == None:
            optimize = self._optimize      # use object setting as default
        fileEntry = self._classes[fileId]
        filePath = fileEntry["path"]

        variantsId = util.toString(variants)
        if optimize:
            optimizeId = self.generateOptimizeId(optimize)
            cacheId = "compiledsize-%s-%s-%s" % (filePath, variantsId, optimizeId)
        else:
            cacheId = "compiledsize-%s-%s" % (filePath, variantsId)

        size = self._cache.readmulti(cacheId, filePath)
        if size != None:
            return size

        if recompile == False:
            return -1

        self._console.debug("Computing compiled size: %s..." % fileId)
        #tree = self._treeLoader.getTree(fileId, variants)
        #compiled = self.compileTree(tree)
        compiled = self.getCompiled(fileId, variants, optimize, format=True) # TODO: format=True is a hack here, since it is most likely
        size = len(compiled)

        self._cache.writemulti(cacheId, size)
        return size
开发者ID:flomotlik,项目名称:grails-qooxdoo,代码行数:28,代码来源:TreeCompiler.py


示例7: getTreeCacheId

 def getTreeCacheId(optimize=[], variantSet={}):
     classVariants = self.classVariants()
     relevantVariants = self.projectClassVariantsToCurrent(classVariants, variantSet)
     return "tree%s-%s-%s-%s" % (
         treegenerator.tag,  # TODO: hard-coded treegen.tag
         self.path,
         self._optimizeId(optimize),
         util.toString(relevantVariants),
     )
开发者ID:samikhaled,项目名称:qooxdoo,代码行数:9,代码来源:MClassCode.py


示例8: checkCache

    def checkCache(self, fileId, variants, optimize, format=False):
        filePath = self._classes[fileId]["path"]

        variantsId = util.toString(variants)
        optimizeId = self.generateOptimizeId(optimize)

        cacheId = "compiled-%s-%s-%s-%s" % (filePath, variantsId, optimizeId, format)
        compiled = self._cache.read(cacheId, filePath)

        return cacheId, compiled
开发者ID:flomotlik,项目名称:grails-qooxdoo,代码行数:10,代码来源:TreeCompiler.py


示例9: tree

    def tree(self, variantSet={}):
        context = self.context
        cache   = context['cache']
        tradeSpaceForSpeed = False  # Caution: setting this to True seems to make builds slower, at least on some platforms!?

        # Construct the right cache id
        unoptCacheId     = "tree-%s-%s" % (self.path, util.toString({}))

        classVariants    = []
        tree             = None
        classVariants    = self.classVariants(generate=False) # just check the cache
        if classVariants == None:
            tree = self._getSourceTree(unoptCacheId, tradeSpaceForSpeed)
            classVariants= self._variantsFromTree(tree)

        relevantVariants = self.projectClassVariantsToCurrent(classVariants, variantSet)
        cacheId          = "tree-%s-%s" % (self.path, util.toString(relevantVariants))

        # Get the right tree to return
        if cacheId == unoptCacheId and tree:  # early return optimization
            return tree

        opttree, cacheMod = cache.read(cacheId, self.path, memory=tradeSpaceForSpeed)
        if not opttree:
            # start from source tree
            if tree:
                opttree = tree
            else:
                opttree = self._getSourceTree(unoptCacheId, tradeSpaceForSpeed)
            # do we have to optimze?
            if cacheId == unoptCacheId:
                return opttree
            else:
                context["console"].debug("Selecting variants: %s..." % self.id)
                context["console"].indent()
                variantoptimizer.search(opttree, variantSet, self.id)
                context["console"].outdent()
                # store optimized tree
                #print "Caching %s" % cacheId
                cache.write(cacheId, opttree, memory=tradeSpaceForSpeed, writeToFile=True)

        return opttree
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:42,代码来源:MClassCode.py


示例10: _checkCache

    def _checkCache(self, fileId, variants, optimize, format=False):
        filePath = self._classes[fileId].path

        classVariants     = self._classes[fileId].classVariants()
        relevantVariants  = Class.projectClassVariantsToCurrent(classVariants, variants)
        variantsId = util.toString(relevantVariants)

        optimizeId = self.generateOptimizeId(optimize)

        cacheId = "compiled-%s-%s-%s-%s" % (filePath, variantsId, optimizeId, format)
        compiled, _ = self._cache.read(cacheId, filePath)

        return cacheId, compiled
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:13,代码来源:TreeCompiler.py


示例11: _getCompiled

    def _getCompiled(self, compOptions):

        ##
        # Interface to ecmascript.backend
        def serializeCondensed(tree, format_=False):
            result = [u'']
            result =  Packer().serializeNode(tree, None, result, format_)
            return u''.join(result)

        def serializeFormatted(tree):
            # provide minimal pretty options
            def options(): pass
            pretty.defaultOptions(options)
            options.prettypCommentsBlockAdd = False  # turn off comment filling

            result = [u'']
            result = pretty.prettyNode(tree, options, result)

            return u''.join(result)

        # ----------------------------------------------------------------------

        optimize          = compOptions.optimize
        variants          = compOptions.variantset
        format_           = compOptions.format
        classVariants     = self.classVariants()
        relevantVariants  = self.projectClassVariantsToCurrent(classVariants, variants)
        variantsId        = util.toString(relevantVariants)
        optimizeId        = self._optimizeId(optimize)
        cache             = self.context["cache"]

        # Caution: Sharing cache id with TreeCompiler
        cacheId = "compiled-%s-%s-%s-%s" % (self.path, variantsId, optimizeId, format_)
        compiled, _ = cache.read(cacheId, self.path)

        if compiled == None:
            tree   = self.tree(variants)
            tree   = self.optimize(tree, optimize)
            if optimize == ["comments"]:
                compiled = serializeFormatted(tree)
                if compiled[-1:] != "\n": # assure trailing \n
                    compiled += '\n'
            else:
                compiled = serializeCondensed(tree, format_)
            cache.write(cacheId, compiled)

        return compiled
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:47,代码来源:MClassCode.py


示例12: getTree

    def getTree(self, fileId, variants=None):
        fileEntry = self._classes[fileId]
        filePath = fileEntry["path"]

        if variants:
            cacheId = "tree-%s-%s" % (filePath, util.toString(variants))
        else:
            cacheId = "tree-%s" % filePath

        tradeSpaceForSpeed = False  # Caution: setting this to True seems to make builds slower, at least on some platforms!?

        tree = self._cache.read(cacheId, filePath, memory=tradeSpaceForSpeed)
        if tree != None:
            return tree

        # Lookup for unoptimized tree
        if variants != None:
            tree = self._cache.read("tree-%s" % fileId, filePath, memory=tradeSpaceForSpeed)

        # Tree still undefined?, create it!
        if tree == None:
            self._console.debug("Parsing file: %s..." % fileId)
            self._console.indent()

            fileContent = filetool.read(fileEntry["path"], fileEntry["encoding"])
            tokens = tokenizer.parseStream(fileContent, fileId)
            
            self._console.outdent()
            self._console.debug("Generating tree: %s..." % fileId)
            self._console.indent()
            tree = treegenerator.createSyntaxTree(tokens)  # allow exceptions to propagate

            # store unoptimized tree
            self._cache.write("tree-%s" % fileId, tree, memory=tradeSpaceForSpeed, writeToFile=True)

            self._console.outdent()

        # Call variant optimizer
        if variants != None:
            self._console.debug("Selecting variants: %s..." % fileId)
            self._console.indent()
            variantoptimizer.search(tree, variants, fileId)
            self._console.outdent()
            # store optimized tree
            self._cache.write(cacheId, tree, memory=tradeSpaceForSpeed, writeToFile=True)

        return tree
开发者ID:flomotlik,项目名称:grails-qooxdoo,代码行数:47,代码来源:TreeLoader.py


示例13: sortClassesRecurser

        def sortClassesRecurser(classId, classListSorted, path):
            if classId in classListSorted:
                return

            # reading dependencies
            if classId == "qx.core.Environment":
                envObj = self._classesObj["qx.core.Environment"]
                envTreeId = "tree-%s-%s" % (envObj.path, util.toString({}))  # TODO: {} is a temp. hack
                self._cache.remove(
                    envTreeId
                )  # clear pot. memcache, so already (string) optimized tree is not optimized again (e.g. with Demobrowser)
            deps, cached = self.getCombinedDeps(classId, variants, buildType)

            if self._console.getLevel() is "info":
                self._console.dot("%s" % "." if cached else "*")

            # path is needed for recursion detection
            if not classId in path:
                path.append(classId)

            # process loadtime requirements
            for dep in deps["load"]:
                dep_name = dep.name
                if dep_name in classList and not dep_name in classListSorted:
                    if dep_name in path:
                        self._console.warn("Detected circular dependency between: %s and %s" % (classId, dep_name))
                        self._console.indent()
                        self._console.debug("currently explored dependency path: %r" % path)
                        self._console.outdent()
                        raise RuntimeError("Circular class dependencies")
                    else:
                        sortClassesRecurser(dep_name, classListSorted, path)

            if not classId in classListSorted:
                # remove element from path
                path.remove(classId)

                # print "Add: %s" % classId
                classListSorted.append(classId)

            return
开发者ID:unify,项目名称:qooxdoo,代码行数:41,代码来源:DependencyLoader.py


示例14: getTree

    def getTree(self, fileId, variants=None):
        fileEntry = self._classes[fileId]
        filePath = fileEntry["path"]

        if variants:
            cacheId = "tree-%s-%s" % (filePath, util.toString(variants))
        else:
            cacheId = "tree-%s" % filePath

        tree = self._cache.read(cacheId, filePath)
        if tree != None:
            return tree

        # Lookup for unoptimized tree
        if variants != None:
            tree = self._cache.read("tree-%s" % fileId, filePath)

        # Tree still undefined?, create it!
        if tree == None:
            self._console.debug("Parsing file: %s..." % fileId)
            self._console.indent()

            fileContent = filetool.read(fileEntry["path"], fileEntry["encoding"])
            tokens = tokenizer.parseStream(fileContent, fileId)
            
            self._console.outdent()
            self._console.debug("Generating tree: %s..." % fileId)
            self._console.indent()

            try:
                tree = treegenerator.createSyntaxTree(tokens)
            except treegenerator.SyntaxException, detail:
                self._console.error("%s" % detail)
                sys.exit(1)

            self._console.outdent()
            self._console.debug("Selecting variants: %s..." % fileId)
            self._console.indent()
开发者ID:mikegr,项目名称:lectorious-grails-qooxdoo,代码行数:38,代码来源:TreeLoader.py


示例15: getTranslation

    def getTranslation(self, fileId, variants):
        fileEntry = self._classes[fileId]
        filePath = fileEntry["path"]

        variantsId = util.toString(variants)

        cacheId = "translation-%s-%s" % (filePath, variantsId)

        translation = self._cache.readmulti(cacheId, filePath)
        if translation != None:
            return translation

        self._console.debug("Looking for translation strings: %s..." % fileId)
        self._console.indent()

        tree = self._treeLoader.getTree(fileId, variants)

        try:
            translation = self._findTranslationBlocks(tree, [])
        except NameError, detail:
            self._console.error("Could not extract translation from %s!" % fileId)
            self._console.error("%s" % detail)
            sys.exit(1)
开发者ID:mikegr,项目名称:lectorious-grails-qooxdoo,代码行数:23,代码来源:Locale.py


示例16: getTranslation

    def getTranslation(self, fileId, variants):
        fileEntry = self._classes[fileId]
        filePath = fileEntry["path"]

        classVariants     = self._classesObj[fileId].classVariants()
        relevantVariants  = Class.projectClassVariantsToCurrent(classVariants, variants)
        variantsId        = util.toString(relevantVariants)

        cacheId = "translation-%s-%s" % (filePath, variantsId)

        translation = self._cache.readmulti(cacheId, filePath)
        if translation != None:
            return translation

        self._console.debug("Looking for translation strings: %s..." % fileId)
        self._console.indent()

        #tree = self._treeLoader.getTree(fileId, variants)
        tree = self._classesObj[fileId].tree(variants)

        try:
            translation = self._findTranslationBlocks(tree, [])
        except NameError, detail:
            raise RuntimeError("Could not extract translation from %s!\n%s" % (fileId, detail))
开发者ID:mengu,项目名称:grooxdoo,代码行数:24,代码来源:Locale.py


示例17: getTreeCacheId

 def getTreeCacheId(optimize=[], variantSet={}):
     classVariants = self.classVariants()
     relevantVariants = self.projectClassVariantsToCurrent(classVariants, variantSet)
     return "tree-%s-%s-%s" % (self.path, self._optimizeId(optimize), util.toString(relevantVariants))
开发者ID:w495,项目名称:acv,代码行数:4,代码来源:MClassCode.py


示例18: classlistFromClassRecursive

        def classlistFromClassRecursive(depsItem, excludeWithDeps, variants, result, warn_deps, loadDepsChain, allowBlockLoaddeps=True):
            # support blocking
            if depsItem.name in excludeWithDeps:
                if depsItem.isLoadDep and not allowBlockLoaddeps:
                    raise DependencyError()
                return

            # check if already in
            if depsItem.name in resultNames:  # string compares are perceivably faster than object compares (as DependencyItem defines __eq__)
                return

            # Handle qx.core.Environment
            if depsItem.name == "qx.core.Environment" and firstTime[0]:
                envObj = self._classesObj["qx.core.Environment"]
                envTreeId = "tree-%s-%s" % (envObj.path, util.toString({})) # TODO: {} is a temp. hack
                self._cache.remove(envTreeId)  # clear pot. memcache, so already (string) optimized tree is not optimized again (e.g. with Demobrowser)
                firstTime[0] = False

            # reading dependencies
            self._console.debug("Gathering dependencies: %s" % depsItem.name)
            self._console.indent()
            deps, cached = self.getCombinedDeps(depsItem.name, variants, buildType, genProxy=genProxyIter.next())
            self._console.outdent()
            if logInfos: self._console.dot("%s" % "." if cached else "*")

            # and evaluate them
            deps["warn"] = self._checkDepsAreKnown(deps)  # add 'warn' key to deps
            ignore_names = [x.name for x in deps["ignore"]]
            if verifyDeps:
                for dep in deps["warn"]:
                    if dep.name not in ignore_names:
                        warn_deps.append(dep)

            # process lists
            try:
                skipNames = [x.name for x in deps["warn"] + deps["ignore"]]

                # cycle detection
                assert depsItem.name not in loadDepsChain
                loadDepsChain.append(depsItem.name)
  
                for subitem in deps["load"]:
                    # cycle check
                    if subitem.name in loadDepsChain:
                        self._console.warn("Detected circular dependency between: %s and %s" % (depsItem.name, subitem.name))
                        self._console.indent()
                        self._console.debug("currently explored dependency path: %r" % loadDepsChain)
                        self._console.outdent()
                        raise RuntimeError("Circular class dependencies")
                    if subitem.name not in resultNames and subitem.name not in skipNames:
                        classlistFromClassRecursive(subitem, excludeWithDeps, variants, result, warn_deps, loadDepsChain, allowBlockLoaddeps)

                ##
                # putting this here allows sorting and expanding of the class
                # list in one go!
                if depsItem.name not in resultNames:
                    result.append(depsItem)
                    resultNames.append(depsItem.name)
                
                # cycle check
                loadDepsChain.remove(depsItem.name)

                for subitem in deps["run"]:
                    if subitem.name not in resultNames and subitem.name not in skipNames:
                        classlistFromClassRecursive(subitem, excludeWithDeps, variants, result, warn_deps, [], allowBlockLoaddeps)

            except DependencyError, detail:
                raise ValueError("Attempt to block load-time dependency of class %s to %s" % (depsItem.name, subitem.name))
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:68,代码来源:DependencyLoader.py


示例19: DependencyItem

                # calculate class list recursively
                for item in includeWithDeps:
                    depsItem = DependencyItem(item, '', '|config|')
                    # calculate dependencies and add required classes
                    classlistFromClassRecursive(depsItem, excludeWithDeps, variants, result, warn_deps, [], allowBlockLoaddeps)
                    #classlistFromClassIterative(depsItem, excludeWithDeps, variants, result, warn_deps, [], allowBlockLoaddeps)

                self._console.dotclear()
                #print len(result),"  ",

                # process qx.core.Environment
                if ("qx.core.Environment" in resultNames 
                    and "variants" in script.optimize
                    and not processedEnvironment):
                    envObj = self._classesObj["qx.core.Environment"]
                    envTreeId = "tree-%s-%s" % (envObj.path, util.toString({})) # TODO: {} is a temp. hack
                    compOpts = CompileOptions(optimize=[], variants=variants)
                    compOpts.allClassVariants = script.classVariants([self._classesObj[x] for x in resultNames])
                    tree = Class.optimizeEnvironmentClass(envObj, compOpts)
                    self._cache.write(envTreeId, tree, memory=True, writeToFile=False)
                    # this is for the side-effect of leaving a modified tree for qx.core.Environmet
                    # in the cache!
                    _ = envObj.dependencies(variants, force=True)
                    # this is for the side-effect of re-calculating the transitive dependencies
                    # of qx.core.Environment!
                    processedEnvironment = True
                else:
                    # We currently know that one additional iteration is enough,
                    # after optimizeEnvironmentClass() has run. This has to do
                    # with the fact that it only removes dependencies to
                    # qx.bom.client.* classes, which in turn do not use
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:31,代码来源:DependencyLoader.py


示例20: dependencies


#.........这里部分代码省略.........
                load.append(dep)
            run_hint_names = [str(x) for x in run_hints]
            for dep in run1:
                if str(dep) in run_hint_names and not run_feature_checks:
                    console.warn("%s: @use(%s) is auto-detected" % (self.id, dep))
                run.append(dep)
            ignore.extend(ignore1)

            console.outdent()

            # Build data structure
            deps = {
                "load"   : load,
                "run"    : run,
                "ignore" : ignore,
            }

            return deps


        def buildTransitiveDeps(shallowDeps):
            newLoad = set(shallowDeps['load'])
            classMaps = {}
            for dep in shallowDeps['load']:
                if dep.needsRecursion:
                    recDeps = self.getTransitiveDeps(dep, variantSet, classMaps, force=force)  # need variantSet here (not relevantVariants), as the recursive deps might depend on any of those
                    for recdep in recDeps:
                        recdep.isLoadDep = True # all these become load dependencies
                    newLoad.update(recDeps)
            shallowDeps['load'] = list(newLoad)

            return shallowDeps


        ##
        # Check wether load dependencies are fresh which are included following
        # a depsItem.needsRecursion of the current class
        def transitiveDepsAreFresh(depsStruct, cacheModTime):
            result = True
            if cacheModTime is None:  # TODO: this can currently only occur with a Cache.memcache result
                result = False
            else:
                for dep in depsStruct["load"]:
                    if dep.requestor != self.id: # this was included through a recursive traversal
                        if dep.name in ClassesAll:
                            classObj = ClassesAll[dep.name]
                            if cacheModTime < classObj.m_time():
                            #if cacheModTime < classObj.library.mostRecentlyChangedFile()[1]:
                                console.debug("Invalidating dep cache for %s, as %s is newer" % (self.id, classObj.id))
                                result = False
                                break
                                # checking classObj.m_time() was done a lot, and was a major time consumer,
                                # esp. when building demobrowser; just checking a library's youngest entry is
                                # much faster, as it is only calculated once (when called without (force=True));
                                # the downside is that a change of one class in a library will result in cache
                                # invalidation for *all* classes in this lib; that's the trade-off;
                                # i'd love to just check the libs directly ("for lib in script.libraries: 
                                # if cacheModTime < lib.mostRecentlyChangedFile()[1]:..."), but I don't
                                # have access to the script here in Class.
            
            return result
        # -- Main ---------------------------------------------------------

        # handles cache and invokes worker function

        console = self.context['console']

        classVariants = self.classVariants()
        relevantVariants = self.projectClassVariantsToCurrent(classVariants, variantSet)
        cacheId = "deps-%s-%s" % (self.path, util.toString(relevantVariants))
        cached = True

        # try compile cache
        classInfo, classInfoMTime = self._getClassCache()
        (deps, cacheModTime) =  classInfo[cacheId] if cacheId in classInfo else (None,None)

        # try dependencies.json
        if (True  # just a switch
            and deps == None  
            # TODO: temp. hack to work around issue with 'statics' optimization and dependencies.json
            and 'statics' not in Context.jobconf.get("compile-options/code/optimize",[])
           ):
            deps_json, cacheModTime = self.library.getDependencies(self.id)
            if deps_json is not None:
                #console.info("using dependencies.json for: %s" % self.id)
                deps = self.depsItems_from_Json(deps_json)
                # don't cache at all, so later 'statics' optimized jobs don't
                # pick up the short depsList from cache

        if (deps == None
          or force == True
          or not transitiveDepsAreFresh(deps, cacheModTime)):
            cached = False
            deps = buildShallowDeps(tree)
            deps = buildTransitiveDeps(deps)
            if not tree: # don't cache for a passed-in tree
                classInfo[cacheId] = (deps, time.time())
                self._writeClassCache(classInfo)
        
        return deps, cached
开发者ID:AaronOpfer,项目名称:qooxdoo,代码行数:101,代码来源:MClassDependencies.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python warnings.warn函数代码示例发布时间:2022-05-27
下一篇:
Python run_cmd.call函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap