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


Python JsonSimple.writeArray方法代码示例

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


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

示例1: getCurationData

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import writeArray [as 别名]
    def getCurationData(self, oid):
        json = JsonObject()
        try:
            # Get the object from storage
            storage = self.Services.getStorage()
            object = storage.getObject(oid)

            # Find the package payload
            payload = object.getPayload("metadata.json")
            # Not found?
            if payload is None:
                self.log.error(" * detail.py => Can't find package data!")
                json.put("error", True)
                return json

            # Parse the data
            data = JsonSimple(payload.open())
            payload.close()

            # Return it
            json.put("error", False)
            json.put("relationships", data.writeArray("relationships"))
            return json
        except StorageException, ex:
            self.log.error(" * detail.py => Storage Error accessing data: ", ex)
            json.put("error", True)
            return json
开发者ID:Paul-Nguyen,项目名称:mint,代码行数:29,代码来源:detail.py

示例2: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import writeArray [as 别名]
    def __activate__(self, context):
        self.request = context["request"]
        self.response = context["response"]
        self.formData = context["formData"]
        self.log = context["log"]

        # Basic response text
        message = JsonSimple()
        self.metadata = message.writeObject(["metadata"])
        self.results  = message.writeArray(["results"])

        # Prepare response Object
        format = self.formData.get("format")
        if format == "json":
            out = self.response.getPrintWriter("application/json; charset=UTF-8")
        else:
            out = self.response.getPrintWriter("text/plain; charset=UTF-8")

        # Success Response
        try:
            self.searchNla()
            out.println(message.toString(True))
            out.close()

        except Exception, ex:
            self.log.error("Error during search: ", ex)

            self.response.setStatus(500)
            message = JsonSimple()
            message.getJsonObject().put("error", ex.getMessage())
            out.println(message.toString(True))
            out.close()
开发者ID:Paul-Nguyen,项目名称:mint,代码行数:34,代码来源:nlaLookup.py

示例3: __upgrade

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import writeArray [as 别名]
    def __upgrade(self, formData):
        # These fields are handled specially
        ignoredFields = ["metaList", "redbox:formVersion", "redbox:newForm"]

        # Prepare a new JSON setup for upgraded data
        newJsonSimple = JsonSimple()
        newJsonObject = newJsonSimple.getJsonObject()
        metaList = newJsonSimple.writeArray(["metaList"])

        oldJsonObject = formData.getJsonObject()
        for key in oldJsonObject.keySet():
            oldField = str(key)
            if oldField not in ignoredFields:
                newField = self.__parseFieldName(oldField)
                metaList.add(newField)
                newJsonObject.put(newField, oldJsonObject.get(key))

        # Form management
        newJsonObject.put("redbox:formVersion", self.redboxVersion)
        newForm = oldJsonObject.get("redbox:newForm")
        if newForm is not None:
            newJsonObject.put("redbox:newForm", newForm)

        #########
        # Some final custom modifications more complicated than most fields
        #########

        # Old URL checkbox 'on' equals new ID Origin 'internal'
        urlOrigin = oldJsonObject.get("url_useRecordId")
        if urlOrigin is not None and urlOrigin == "on":
            newJsonObject.put("dc:identifier.redbox:origin", "internal")

        # Related data should default to being unlinked if from legacy forms
        counter = 1
        template = "dc:relation.vivo:Dataset"
        newIdField = "%s.%s.dc:identifier" % (template, counter)
        while newJsonObject.containsKey(newIdField):
            newOriginField = "%s.%s.redbox:origin" % (template, counter)
            newJsonObject.put(newOriginField, "external")
            newPublishField = "%s.%s.redbox:publish" % (template, counter)
            newJsonObject.put(newPublishField, "off")
            counter += 1
            newIdField = "%s.%s.dc:identifier" % (template, counter)

        self.audit.add("Migration tool. Version upgrade performed '%s' => '%s'" % (self.version, self.redboxVersion))
        return newJsonSimple
开发者ID:andrewbrazzatti,项目名称:redbox-core-dev-build,代码行数:48,代码来源:redboxMigration1.5.py

示例4: getCurationData

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import writeArray [as 别名]
    def getCurationData(self, oid):
        json = JsonObject()
        try:
            # Get the object from storage
            storage = self.Services.getStorage()
            object = storage.getObject(oid)

            # Find the package payload
            payload = None
            pidList = object.getPayloadIdList()
            for pid in pidList:
                if (pid.endswith(".tfpackage")):
                    payload = object.getPayload(pid)
            # Not found?
            if payload is None:
                self.log.error(" * detail.py => Can't find package data!")
                json.put("error", True)
                return json

            # Parse the data
            data = JsonSimple(payload.open())
            payload.close()

            # Some basic cosmetic fixes
            relations = data.writeArray("relationships")
            for relation in relations:
                if not relation.containsKey("field"):
                    relation.put("field", "From Object "+relation.get("oid"))

            # Return it
            json.put("error", False)
            json.put("relationships", relations)
            return json
        except StorageException, ex:
            self.log.error(" * detail.py => Storage Error accessing data: ", ex)
            json.put("error", True)
            return json
开发者ID:ozej8y,项目名称:redbox,代码行数:39,代码来源:detail.py


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