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


Python json.dumpsCode函数代码示例

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


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

示例1: _handleI18N

def _handleI18N(script, generator):
    context.console.info("Processing localisation data")
    context.console.indent()
    approot = context.jobconf.get("provider/app-root", "./provider")

    # get class projection
    class_list = []
    needs_cldr = False
    for classObj in script.classesObj:
        if passesOutputfilter(classObj.id):
            class_list.append(classObj.id)
            if not needs_cldr and classObj.getHints('cldr'):
                needs_cldr = True

    # get i18n data
    context.console.info("Getting translations")
    trans_dat = generator._locale.getTranslationData(class_list, script.variants, script.locales, 
                                                       addUntranslatedEntries=True)
    loc_dat   = None
    if needs_cldr:
        context.console.info("Getting CLDR data")
        loc_dat   = generator._locale.getLocalizationData(class_list, script.locales)


    # write translation and cldr files
    context.console.info("Writing localisation files: ", False)
    numTrans = len(trans_dat)
    for num,lang in enumerate(trans_dat):
        context.console.progress(num+1, numTrans)

        # translations
        transmap  = {}
        filename = "i18n-" + lang
        targetname = "i18n-" + lang
        translations = trans_dat[lang]
        for key in translations:
            if translations[key]:
                transmap[key] = [ { "target" : targetname, "data" : { key : translations[key] }} ]
            else:
                transmap[key] = [ ]
        filetool.save(approot+"/data/translation/"+filename+".json", json.dumpsCode(transmap))
        
        # cldr
        localemap = {}
        filename = "locale-" + lang
        targetname = "locale-" + lang
        if loc_dat:
            # sample: { "cldr" : [ { "target" : "locale-en", "data" : {"alternativeQuotationEnd":'"', "cldr_am": "AM",...}} ]}
            localekeys = loc_dat[lang]
            cldr_entry = [ { "target" : targetname, "data" : { }} ]
            for key in localekeys:
                if localekeys[key]:
                    cldr_entry[0]['data'][key] = localekeys[key]
            localemap['cldr'] = cldr_entry
            filetool.save(approot+"/data/locale/"+filename+".json", json.dumpsCode(localemap))

    context.console.outdent()
    return
开发者ID:dominikg,项目名称:qooxdoo,代码行数:58,代码来源:CodeProvider.py

示例2: loaderPackages

 def loaderPackages(script, compConf):
     packagemap = {}
     for package in script.packages:
         packageentry = {}
         packagemap[package.id] = packageentry
         packageentry['uris'] = package.files
     return json.dumpsCode(packagemap)
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:7,代码来源:CodeGenerator.py

示例3: _handleResources

def _handleResources(script, generator, filtered=True):

    def createResourceInfo(res, resval):
        resinfo = [ { "target": "resource", "data": { res : resval }} ]
        #filetool.save(approot+"/data/resource/" + res + ".json", json.dumpsCode(resinfo))
        return resinfo

    def copyResource(res, library):
        sourcepath = os.path.join(library._resourcePath, res)
        targetpath = approot + "/resource/" + res
        filetool.directory(os.path.dirname(targetpath))
        shutil.copy(sourcepath, targetpath)
        return

    # ----------------------------------------------------------------------
    context.console.info("Processing resources: ", False)
    approot = context.jobconf.get("provider/app-root", "./provider")
    filetool.directory(approot+"/data")
    filetool.directory(approot+"/resource")
    
    # quick copy of runLogResources, for fast results
    packages   = script.packagesSorted()
    parts      = script.parts
    variants   = script.variants

    allresources = {}
    if filtered:
        # -- the next call is fake, just to populate package.data.resources!
        _ = generator._codeGenerator.generateResourceInfoCode(script, generator._settings, context.jobconf.get("library",[]))
        for packageId, package in enumerate(packages):
            allresources.update(package.data.resources)
    else:
        # get the main library
        mainlib = [x for x in script.libraries if x.namespace == script.namespace][0]
        reslist = mainlib.getResources()
        allresources = ResourceHandler.createResourceStruct(reslist, updateOnlyExistingSprites = False)

    # get resource info
    resinfos = {}
    numResources = len(allresources)
    for num,res in enumerate(allresources):
        context.console.progress(num+1, numResources)
        # fake a classId-like resourceId ("a.b.c"), for filter matching
        resId = os.path.splitext(res)[0]
        resId = resId.replace("/", ".")
        if filtered and not passesOutputfilter(resId):
            continue
        resinfos[res] = createResourceInfo(res, allresources[res])
        # extract library name space
        if isinstance(allresources[res], types.ListType): # it's an image = [14, 14, u'png', u'qx' [, u'qx/decoration/Modern/checkradio-combined.png', 0, 0]]
            library_ns = allresources[res][3]
        else: # html page etc. = "qx"
            library_ns = allresources[res]
        if library_ns:  # library_ns == '' means embedded image -> no copying
            library    = libraries[library_ns]
            copyResource(res, library)

    filetool.save(approot+"/data/resource/resources.json", json.dumpsCode(resinfos))

    return
开发者ID:dominikg,项目名称:qooxdoo,代码行数:60,代码来源:CodeProvider.py

示例4: _handleI18N

def _handleI18N(script, generator):
    approot = context.jobconf.get("provider/app-root", "./provider")

    # get class projection
    class_list = []
    needs_cldr = False
    for classObj in script.classesObj:
        if passesOutputfilter(classObj.id):
            class_list.append(classObj.id)
            if not needs_cldr and classObj.getMeta('cldr'):
                needs_cldr = True

    # get i18n data
    trans_dat = generator._locale.getTranslationData_1(class_list, script.variants, script.locales, 
                                                       addUntranslatedEntries=True)
    loc_dat   = None
    if needs_cldr:
        loc_dat   = generator._locale.getLocalizationData(class_list, script.locales)


    # write translation and cldr files
    for lang in trans_dat:
        filename = "i18n-" + lang

        # translations
        transmap  = {}
        translations = trans_dat[lang]
        for key in translations:
            if translations[key]:
                transmap[key] = [ { "target" : "i18n", "data" : { key : translations[key] }} ]
            else:
                transmap[key] = [ ]
        filetool.save(approot+"/data/translation/"+filename+".json", json.dumpsCode(transmap))
        
        # cldr
        localemap = {}
        if loc_dat:
            localekeys = loc_dat[lang]
            for key in localekeys:
                if localekeys[key]:
                    localemap[key] = [ { "target" : "i18n", "data" : { key : localekeys[key] }} ]
                else:
                    localemap[key] = [ ]
            filetool.save(approot+"/data/locale/"+filename+".json", json.dumpsCode(localemap))

    return
开发者ID:mengu,项目名称:grooxdoo,代码行数:46,代码来源:CodeProvider.py

示例5: loaderClosureParts

 def loaderClosureParts(script, compConf):
     cParts = {}
     bootPkgId = bootPackageId(script)
     for part in script.parts.values():
         closurePackages = [isClosurePackage(p, bootPkgId) for p in part.packages if p.id != bootPkgId] # the 'boot' package may be the only non-closure package
         if closurePackages and all(closurePackages):
             cParts[part.name] = True
     return json.dumpsCode(cParts)
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:8,代码来源:CodeGenerator.py

示例6: getPackageData

 def getPackageData(package):
     data = {}
     data["resources"]    = package.data.resources
     if not self._job.get("packages/i18n-as-parts", False):
         data["translations"] = package.data.translations
         data["locales"]      = package.data.locales
     data = json.dumpsCode(data)
     data += ';\n'
     return data
开发者ID:Wkasel,项目名称:qooxdoo,代码行数:9,代码来源:CodeGenerator.py

示例7: loaderScriptUris_1

 def loaderScriptUris_1(script, compConf):
     uris = []
     for package in script.packagesSorted():
         package_scripts = []
         uris.append(package_scripts)
         for script in package:
             script_entry = "%s:%s" % (libname, file_basename)
             package_scripts.append(script_entry)
     return json.dumpsCode(uris)
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:9,代码来源:CodeGenerator.py

示例8: CreateDemoData

def CreateDemoData(destdir):
    dist = os.path.join(destdir, demoDataFn)
    res = []
    ocategory = ""

    while True:
        (htmlFilePath, category, demo) = (yield)
        if htmlFilePath == None: break

        # init new category
        if category != ocategory:
            ocategory = category
            resCategory = {}
            res.append(resCategory)
            resCategory["classname"] = category
            resCatDemos = []
            resCategory["tests"]     = resCatDemos

        # init new demo
        resDemo = {}
        resCatDemos.append(resDemo)

        # get the tags
        jsitem = demo[0:demo.find("html")] + "js"
        jsfile = os.path.join(demosSourcePath, category, jsitem)
        tags = getTagsFromJsFile(jsfile)

        title = os.path.splitext(demo)[0]

        if "_" in title:
            basename, nr = title.split("_",1)
        else:
            basename, nr = (title, 0)

        title = title.replace("_", " ")

        resDemo["nr"]    = nr
        resDemo["title"] = title
        resDemo["name"]  = demo
        resDemo["tags"]  = list(tags)

    # Write demodata.js file
    if not os.path.exists(destdir):
      os.makedirs(destdir)

    content = json.dumpsCode(res)

    outputFile = codecs.open(dist, encoding="utf-8", mode="w", errors="replace")
    outputFile.write(content)
    outputFile.flush()
    outputFile.close()

    yield  # final yield to catch caller's .send(None)
开发者ID:vuuvv,项目名称:vshop1,代码行数:53,代码来源:gendata.py

示例9: loaderPartsMap

        def loaderPartsMap(script, compConf):
            partData = {}
            packages = script.packagesSorted()
            #print "packages: %r" % packages
            for part in script.parts:
                #partData[part] = script.parts[part].packagesAsIndices(packages)
                partData[part] = []
                for package in script.parts[part].packages:
                    partData[part].append(package.id)
                #print "part '%s': %r" % (part, script.parts[part].packages)
            partData = json.dumpsCode(partData)

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

示例10: _handleResources

def _handleResources(script, generator):

    def createResourceInfo(res, resval):
        resinfo = [ { "target": "resource", "data": { res : resval }} ]
        #filetool.save(approot+"/data/resource/" + res + ".json", json.dumpsCode(resinfo))
        return resinfo

    def copyResource(res, library):
        sourcepath = os.path.join(library['path'], library['resource'], res)
        targetpath = approot + "/resource/" + res
        filetool.directory(os.path.dirname(targetpath))
        shutil.copy(sourcepath, targetpath)
        return

    # ----------------------------------------------------------------------
    approot = context.jobconf.get("provider/app-root", "./provider")
    filetool.directory(approot+"/data")
    filetool.directory(approot+"/resource")
    
    # quick copy of runLogResources, for fast results
    packages   = script.packagesSortedSimple()
    parts      = script.parts
    variants   = script.variants

    allresources = {}
    # get resource info
    # -- the next call is fake, just to populate package.data.resources!
    _ = generator._codeGenerator.generateResourceInfoCode(script, generator._settings, context.jobconf.get("library",[]))
    for packageId, package in enumerate(packages):
        allresources.update(package.data.resources)
    
    resinfos = {}
    for res in allresources:
        # fake a classId-like resourceId ("a.b.c"), for filter matching
        resId = os.path.splitext(res)[0]
        resId = resId.replace("/", ".")
        if passesOutputfilter(resId):
            resinfos[res] = createResourceInfo(res, allresources[res])
            # extract library name space
            if isinstance(allresources[res], types.ListType): # it's an image = [14, 14, u'png', u'qx' [, u'qx/decoration/Modern/checkradio-combined.png', 0, 0]]
                library_ns = allresources[res][3]
            else: # html page etc. = "qx"
                library_ns = allresources[res]
            library    = libraries[library_ns]
            copyResource(res, library)

    filetool.save(approot+"/data/resource/resources.json", json.dumpsCode(resinfos))

    return
开发者ID:mengu,项目名称:grooxdoo,代码行数:49,代码来源:CodeProvider.py

示例11: runLogResources

def runLogResources(jobconf, script):
    if not isinstance(jobconf.get("log/resources", False), types.DictType):
        return
    console = Context.console
    packages = script.packagesSorted()

    console.info("Dumping resource info...");
    console.indent()

    allresources = {}
    # get resource info
    CodeGenerator.packagesResourceInfo(script) # populate package.data.resources
    for packageId, package in enumerate(packages):
        allresources.update(package.data.resources)

    file_ = jobconf.get("log/resources/file", "resources.json")
    filetool.save(file_, json.dumpsCode(allresources))
    console.outdent()

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

示例12: getDataString

 def getDataString():
     data  = self.packageData()
     return json.dumpsCode(data)
开发者ID:1and1,项目名称:qooxdoo,代码行数:3,代码来源:Package.py

示例13: generateLoader

        def generateLoader(script, compConf, globalCodes, bootCode='', ):

            self._console.info("Generate loader script")
            result = ""
            vals   = {}

            if not self._job.get("packages/i18n-with-boot", True):
                # remove I18N info from globalCodes, so they don't go into the loader
                globalCodes["Translations"] = {}
                globalCodes["Locales"]      = {}
            else:
                if script.buildType == "build":
                    # also remove them here, as this info is now with the packages
                    globalCodes["Translations"] = {}
                    globalCodes["Locales"]      = {}

            if not script.parts:
                return result

            # stringify data in globalCodes
            for entry in globalCodes:
                globalCodes[entry] = json.dumpsCode(globalCodes[entry])
                # undo damage done by simplejson to raw strings with escapes \\ -> \
                globalCodes[entry] = globalCodes[entry].replace('\\\\\\', '\\').replace(r'\\', '\\')  # " gets tripple escaped, therefore the first .replace()

            vals.update(globalCodes)

            if script.buildType =="build":
                vals["Resources"] = json.dumpsCode({})  # TODO: undo Resources from globalCodes!!!

            # Name of the boot part
            vals["Boot"] = loaderBootName(script, compConf)

            # Code (pot.) of the boot part
            vals["BootPart"] = loaderBootPart(script, compConf, bootCode)

            # Translate part information to JavaScript
            vals["Parts"] = loaderPartsMap(script, compConf)

            # Translate URI data to JavaScript
            #vals["Uris"] = loaderScriptUris(script, compConf)

            # Translate URI data to JavaScript
            vals["Packages"] = loaderPackages(script, compConf)

            # Add potential extra scripts
            vals["UrisBefore"] = loaderUrisBefore(script, compConf)

            # Add potential extra css
            vals["CssBefore"] = loaderCssBefore(script, compConf)

            # Whether boot package is inline
            vals["BootIsInline"] = loaderBootInline(script, compConf)
                
            # Closure package information
            vals["ClosureParts"] = loaderClosureParts(script, compConf)

            # Package Hashes
            #vals["PackageHashes"] = loaderPackageHashes(script, compConf)

            # Script hook for qx.$$loader.decodeUris() function
            vals["DecodeUrisPlug"] = loaderDecodeUrisPlug(script, compConf)
            
            # Enable "?nocache=...." for script loading?
            vals["NoCacheParam"] = loaderNocacheParam(script, compConf)

            # Locate and load loader template
            template, templatePath = loaderTemplate(script, compConf)

            # Fill template gives result
            try:
                result = loaderFillTemplate(vals, template)
            except KeyError, e:
                raise ValueError("Unknown macro used in loader template (%s): '%s'" % 
                                 (templatePath, e.args[0])) 
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:75,代码来源:CodeGenerator.py

示例14: loaderUrisBefore

 def loaderUrisBefore(script, compConf):
     urisBefore = []
     additional_scripts = self._job.get("add-script",[])
     for additional_script in additional_scripts:
         urisBefore.append(additional_script["uri"])
     return json.dumpsCode(urisBefore)
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:6,代码来源:CodeGenerator.py

示例15: loaderBootInline

 def loaderBootInline(script, compConf):
     return json.dumpsCode(inlineBoot(script, compConf))
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:2,代码来源:CodeGenerator.py


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