當前位置: 首頁>>代碼示例>>Python>>正文


Python IdScope.updateBeginId方法代碼示例

本文整理匯總了Python中vistrails.db.domain.IdScope.updateBeginId方法的典型用法代碼示例。如果您正苦於以下問題:Python IdScope.updateBeginId方法的具體用法?Python IdScope.updateBeginId怎麽用?Python IdScope.updateBeginId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vistrails.db.domain.IdScope的用法示例。


在下文中一共展示了IdScope.updateBeginId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Mashuptrail

# 需要導入模塊: from vistrails.db.domain import IdScope [as 別名]
# 或者: from vistrails.db.domain.IdScope import updateBeginId [as 別名]

#.........這裏部分代碼省略.........
                break
        if found:
            self.actionAnnotations.remove(found)
                   
    def getTagMap(self):
        """getTagMap() -> dict of tag:action_id"""
        tagMap = {}
        for a in self.actionAnnotations:
            if a.key == "__tag__":
                tagMap[a.value] = a.action_id
        return tagMap
    
    def addActionAnnotation(self, action_id, key, value, user, date):
        id = self.id_scope.getNewId("mashup_actionAnnotation")
        annot = ActionAnnotation(id=id, action_id=action_id, key=key,
                                 value=value, user=user, date=date)
        self.actionAnnotations.append(annot)


    ##########################################################################
    # Operators

    def __str__(self):
        """ __str__() -> str - Returns a string representation of itself """
        
        return ("(Mashuptrail id='%s' vtVersion='%s' actions='%s')@%X" %
                    (self.id,
                     self.vtVersion,
                     self.actions,
                     id(self)))
    
    ######################################################################
    ## Serialization and Unserialization
    ##                
#    def toXml(self, node=None):
#        """toXml(node: ElementTree.Element) -> ElementTree.Element
#           writes itself to xml
#        """
#
#        if node is None:
#            node = ElementTree.Element('mashuptrail')
#        
#        #set attributes
#        node.set('id', self.convert_to_str(self.id, 'uuid'))
#        node.set('vtVersion', self.convert_to_str(self.vtVersion,'long'))
#        node.set('version', self.convert_to_str(self.version, 'str'))
#        for action in self.actions:
#            child_ = ElementTree.SubElement(node, 'action')
#            action.toXml(child_)
#        for annot in self.annotations:
#            child_ = ElementTree.SubElement(node, 'actionAnnotation')
#            annot.toXml(child_)
#        return node
#    
#    @staticmethod
#    def fromXml(node):
#        if node.tag != 'mashuptrail':
#            debug.debug("node.tag != 'mashuptrail'")
#            return None
#        #read attributes
#        data = node.get('id', None)
#        id = Mashuptrail.convert_from_str(data, 'uuid')
#        data = node.get('vtVersion', None)
#        vtVersion = Mashuptrail.convert_from_str(data, 'long')
#        data = node.get('version', None)
#        version = Mashuptrail.convert_from_str(data, 'str')
#        actions = []
#        action_map = {}
#        annotations = []
#        for child in node.getchildren():
#            if child.tag == 'action':
#                action = Action.fromXml(child)
#                actions.append(action)
#                action_map[action.id] = action
#            elif child.tag == 'actionAnnotation':
#                annot = ActionAnnotation.fromXml(child)
#                annotations.append(annot)
#                
#        mtrail = Mashuptrail(id,vtVersion)
#        mtrail.version = version
#        mtrail.actions = actions
#        mtrail.actionMap = action_map
#        mtrail.annotations = annotations
#        mtrail.currentVersion = mtrail.getLatestVersion()
#        mtrail.updateIdScope()
#        return mtrail
    
    ######################################################################
    ## IdScope
    ##      
    def updateIdScope(self):
        for action in self.actions:
            self.id_scope.updateBeginId('mashup_action', action.id+1)
            for alias in action.mashup.alias_list:
                self.id_scope.updateBeginId('mashup_alias', alias.id+1)
                self.id_scope.updateBeginId('mashup_component', alias.component.id+1)
        for annotation in self.annotations:
            self.id_scope.updateBeginId('annotation', annotation.id+1)
        for aannotation in self.actionAnnotations:
            self.id_scope.updateBeginId('mashup_actionAnnotation', aannotation.id+1)
開發者ID:danielballan,項目名稱:VisTrails,代碼行數:104,代碼來源:mashup_trail.py


注:本文中的vistrails.db.domain.IdScope.updateBeginId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。