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


Python JsonSimple.getJsonSimpleMap方法代码示例

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


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

示例1: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import getJsonSimpleMap [as 别名]
class Epub:
    def __init__(self):
        pass

    def __activate__(self, context):
        self.velocityContext = context

        oid = self.vc("formData").get("oid")
        print "--- Creating ePub for: %s ---" % oid
        try:
            self.__epubMimetypeStream = None
            self.__epubContainerStream = None
            self.__epubcss = None
            self.__orderedItem = []
            self.__itemRefDict = {}
            # get the package manifest
            object = Services.getStorage().getObject(oid)
            sourceId = object.getSourceId()
            payload = object.getPayload(sourceId)
            self.__manifest = JsonSimple(payload.open())
            payload.close()
            object.close()
            # create the epub
            self.__getDigitalItems(self.__manifest.getJsonSimpleMap("manifest"))
            self.__createEpub()
        except Exception, e:
            log.error("Failed to create epub", e)
            self.vc("response").setStatus(500)
            writer = self.vc("response").getPrintWriter("text/plain; charset=UTF-8")
            writer.println(str(e))
            writer.close()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:33,代码来源:epub.py

示例2: __mergeData

# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import getJsonSimpleMap [as 别名]
 def __mergeData(self):
     
     requiredMetadata = ["format", "width", "height", "timeSpent", "size"]
     
     try:
         # ffmpeg.info data:
         ffmpegPayload = self.__object.getPayload("ffmpeg.info")
         ffmpegInfo = JsonSimple(ffmpegPayload.open())
         
         ffmpegOutput = ffmpegInfo.getJsonSimpleMap(["outputs"])
         
         map = JsonSimple()
         for key in ffmpegOutput.keySet():
             data = ffmpegOutput.get(key)
             detailMap = JsonSimple()
             for field in data.getJsonObject().keySet():
                 if field in requiredMetadata:
                     detailMap.getJsonObject().put(field, data.getString("", [field]))
             map.getJsonObject().put(key, detailMap)
         
         self.__metadata.getJsonObject().put("outputs", map)
         ffmpegPayload.close()
     except Exception, e:
         print str(e)
开发者ID:the-fascinator-contrib,项目名称:builds-media-repository,代码行数:26,代码来源:metadata.py

示例3: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import getJsonSimpleMap [as 别名]

#.........这里部分代码省略.........
            if object is not None:
                try:
                    payload = object.getPayload(pid)
                    return payload.getContentType()
                except:
                    pass
        return "unknown"

    def getRawFFmpeg(self):
        return self.makeHtml(self.__ffmpegRaw)

    def getSplashScreen(self, metadata, preference):
        #TODO - Proper checking that the prefered payload actually exists
        if preference is not None and preference != "":
            return preference

        # Fall back to the thumbnail if no preference was given
        thumbnail = metadata.get("thumbnail")
        if thumbnail is not None:
            return thumbnail
        return ""

    def getTranscodings(self):
        if self.__ffmpegOutputs is not None:
            return self.__ffmpegOutputs.keySet()
        else:
            return ArrayList()

    def isAudio(self, mime):
        return mime.startswith("audio/")

    def isVideo(self, mime):
        return mime.startswith("video/")

    # Turn a Python boolean into a javascript boolean
    def jsBool(self, pBool):
        if pBool:
            return "true"
        else:
            return "false"

    def makeHtml(self, input):
        input = input.replace(" ", " ")
        input = input.replace("\r\n", "<br/>")
        input = input.replace("\r", "<br/>")
        input = input.replace("\n", "<br/>")
        input = input.replace("\\r\\n", "<br/>")
        input = input.replace("\\r", "<br/>")
        input = input.replace("\\n", "<br/>")
        return input

    def niceSize(self, size):
        # Cast to a number
        size = eval(size)
        # Bytes
        if (size > 1000):
            # KBytes
            size = size / 1000;
            if (size > 1000):
                # MBytes
                size = size / 1000;
                if (size > 1000):
                    # GBytes
                    size = size / 1000;
                    return str(round(size, 1)) + "Gb"
                else:
                    return str(round(size, 1)) + "Mb"
            else:
                return str(round(size, 1)) + "Kb"
        else:
            return str(size) + "b"

    def parseFFmpeg(self, parent):
        if parent is not None:
            object = parent.getObject()
            if object is not None:
                payload = None
                try:
                    payload = object.getPayload("ffmpeg.info")
                    # Stream the content out to string
                    out = ByteArrayOutputStream()
                    IOUtils.copy(payload.open(), out)
                    payload.close()
                    self.__ffmpegRaw = out.toString("UTF-8")
                    out.close()
                    payload.close()
                    # And parse it
                    self.__ffmpegData = JsonSimple(self.__ffmpegRaw)
                    if self.__ffmpegData is None:
                        return False
                    else:
                        self.__ffmpegOutputs = self.__ffmpegData.getJsonSimpleMap(["outputs"])
                        return True
                except:
                    if payload is not None:
                        payload.close()
        return False
    
    def getUrlBase(self):
        return self.__urlBase
开发者ID:kiranba,项目名称:the-fascinator,代码行数:104,代码来源:detail.py

示例4: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import getJsonSimpleMap [as 别名]
class HeadData:
    def __init__(self):
        pass

    def __activate__(self, context):
        self.velocityContext = context
        self.__metadata = self.vc("metadata")
        self.__urlBase = None
        self.__ffmpegRaw = None
        self.__ffmpegData = None
        self.__ffmpegOutputs = None

    # Get from velocity context
    def vc(self, index):
        if self.velocityContext[index] is not None:
            return self.velocityContext[index]
        else:
            log.error("ERROR: Requested context entry '" + index + "' doesn't exist")
            return None

    def getBasicFFmpegData(self, index):
        if self.__ffmpegData is not None:
            output = self.__ffmpegData.getString(None, [index])
            if output is not None:
                return output
        return ""

    def getFFmpegData(self, pid, index):
        if self.__ffmpegOutputs is not None:
            output = self.__ffmpegOutputs.get(pid).getString(None, [index])
            if output is not None:
                return output
        return ""

    # Get The MIME Type of a payload
    def getMimeType(self, pid, parent):
        if parent is not None:
            object = parent.getObject()
            if object is not None:
                try:
                    payload = object.getPayload(pid)
                    return payload.getContentType()
                except:
                    pass
        return "unknown"

    def getTranscodings(self):
        pass

    def getRawFFmpeg(self):
        return self.__ffmpegRaw

    def getSplashScreen(self, metadata, preference):
        #TODO - Proper checking that the prefered payload actually exists
        if preference is not None and preference != "":
            return preference

        # Fall back to the thumbnail if no preference was given
        thumbnail = metadata.getFirst("thumbnail")
        if thumbnail is not None:
            return thumbnail
        return ""

    def isAudio(self, mime):
        return mime.startswith("audio/")

    def isVideo(self, mime):
        return mime.startswith("video/")

    # Turn a Python boolean into a javascript boolean
    def jsBool(self, pBool):
        if pBool:
            return "true"
        else:
            return "false"

    def parseFFmpeg(self, parent):
        if parent is not None:
            payload = None
            object = parent.getObject()
            if object is not None:
                try:
                    payload = object.getPayload("ffmpeg.info")
                    # Stream the content out to string
                    out = ByteArrayOutputStream()
                    IOUtils.copy(payload.open(), out)
                    payload.close()
                    self.__ffmpegRaw = out.toString("UTF-8")
                    out.close()
                    payload.close()
                    # And parse it
                    self.__ffmpegData = JsonSimple(self.__ffmpegRaw)
                    if self.__ffmpegData is None:
                        return False
                    else:
                        self.__ffmpegOutputs = self.__ffmpegData.getJsonSimpleMap(["outputs"])
                        return True
                except:
                    if payload is not None:
                        payload.close()
#.........这里部分代码省略.........
开发者ID:kiranba,项目名称:the-fascinator,代码行数:103,代码来源:head.py


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