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


Python json.dumps函数代码示例

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


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

示例1: _getCompileCommand

        def _getCompileCommand(clazz, variants, optimize, format_):

            def getToolBinPath():
                path = sys.argv[0]
                path = os.path.abspath(os.path.normpath(os.path.dirname(path)))
                return path

            m   = {}
            cmd = ""
            toolBinPath      = getToolBinPath()
            m['compilePath'] = os.path.join(toolBinPath, "compile.py -q")
            m['filePath']    = os.path.normpath(clazz.path)
            # optimizations
            optis = []
            for opti in optimize:
                optis.append("--" + opti)
            m['optimizations'] = " ".join(optis)
            # variants
            varis = []
            for vari in variants:
                varis.append("--variant=" + vari + ":" + json.dumps(variants[vari]))
            m['variants'] = " ".join(varis)
            m['cache'] = "-c " + self._cache._path  # Cache needs context object, interrupt handler,...
            # compile.py could read the next from privateoptimizer module directly
            m['privateskey'] = "--privateskey " + '"' + privateoptimizer.privatesCacheId + '"'

            cmd = "%(compilePath)s %(optimizations)s %(variants)s %(cache)s %(privateskey)s %(filePath)s" % m
            return cmd
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:28,代码来源:CodeGenerator.py

示例2: depsToFlareFile

    def depsToFlareFile(classDepsIter, depsLogConf):
        data = {}
        for (packageId, classId, depId, loadOrRun) in classDepsIter:
            if classId not in data:
                data[classId] = {}
                data[classId]['name'] = classId
                data[classId]["size"] = 1000
                data[classId]["imports"] = []

            if loadOrRun == 'load':
                data[classId]['imports'].append(depId)

        output = []
        for cid in data.keys():
            output.append(data[cid])

        file = depsLogConf.get('flare/file', "flare.json")
        console.info("Writing dependency data to file: %s" % file)
        pretty = depsLogConf.get('flare/pretty', None)
        if pretty:
            indent = 2
            separators = (', ', ': ')
        else:
            indent = None
            separators = (',', ':')
        filetool.save(file, json.dumps(output, sort_keys=True, indent=indent, separators=separators))

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

示例3: _expandString

    def _expandString(self, s, mapstr, mapbin):
        assert isinstance(s, types.StringTypes)
        if not Key.hasMacro(s):  # optimization: no macro -> return
            return s
        macro = ""
        sub   = ""
        possiblyBin = re.match(r'^\${(.*)}$', s)   # look for '${...}' as a bin replacement
        if possiblyBin:
            macro = possiblyBin.group(1)

        if macro and (macro in mapbin.keys()):
            replval = mapbin[macro]
            if isinstance(replval, types.DictType):
                sub = copy.deepcopy(replval)  # make sure macro values are not affected during value merges later
            else:
                sub = replval   # array references are ok for now
        else:
            templ = string.Template(s)
            # allow stringyfied value of bin macros to be spliced into result value
            mapall = mapstr.copy()
            mapall.update(dict((k,json.dumps(v)) for (k,v) in mapbin.items()))
            try:
                sub = templ.substitute(mapall)
            except KeyError, e:
                raise ValueError("Macro left undefined in job (%s): '%s'\n(might be from an included config)" % (self.name, e.args[0]))
开发者ID:AaronOpfer,项目名称:qooxdoo,代码行数:25,代码来源:Job.py

示例4: runFontMap

def runFontMap(jobconf, confObj):

    if not jobconf.get("font-map", False):
        return

    console = Context.console
    cache = Context.cache

    # Test for fontforge
    try:
        import fontforge
    except ImportError:
        console.error("Font map generation is not possible: fontforge is missing")
        return

    console.info("Generating font map...")
    console.indent()

    done = []

    fonts = jobconf.get("font-map/fonts", {})
    for font, fontspec in fonts.iteritems():
        alias = fontspec["alias"] or font.fontfamily

        if alias in done:
            continue
        done.append(alias);

        config = {
          "alias" : alias or font.fontfamily,
          "size" : fontspec["size"] or 48,
          "mapping" : {}
        }

        fo = fontforge.open(font)

        for glyph in fo:
            go = fo[glyph]
            if go.unicode > 0:
                config["mapping"][go.glyphname] = [go.unicode, round(go.width / float(go.vwidth), 3)]

        # store meta data for this font
        bname = os.path.basename(font)
        ri = bname.rfind('.')
        if ri > -1:
            bname = bname[:ri]
        bname += '.meta'
        meta_fname = os.path.join(os.path.dirname(font), bname)
        console.debug("writing meta file %s" % meta_fname)
        filetool.save(meta_fname, json.dumps(config, ensure_ascii=False, sort_keys=True))

    console.outdent()
    return
开发者ID:RemiHeugue,项目名称:qooxdoo,代码行数:53,代码来源:Resources.py

示例5: main

def main():
    apidata = {}
    apidata['type'] = 'doctree'
    apidata['children'] = []
    apidata['attributes'] = {}
    apidata['children'].append({
      "type":"packages","attributes":{},"children":[]  
    })
    filetool.directory(store_path)

    dirwalker = filetool.find(module_root, r'\.py$')

    for pyfile in dirwalker:
        #if os.stat(pyfile).st_size == 0:
        #    continue
        # get the file's api doc as json
        filejson = pyapi2json(pyfile)
        apipackage = file2package(pyfile, module_root)
        # and store it
        filetool.save(store_path+'/'+apipackage+'.json', filejson)
        # make an entry in apidata struct
        levels = apipackage.split('.')
        curr = apidata['children'][0]['children']
        for pos,level in enumerate(levels):
            if level not in (x['attributes']['name'] for x in curr if 'name' in x['attributes']):
                newentry = {
                    "children" : [],
                    "type" : "packages" if pos % 2 else "package",
                    "attributes" : {
                        "packageName" : ".".join(levels[:pos]),
                        "name" : level,
                        "fullName" : ".".join(levels[:pos+1])
                    }
                }
                if pos==len(levels)-1:
                    newentry["externalRef"] = True
                    #del newentry['children']
                    #newentry["type"] = "classes"
                    pass
                curr.append(newentry)
                curr = newentry['children']
            else:
                curr = [x['children'] for x in curr if x['attributes']['name']==level][0]
        

    # store apidata
    filetool.save(store_path+'/'+"apidata.json", json.dumps(apidata))
开发者ID:1and1,项目名称:qooxdoo,代码行数:47,代码来源:generator_api.py

示例6: runSimulation

def runSimulation(jobconf):
    console = Context.console
    console.info("Running Simulation...")

    argv    = []
    javaBin = "java"
    javaClassPath = "-cp"
    argv.extend((javaBin, javaClassPath))

    configClassPath = jobconf.get("simulate/java-classpath", [])
    qxSeleniumPath = jobconf.get("simulate/qxselenium-path", False)
    if qxSeleniumPath:
        configClassPath.append(qxSeleniumPath)

    classPathSeparator = ":"
    if util.getPlatformInfo()[0] == "Windows":
        classPathSeparator = ";"

    configClassPath = classPathSeparator.join(configClassPath)

    if "CYGWIN" in util.getPlatformInfo()[0]:
        configClassPath = "`cygpath -wp " + configClassPath + "`"

    argv.append(configClassPath)

    rhinoClass = jobconf.get("simulate/rhino-class", "org.mozilla.javascript.tools.shell.Main")
    runnerScript = jobconf.get("simulate/simulator-script")
    argv.extend((rhinoClass, runnerScript))

    cmd = " ".join(textutil.quoteCommandArgs(argv))

    settings = jobconf.get("environment", None)
    for key in settings:
        if type(settings[key]) == unicode:
            settings[key] = settings[key].replace(" ", "$")
    if settings:
        settings = json.dumps(settings, separators=(",", ":"))
        settings = settings.replace('"','\\"').replace("{", "\{").replace("}", "\}")
        settings = "settings=" + settings
        cmd += " " + settings

    console.debug("Selenium start command: " + cmd)
    shell = ShellCmd()
    shell.execute_logged(cmd, console, True)
开发者ID:AaronOpfer,项目名称:qooxdoo,代码行数:44,代码来源:Testing.py

示例7: printVariantInfo

        def printVariantInfo(variantSetNum, variants, variantSets, variantData):
            if len(variantSets) < 2:  # only log when more than 1 set
                return
            variantStr = json.dumps(variants,ensure_ascii=False)
            self._console.head("Processing variant set %s/%s" % (variantSetNum+1, len(variantSets)))

            # Debug variant combination
            hasVariants = False
            for key in variants:
                if len(variantData[key]) > 1:
                    hasVariants = True

            if hasVariants:
                self._console.info("Switched variants:")
                self._console.indent()
                for key in variants:
                    if len(variantData[key]) > 1:
                        self._console.info("%s = %s" % (key, variants[key]))
                self._console.outdent()

            return
开发者ID:concefly,项目名称:light,代码行数:21,代码来源:Generator.py

示例8: depsToJsonFile

    def depsToJsonFile(classDepsIter, depsLogConf):
        data = {}
        for (packageId, classId, depId, loadOrRun) in classDepsIter:
            if classId not in data:
                data[classId] = {}
                data[classId]["load"] = []
                data[classId]["run"] = []

            data[classId][loadOrRun].append(depId)

        file = depsLogConf.get('json/file', "deps.json")
        console.info("Writing dependency data to file: %s" % file)
        pretty = depsLogConf.get('json/pretty', None)
        if pretty:
            indent     = 2
            separators = (', ', ': ')
        else:
            indent     = None
            separators = (',', ':')
        filetool.save(file, json.dumps(data, sort_keys=True, indent=indent, separators=separators))

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

示例9: runImageCombining


#.........这里部分代码省略.........
            imageId   = altprefix + "/" + imageId

        imageId = Path.posifyPath(imageId)
        return imageId

    ##
    # create a dict with the clipped image file path as key, and prefix elements as value
    def getClippedImagesDict(imageSpec):
        imgDict = {}
        inputStruct = imageSpec['input']
        for group in inputStruct:
            prefixSpec = group.get('prefix', [])
            prefix, altprefix = extractFromPrefixSpec(prefixSpec)
            if prefix:
                prefix = confObj.absPath(prefix)
            for filepatt in group['files']:
                num_files = 0
                for file in glob.glob(confObj.absPath(filepatt)):  # resolve file globs - TODO: can be removed in generator.action.ImageClipping
                    console.debug("adding image %s" % file)
                    imgDict[file]    = [prefix, altprefix]
                    num_files       += 1
                if num_files == 0:
                    raise ValueError("Non-existing file spec: %s" % filepatt)

        return imgDict

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

    if not jobconf.get("combine-images", False):
        return
    
    console = Context.console
    cache = Context.cache

    console.info("Combining images...")
    console.indent()
    imageClipper = ImageClipping(console, cache, jobconf)

    images = jobconf.get("combine-images/images", {})
    for image, imgspec in images.iteritems():
        console.info("Creating image %s" % image)
        console.indent()
        imageId= getImageId(image, imgspec.get('prefix', []))
        image  = confObj.absPath(image)  # abs output path
        config = {}

        # create a dict of clipped image objects - for later look-up
        clippedImages = getClippedImagesDict(imgspec)

        # collect list of all input files, no matter where they come from
        input = sorted(clippedImages.keys())

        # collect layout property
        if 'layout' in imgspec:
            layout = imgspec['layout'] == "horizontal"
        else:
            layout = "horizontal" == "horizontal" # default horizontal=True

        # get type of combined image (png, base64, ...)
        combtype = "base64" if image.endswith(".b64.json") else "extension"

        # create the combined image
        subconfigs = imageClipper.combine(image, input, layout, combtype)

        # for the meta information, go through the list of returned subconfigs (one per clipped image)
        for sub in subconfigs:
            x = Image()
            x.combId, x.left, x.top, x.width, x.height, x.format = (
               imageId, sub['left'], sub['top'], sub['width'], sub['height'], sub['type'])
            subId = getImageId(sub['file'], clippedImages[sub['file']])
            config[subId] = x.toMeta()

        # store meta data for this combined image
        bname = os.path.basename(image)
        ri = bname.rfind('.')
        if ri > -1:
            bname = bname[:ri]
        bname += '.meta'
        meta_fname = os.path.join(os.path.dirname(image), bname)
        console.debug("writing meta file %s" % meta_fname)
        filetool.save(meta_fname, json.dumps(config, ensure_ascii=False, sort_keys=True))
        console.outdent()

        # handle base64 type, need to write "combined image" to file
        if combtype == "base64":
            combinedMap = {}
            for sub in subconfigs:
                subMap = {}
                subId  = getImageId(sub['file'], clippedImages[sub['file']])
                subMap['width']    = sub['width']
                subMap['height']   = sub['height']
                subMap['type']     = sub['type']
                subMap['encoding'] = sub['encoding']
                subMap['data']     = sub['data']
                combinedMap[subId] = subMap
            filetool.save(image, json.dumpsCode(combinedMap))

    console.outdent()

    return
开发者ID:choubayu,项目名称:qooxdoo,代码行数:101,代码来源:Resources.py

示例10: storeApi

    def storeApi(self, include, apiPath, variantSet, verify):
        self._console.info("Generating API data...")
        self._console.indent()

        docTree = tree.Node("doctree")
        length = len(include)

        self._console.info("Loading class docs...", False)
        self._console.indent()

        packages = []
        hasErrors = False
        for pos, fileId in enumerate(include):
            self._console.progress(pos+1, length)
            fileApi = self.getApi(fileId, variantSet)
            if fileApi == None:
                hasErrors = True
            
            # Only continue merging if there were no errors
            if not hasErrors:
                self._mergeApiNodes(docTree, fileApi)
                pkgId = self._classesObj[fileId].package
                # make sure all parent packages are included
                nsparts = pkgId.split('.')
                for i in range(len(nsparts)+1):
                    parentPkg = ".".join(nsparts[0:i])
                    if not parentPkg in packages:
                        packages.append(parentPkg)

        self._console.outdent()

        if hasErrors:
            self._console.error("Found erroneous API information. Please see above. Stopping!")
            return
                
        self._console.info("Loading package docs...")
        self._console.indent()
        
        packages.sort()
        for pkgId in packages:
            self._mergeApiNodes(docTree, self.getPackageApi(pkgId))

        self._console.outdent()

        self._console.info("Connecting classes...")
        api.connectPackage(docTree, docTree)

        self._console.info("Generating search index...")
        index = self.docTreeToSearchIndex(docTree, "", "", "")
        
        if verify and "links" in verify:
            self.verifyLinks(docTree, index)
        
        self._console.info("Saving data...", False)
        self._console.indent()

        packageData = api.getPackageData(docTree)
        packageJson = json.dumps(packageData)
        filetool.save(os.path.join(apiPath, "apidata.json"), packageJson)
        
        length = 0
        for classData in api.classNodeIterator(docTree):
            length += 1
            
        pos = 0
        for classData in api.classNodeIterator(docTree):
            pos += 1
            self._console.progress(pos, length)
            nodeData = tree.getNodeData(classData)
            nodeJson = json.dumps(nodeData)
            fileName = os.path.join(apiPath, classData.get("fullName") + ".json")
            filetool.save(fileName, nodeJson)
            
        self._console.outdent()
            
        self._console.info("Saving index...")
        indexContent = json.dumps(index, separators=(',',':'), sort_keys=True) # compact encoding
        filetool.save(os.path.join(apiPath, "apiindex.json"), indexContent)            

        self._console.outdent()
        self._console.info("Done")
开发者ID:leandrorchaves,项目名称:qooxdoo-1.x,代码行数:81,代码来源:ApiLoader.py

示例11: storeApi

    def storeApi(self, include, apiPath, variantSet, verify):
        self._console.info("Generating API data...")
        self._console.indent()

        docTree = tree.Node("doctree")
        docTree.set("fullName", "")
        docTree.set("name", "")
        docTree.set("packageName", "")
        length = len(include)

        self._console.info("Loading class docs...", False)
        self._console.indent()

        packages = []
        AttachMap = {}
        hasErrors = False
        for pos, fileId in enumerate(include):
            self._console.progress(pos+1, length)
            fileApi, attachMap = self.getApi(fileId, variantSet)
            if fileApi == None:
                hasErrors = True
            
            # Only continue merging if there were no errors
            if not hasErrors:
                # update AttachMap
                for cls in attachMap: # 'qx.Class', 'qx.core.Object', 'q', ...
                    if cls not in AttachMap:
                        AttachMap[cls] = attachMap[cls]
                    else:
                        for section in attachMap[cls]:  # 'statics', 'members'
                            if section not in AttachMap[cls]:
                                AttachMap[cls][section] = attachMap[cls][section]
                            else:
                                for method in attachMap[cls][section]:  # 'define', 'showToolTip', ...
                                    if method not in AttachMap[cls][section]:
                                        AttachMap[cls][section][method] = attachMap[cls][section][method]
                                    else:
                                        self._console.warn("Multiple @attach for same target '%s::%s#%s'." % (cls, section, method))

                self._mergeApiNodes(docTree, fileApi)
                pkgId = self._classesObj[fileId].package
                # make sure all parent packages are included
                nsparts = pkgId.split('.')
                for i in range(len(nsparts)+1):
                    parentPkg = ".".join(nsparts[0:i])
                    if not parentPkg in packages:
                        packages.append(parentPkg)

        self._console.outdent()

        if hasErrors:
            self._console.error("Found erroneous API information. Please see above. Stopping!")
            return
                
        self._console.info("Loading package docs...")
        self._console.indent()
        
        packages.sort()
        for pkgId in packages:
            self._mergeApiNodes(docTree, self.getPackageApi(pkgId))

        self._console.outdent()

        self._console.info("Connecting classes...")
        api.connectPackage(docTree, docTree)

        self._console.info("Generating search index...")
        index = self.docTreeToSearchIndex(docTree, "", "", "")
        
        if verify and "links" in verify:
            self.verifyLinks(docTree, index)
        
        self._console.info("Saving data...", False)
        self._console.indent()

        packageData = api.getPackageData(docTree)
        packageJson = json.dumps(packageData)
        filetool.save(os.path.join(apiPath, "apidata.json"), packageJson)

        # apply the @attach information
        for classData in api.classNodeIterator(docTree):
            className = classData.get("fullName")
            if className in AttachMap:
                self._applyAttachInfo(className, classData, AttachMap[className])
        
        # write per-class .json to disk
        length = 0
        for classData in api.classNodeIterator(docTree):
            length += 1
            
        pos = 0
        for classData in api.classNodeIterator(docTree):
            pos += 1
            self._console.progress(pos, length)
            nodeData = tree.getNodeData(classData)
            nodeJson = json.dumps(nodeData)
            fileName = os.path.join(apiPath, classData.get("fullName") + ".json")
            filetool.save(fileName, nodeJson)
            
        self._console.outdent()
#.........这里部分代码省略.........
开发者ID:bupthzd,项目名称:undergrad_thesis,代码行数:101,代码来源:ApiLoader.py

示例12: CreateDemoJson

def CreateDemoJson(dest, qxdir):
    source = []
    build  = []
    scategories = {}
    bcategories = {}

    # Pre-processing
    JSON = {}
    # top-level includes

    default_json = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])) , 'default.json')
    assert os.path.isfile(default_json)
    JSON['include'] = [{ "path" : "%s" % default_json }]

    # per-demo template file
    tmpl_json = os.path.join(os.path.dirname(sys.argv[0]) , 'tmpl.json')
    tmpl_manifest = os.path.join(os.path.dirname(sys.argv[0]) , TMPL_MANIFEST)
    tmpl_config = os.path.join(os.path.dirname(sys.argv[0]) , TMPL_CONFIG)

    json_tmpl = open(tmpl_json,"rU").read()

    demo_ns = "%s.demo" % namespace

    manifest_tmpl = json.loads(open(tmpl_manifest, 'rU').read())
    manifest_tmpl['provides']['namespace'] = demo_ns

    config_tmpl = json.loads(open(tmpl_config, 'rU').read())
    config_tmpl['let']['QOOXDOO_PATH'] = os.path.join('..', qxdir)
    config_tmpl['jobs']['source-demos']['let']['APPLICATION'] = demo_ns

    fn = os.path.basename(tmpl_manifest)[len('tmpl.'):] # file name
    open(os.path.join(dest, '..', '..', fn), 'w').write(json.dumps(manifest_tmpl, indent=2, sort_keys=True))

    fn = os.path.basename(tmpl_config)[len('tmpl.'):]
    open(os.path.join(dest, '..', '..', fn), 'w').write(json.dumps(config_tmpl, indent=2, sort_keys=True))

    # jobs section
    JSON['jobs'] = {}

    # allow exported jobs to be shadowed
    JSON['config-warnings'] = {}
    shadowed_jobs = []
    JSON['config-warnings']['job-shadowing'] = shadowed_jobs

    # Process demo html files
    while True:
        html = (yield)
        #print html
        if html == None:  # terminate the generator part and go to finalizing json file
            break

        category, name = demoCategoryFromFile(html)
        #print ">>> Processing: %s.%s..." % (category, name)

        # check for demo-specific config file
        config_file = os.path.splitext(html)[0] + ".json"
        if os.path.exists(config_file):
            JSON['include'].append({"path":"%s" % config_file})
            demo_config = json.loadStripComments(config_file)
            shadowed_jobs.extend(demo_config['export'])

        # build classname
        simple = "%s.%s" % (category,name)
        source.append("source-%s" % simple)
        build.append("build-%s" % simple)
        if not category in scategories:
            scategories[category] = []
        scategories[category].append("source-%s" % (simple,))
        if not category in bcategories:
            bcategories[category] = []
        bcategories[category].append("build-%s" % (simple,))

        # concat all
        currcont = json_tmpl.replace('XXX',"%s.%s"%(category,name)).replace("YYY",name).replace("ZZZ",category)
        templatejobs = json.loads("{" + currcont + "}")
        for job,jobval in templatejobs.iteritems():
            JSON['jobs'][job] = jobval

    # Post-processing
    for category in scategories:
        currentry = JSON['jobs']["source-%s" % category] = {}
        currentry['run'] = sorted(scategories[category])
        currentry = JSON['jobs']["build-%s" % category] = {}
        currentry['run'] = sorted(bcategories[category])

    JSON['jobs']["source"] = { "run" : sorted(source) }
    JSON['jobs']["build"]  = { "run" : sorted(build) }

    cont = '// This file is dynamically created by the generator!\n'
    cont += json.dumps(JSON, sort_keys=True, indent=2)
    filetool.save(os.path.join('demobrowser', fJSON), cont)

    yield  # final yield to provide for .send(None) of caller
开发者ID:plq,项目名称:qooxdoo,代码行数:93,代码来源:gendata.py

示例13: depsToProviderFormat

    def depsToProviderFormat(classDepsIter, depsLogConf):
        ##
        # duplicates CodeProvider.passesOutputFilter
        def passesOutputFilter(resId):
            # must match some include expressions
            if not filter(None, [x.search(resId) for x in inclregexps]):  # [None, None, _sre.match, None, _sre.match, ...]
                return False
            # must not match any exclude expressions
            if filter(None, [x.search(resId) for x in exclregexps]):
                return False
            return True

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

        inclregexps = jobconf.get("provider/include", ["*"])
        exclregexps = jobconf.get("provider/exclude", [])
        inclregexps = map(textutil.toRegExp, inclregexps)
        exclregexps = map(textutil.toRegExp, exclregexps)
        replace_dots = depsLogConf.get("json/replace-dots-in", [])
        slashes_keys = 'keys' in replace_dots
        slashes_vals = 'values' in replace_dots

        classToDeps = {}
        # Class deps
        for (packageId, classId, depId, loadOrRun) in classDepsIter:
            if passesOutputFilter(classId):
                if classId not in classToDeps:
                    classToDeps[classId] = {}
                    classToDeps[classId]["load"] = []
                    classToDeps[classId]["run"] = []
                if depId != None:
                    classToDeps[classId][loadOrRun].append(depId)

        if slashes_vals:
            # transform dep items
            for key, val in classToDeps.items():
                newval = []
                for ldep in val["load"]:
                    newdep = ldep.replace(".", "/")
                    newval.append(newdep)
                val["load"] = newval
                newval = []
                for ldep in val["run"]:
                    newdep = ldep.replace(".", "/")
                    newval.append(newdep)
                val["run"] = newval

        # Resource deps
        # class list
        classObjs = [x for x in script.classesObj if x.id in classToDeps.keys()]
        # map resources to class.resources
        classObjs = Class.mapResourcesToClasses(script.libraries, classObjs, jobconf.get("asset-let", {}))

        for clazz in classObjs:
            reskeys = ["/resource/resources#"+x.id for x in clazz.resources]
            classToDeps[clazz.id]["run"].extend(reskeys)

        # Message key deps
        for classId in classToDeps:
            #classKeys, _ = Locale.getTranslation(classId, {})
            classKeys, _ = script.classesAll[classId].messageStrings({})
            transIds  = set(x['id'] for x in classKeys) # get the msgid's, uniquely
            transIds.update(x['plural'] for x in classKeys if 'plural' in x) # add plural keys
            transKeys = ["/translation/i18n-${lang}#" + x for x in transIds]
            classToDeps[classId]["run"].extend(transKeys)

        # CLDR dependency
        for classId in classToDeps:
            if script.classesAll[classId].getHints("cldr"):
                classToDeps[classId]["run"].append("/locale/locale-${lang}#cldr")

        if slashes_keys:
            # transform dep keys ("qx.Class" -> "qx/Class.js")
            for key, val in classToDeps.items():
                if key.find(".")>-1:
                    newkey = key.replace(".", "/")
                    classToDeps[newkey] = classToDeps[key]
                    del classToDeps[key]

        # sort information for each class (for stable output)
        for classvals in classToDeps.values():
            for key in classvals:
                classvals[key] = sorted(classvals[key], reverse=True)

        # write to file
        file_ = depsLogConf.get('json/file', "deps.json")
        console.info("Writing dependency data to file: %s" % file_)
        pretty = depsLogConf.get('json/pretty', None)
        if pretty:
            indent     = 2
            separators = (', ', ': ')
        else:
            indent     = None
            separators = (',', ':')
        filetool.save(file_, json.dumps(classToDeps, sort_keys=True, indent=indent, separators=separators))

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

示例14: storeApi

    def storeApi(self, include, apiPath, variantSet, jobConf):
        self._console.info("Generating API data...")
        self._console.indent()

        docTree = tree.Node("doctree")
        docTree.set("fullName", "")
        docTree.set("name", "")
        docTree.set("packageName", "")
        length = len(include)

        self._console.info("Loading class docs...", False)
        self._console.indent()

        packages = []
        AttachMap = {}
        hasErrors = False
        for pos, fileId in enumerate(include):
            self._console.progress(pos+1, length)
            fileApi, attachMap = self.getApi(fileId, variantSet)
            if fileApi == None:
                hasErrors = True

            # Only continue merging if there were no errors
            if not hasErrors:
                # update AttachMap
                for cls in attachMap: # 'qx.Class', 'qx.core.Object', 'q', ...
                    if cls not in AttachMap:
                        AttachMap[cls] = attachMap[cls]
                    else:
                        for section in attachMap[cls]:  # 'statics', 'members'
                            if section not in AttachMap[cls]:
                                AttachMap[cls][section] = attachMap[cls][section]
                            else:
                                for method in attachMap[cls][section]:  # 'define', 'showToolTip', ...
                                    if method not in AttachMap[cls][section]:
                                        AttachMap[cls][section][method] = attachMap[cls][section][method]
                                    else:
                                        self._console.warn("Multiple @attach for same target '%s::%s#%s'." % (cls, section, method))

                self._mergeApiNodes(docTree, fileApi)
                pkgId = self._classesObj[fileId].package
                # make sure all parent packages are included
                nsparts = pkgId.split('.')
                for i in range(len(nsparts)+1):
                    parentPkg = ".".join(nsparts[0:i])
                    if not parentPkg in packages:
                        packages.append(parentPkg)

        self._console.outdent()

        if hasErrors:
            self._console.error("Found erroneous API information. Please see above. Stopping!")
            return

        self._console.info("Loading package docs...")
        self._console.indent()

        packages.sort()
        for pkgId in packages:
            self._mergeApiNodes(docTree, self.getPackageApi(pkgId))

        self._console.outdent()

        self._console.info("Connecting classes...  ", feed=False)
        api.connectPackage(docTree, docTree)
        self._console.dotclear()

        self._console.info("Generating search index...")
        index = self.docTreeToSearchIndex(docTree, "", "", "")

        if "verify" in jobConf:
            if "links" in jobConf["verify"]:
                api.verifyLinks(docTree, index)
            if "types" in jobConf["verify"]:
                api.verifyTypes(docTree, index)

        if "warnings" in jobConf and "output" in jobConf["warnings"]:
            api.logErrors(docTree, jobConf["warnings"]["output"])

        if "verify" in jobConf:
            if "statistics" in jobConf["verify"]:
                api.verifyDocPercentage(docTree)

        self._console.info("Saving data...", False)
        self._console.indent()

        packageData = api.getPackageData(docTree)
        packageJson = json.dumps(packageData)
        filetool.save(os.path.join(apiPath, "apidata.json"), packageJson)

        # apply the @attach information
        for classData in api.classNodeIterator(docTree):
            className = classData.get("fullName")
            if className in AttachMap:
                self._applyAttachInfo(className, classData, AttachMap[className])

        # write per-class .json to disk
        length = 0
        for classData in api.classNodeIterator(docTree):
            length += 1
#.........这里部分代码省略.........
开发者ID:RemiHeugue,项目名称:qooxdoo,代码行数:101,代码来源:ApiLoader.py

示例15: CreateDemoJson

def CreateDemoJson():

    source = []
    build  = []
    scategories = {}
    bcategories = {}

    # Pre-processing
    JSON = {}
    # top-level includes
    default_json = 'tool' + '/' + 'default.json'
    assert os.path.isfile(default_json)
    JSON['include'] = [{ "path" : "%s" % default_json }]

    # per-demo template file
    json_tmpl = open(os.path.join('tool','tmpl.json'),"rU").read()

    # jobs section
    JSON['jobs'] = {}

    # Process demo html files
    while True:
        html = (yield)
        #print html
        if html == None:  # terminate the generator part and go to finalizing json file
            break

        category, name = demoCategoryFromFile(html)
        #print ">>> Processing: %s.%s..." % (category, name)

        # check for demo-specific config file
        config_file = os.path.splitext(html)[0] + ".json"
        if os.path.exists(config_file):
            JSON['include'].append({"path":"%s" % config_file})

        # build classname
        simple = "%s.%s" % (category,name)
        source.append("source-%s" % simple)
        build.append("build-%s" % simple)
        if not category in scategories:
            scategories[category] = []
        scategories[category].append("source-%s" % (simple,))
        if not category in bcategories:
            bcategories[category] = []
        bcategories[category].append("build-%s" % (simple,))

        # concat all
        currcont = json_tmpl.replace('XXX',"%s.%s"%(category,name)).replace("YYY",name).replace("ZZZ",category)
        templatejobs = json.loads("{" + currcont + "}")
        for job,jobval in templatejobs.iteritems():
            JSON['jobs'][job] = jobval

    # Post-processing
    for category in scategories:
        currentry = JSON['jobs']["source-%s" % category] = {}
        currentry['run'] = sorted(scategories[category])
        currentry = JSON['jobs']["build-%s" % category] = {}
        currentry['run'] = sorted(bcategories[category])

    JSON['jobs']["source"] = { "run" : sorted(source) }
    JSON['jobs']["build"]  = { "run" : sorted(build) }

    cont = '// This file is dynamically created by the generator!\n'
    cont += json.dumps(JSON, sort_keys=True, indent=2)
    filetool.save(fJSON, cont)

    yield  # final yield to provide for .send(None) of caller
开发者ID:vuuvv,项目名称:vshop1,代码行数:67,代码来源:gendata.py


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