예제 #1
0
def vCard():
    return newFromBehavior('vcard', '3.0')
예제 #2
0
def iCalendar():
    return newFromBehavior('vcalendar', '2.0')
예제 #3
0
def iCalendar():
    return newFromBehavior('vcalendar', '2.0')
예제 #4
0
def vCard():
    return newFromBehavior('vcard', '3.0')
예제 #5
0
파일: ics_diff.py 프로젝트: long3841/gus
 def processComponentPair(leftComp, rightComp):
     """
     Return None if a match, or a pair of components including UIDs and
     any differing children.
     
     """        
     leftChildKeys = leftComp.contents.keys()
     rightChildKeys = rightComp.contents.keys()
     
     differentContentLines = []
     differentComponents = {}
     
     for key in leftChildKeys:
         rightList = rightComp.contents.get(key, [])
         if isinstance(leftComp.contents[key][0], Component):
             compDifference = processComponentLists(leftComp.contents[key],
                                                    rightList)
             if len(compDifference) > 0:
                 differentComponents[key] = compDifference
                 
         elif leftComp.contents[key] != rightList:
             differentContentLines.append((leftComp.contents[key],
                                           rightList))
             
     for key in rightChildKeys:
         if key not in leftChildKeys:
             if isinstance(rightComp.contents[key][0], Component):
                 differentComponents[key] = ([], rightComp.contents[key])
             else:
                 differentContentLines.append(([], rightComp.contents[key]))
     
     if len(differentContentLines) == 0 and len(differentComponents) == 0:
         return None
     else:
         left  = newFromBehavior(leftComp.name)
         right = newFromBehavior(leftComp.name)
         # add a UID, if one existed, despite the fact that they'll always be
         # the same
         uid = leftComp.getChildValue('uid')
         if uid is not None:
             left.add( 'uid').value = uid
             right.add('uid').value = uid
             
         for name, childPairList in differentComponents.iteritems():
             leftComponents, rightComponents = zip(*childPairList)
             if len(leftComponents) > 0:
                 # filter out None
                 left.contents[name] = filter(None, leftComponents)
             if len(rightComponents) > 0:
                 # filter out None
                 right.contents[name] = filter(None, rightComponents)
         
         for leftChildLine, rightChildLine in differentContentLines:
             nonEmpty = leftChildLine or rightChildLine
             name = nonEmpty[0].name
             if leftChildLine is not None:
                 left.contents[name] = leftChildLine
             if rightChildLine is not None:
                 right.contents[name] = rightChildLine
         
         return left, right