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


Python JsonSimple.getJsonArray方法代码示例

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


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

示例1: getLabel

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getJsonArray [as 别名]
 def getLabel(self, jsonFile, key, listKey, valKey, labelKey):
     value = self.metadata.get(key)
     jsonLabelFile = System.getProperty("fascinator.home") + jsonFile
     jsonLabel = JsonSimple(File(jsonLabelFile))
     entries = jsonLabel.getJsonArray()
     # the structure of the json file is fun and complicated
     if entries is None:
         entries = jsonLabel.getArray(listKey)
     else:
         valKey = "value"
         labelKey = "label"
     for entry in entries:
         entryJson = JsonSimple(entry)
         if value == entryJson.getString("", valKey):
             return entryJson.getString("", labelKey)
     return None
开发者ID:nishen,项目名称:redbox,代码行数:18,代码来源:detail.py

示例2: getLabel

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getJsonArray [as 别名]
 def getLabel(self, jsonFile, key):
     value = self.metadata.get(key)
     jsonLabelFile = System.getProperty("fascinator.home") + jsonFile
     jsonF = JsonSimple(File(jsonLabelFile))
     entries = jsonF.getJsonArray()
     if entries is None:
         entries = jsonF.getArray('results')
         if entries is None:
             self.log.debug("Unknown data source format: JSON file {} or its 'results' has no array.", jsonLabelFile)
             return None
     
     for entry in entries:
         entryJson = JsonSimple(entry)
         if value == entryJson.getString("", "id"):
             return entryJson.getString("", "label")
         elif value == entryJson.getString("", "value"):
             return entryJson.getString("", "label")
         
     return None
开发者ID:ozej8y,项目名称:redbox,代码行数:21,代码来源:detail.py

示例3: __getPayloadJsonArray

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getJsonArray [as 别名]
 def __getPayloadJsonArray(self, oid, payloadName):
     """
     Get the content (JsonArray) of a payload
     return the JSONArray or an empty (new) one 
     """
     storedObj = self.Services.getStorage().getObject(oid)
     
     payloadList = storedObj.getPayloadIdList()
     if payloadList.contains(payloadName):
         # print "Updating existing"
         payloadObj = storedObj.getPayload(payloadName)
         payloadJson = JsonSimple(payloadObj.open())
         objList = payloadJson.getJsonArray()
     else:
         # print "Creating new one"
         objList = JSONArray()
     
     return objList
      
开发者ID:ozej8y,项目名称:redbox,代码行数:20,代码来源:attachments.py

示例4: __init__

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getJsonArray [as 别名]
class LaunchData:

    def __init__(self):
        pass
    def __activate__(self, context):
        self.log = context["log"]
        self.request = context["request"]
        self.sessionState = context["sessionState"]
        self.sessionState.set("username","admin")
        processingSet = self.request.getParameter("processingSet")
        self.procMsg = None
        # read configuration and trigger processing stream sets
        # storing the return object on the map
        configFilePath = FascinatorHome.getPath("process")+"/processConfig.json"
        procConfigFile = File(configFilePath)
        if procConfigFile.exists() == True:
            self.dataMap = HashMap()
            self.dataMap.put("indexer", context['Services'].getIndexer())
            self.procConfigJson = JsonSimple(procConfigFile)
            for configObj in self.procConfigJson.getJsonArray():
                configJson = JsonSimple(configObj)
                procId = configJson.getString("", "id")
                if processingSet is not None: 
                    if procId == processingSet:
                        self.execProcSet(procId, configJson)
                else:
                    self.execProcSet(procId, configJson)
            if self.procMsg is None:
                self.procMsg = "Processing complete!"
        else:
            self.procMsg = "Configuration file does not exist: " + configFilePath
            
    def execProcSet(self, procId, configJson):
        self.execProcessors(procId, configJson, self.dataMap, "pre")
        self.execProcessors(procId, configJson, self.dataMap, "process")
        self.execProcessors(procId, configJson, self.dataMap, "post")
        
    def execProcessors(self, procId, configJson, dataMap, stageName):
        for procObj in configJson.getArray(stageName):
            procJson = JsonSimple(procObj)
            procClassName = procJson.getString("", "class")
            procConfigPath = procJson.getString("", "config")
            
            procInputKey = procJson.getString("", "inputKey")
            procOutputKey = procJson.getString("", "outputKey")
            procClass = Class.forName(procClassName)
            procInst = procClass.newInstance()
            
            procMethod = procClass.getMethod("process", self.get_class("java.lang.String"),self.get_class("java.lang.String"), self.get_class("java.lang.String"),self.get_class("java.lang.String"),self.get_class("java.lang.String"), self.get_class("java.util.HashMap"))
            procMethod.invoke(procInst, procId, procInputKey, procOutputKey, stageName, procConfigPath, dataMap)
            
        
    # Standard Java Class forName seems to have issues at least with Interfaces. 
    # This is an alternative method taken from http://stackoverflow.com/questions/452969/does-python-have-an-equivalent-to-java-class-forname    
    def get_class(self, kls):
        parts = kls.split('.')
        module = ".".join(parts[:-1])
        m = __import__( module )
        for comp in parts[1:]:
            m = getattr(m, comp)            
        return m    
    
    def getProcMsg(self):
        return self.procMsg
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:66,代码来源:launch.py


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