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


Python SimpleDateFormat.parseObject方法代码示例

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


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

示例1: processObjects

# 需要导入模块: from java.text import SimpleDateFormat [as 别名]
# 或者: from java.text.SimpleDateFormat import parseObject [as 别名]
def processObjects(allObjects, DateParsePattern):
    vector = ObjectStateHolderVector()
    iter = allObjects.iterator()
    #ciList = [[id, type, props]]
    ciList = []
    ciDict = {}
    createCi = 1
    while iter.hasNext():
        #attributes = [name, type, key, value]
        attributes = []
        objectElement = iter.next()
        mamId = objectElement.getAttribute('mamId').getValue()
        cit = objectElement.getAttribute('name').getValue()
        if mamId != None and cit != None:
            # add the attributes...
            allAttributes = objectElement.getChildren('field')
            iterAtt = allAttributes.iterator()
            while iterAtt.hasNext():
                attElement = iterAtt.next()
                attName = attElement.getAttribute('name').getValue()
                attType = attElement.getAttribute('datatype').getValue()
                attKey = attElement.getAttribute('key')
                attValue = attElement.getText()

                if attType == None or attType == "":
                    attType = "string"
                if attKey == None or attKey == "":
                    attKey = "false"
                else:
                    attKey = attKey.getValue()
                if attName != "" and attType != "": 
                    attributes.append([attName, attType, attKey, attValue])
                # create CI or not? Is key empty or none?
                if attKey == "true":
                    if attValue != None and attValue != "":
                        createCi = 1
                    else:
                        createCi = 0
            #info (concatenate("Id: ", mamId, ", Type: ", cit, ", Properties: ", attributes))
            if createCi == 1:
                ciList.append([mamId, cit, attributes])
                #ciDict[mamId] = [mamId, cit, attributes]
        #print "MAMID = ", mamId, ", CIT = ", cit, ", Attributes = ", attributes
    for ciVal in ciList:
        logger.info("\tAdding %s [%s] => [%s]" % (ciVal[1], ciVal[0], ciVal[2]) )
        id = ciVal[0]
        type = ciVal[1]
        osh = ObjectStateHolder(type)
        if ciVal[2] != None:
            props = ciVal[2]
            createContainer = 0
            containerOsh = None
            for prop in props: 
                if prop[0] == 'root_container' and prop[3] != "" and ciDict.has_key(prop[3]):
                    containerOsh = ciDict[prop[3]]
                    createContainer = 1
                if prop[1] == 'integer':
                    prop[3] and prop[3].isdigit() and osh.setIntegerAttribute(prop[0], prop[3]) 
                elif prop[1] == 'long': 
                    prop[3] and prop[3].isdigit() and osh.setLongAttribute(prop[0], prop[3])
                elif prop[1] == 'enum':
                    osh.setEnumAttribute(prop[0], int(prop[3]))
                elif prop[1] == 'boolean':
                    if str(prop[3]).lower == 'false':
                        osh.setBoolAttribute(prop[0], 0)
                    else:
                        osh.setBoolAttribute(prop[0], 1)
                elif prop[1] == 'date':
                    if DateParsePattern != None and DateParsePattern != "":
                        formatter = SimpleDateFormat(DateParsePattern)
                        osh.setDateAttribute(prop[0], formatter.parseObject(prop[3]))
                else:
                    osh.setAttribute(prop[0], prop[3]) 
            if createContainer == 1:
                osh.setContainer(containerOsh)
        vector.add(osh)
        ciDict[id] = osh
    return (vector, ciDict)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:80,代码来源:atrium_to_ucmdb.py


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