def categoryNode(self, parentNode, category, *categorizableContainers):  # pylint: disable=W0621
        def inCategorizableContainer(categorizable):
            for container in categorizableContainers:
                if categorizable in container:
                    return True
            return False
        node = self.baseCompositeNode(parentNode, category, 'category', self.categoryNode, 
                                      categorizableContainers)

        if category.isFiltered():
            node.attrib['filtered'] = str(category.isFiltered())
        if category.hasExclusiveSubcategories():
            node.attrib['exclusiveSubcategories'] = str(category.hasExclusiveSubcategories())
        if category.isGlobal():
            node.attrib['isGlobal'] = str(category.isGlobal())
        for eachNote in sortedById(category.notes()):
            self.noteNode(node, eachNote)
        for attachment in sortedById(category.attachments()):
            self.attachmentNode(node, attachment)
        # Make sure the categorizables referenced are actually in the 
        # categorizableContainer, i.e. they are not deleted
        categorizableIds = ' '.join([categorizable.id() for categorizable in \
            sortedById(category.categorizables()) if inCategorizableContainer(categorizable)])
        if categorizableIds:            
            node.attrib['categorizables'] = categorizableIds
        return node
Beispiel #2
0
    def categoryNode(self, category, *categorizableContainers):  # pylint: disable-msg=W0621
        def inCategorizableContainer(categorizable):
            for container in categorizableContainers:
                if categorizable in container:
                    return True
            return False

        node = self.baseCompositeNode(category, "category", self.categoryNode, categorizableContainers)
        if category.isFiltered():
            node.setAttribute("filtered", str(category.isFiltered()))
        if category.hasExclusiveSubcategories():
            node.setAttribute("exclusiveSubcategories", str(category.hasExclusiveSubcategories()))
        for eachNote in category.notes():
            node.appendChild(self.noteNode(eachNote))
        for attachment in category.attachments():
            node.appendChild(self.attachmentNode(attachment))
        # Make sure the categorizables referenced are actually in the
        # categorizableContainer, i.e. they are not deleted
        categorizableIds = " ".join(
            [
                categorizable.id()
                for categorizable in category.categorizables()
                if inCategorizableContainer(categorizable)
            ]
        )
        if categorizableIds:
            node.setAttribute("categorizables", categorizableIds)
        return node
Beispiel #3
0
 def categoryNode(self, category, *categorizableContainers):
     def inCategorizableContainer(categorizable):
         for container in categorizableContainers:
             if categorizable in container:
                 return True
         return False
     node = self.baseCompositeNode(category, 'category', self.categoryNode, 
                                   categorizableContainers)
     if category.isFiltered():
         node.setAttribute('filtered', str(category.isFiltered()))
     for note in category.notes():
         node.appendChild(self.noteNode(note))
     for attachment in category.attachments():
         node.appendChild(self.attachmentNode(attachment))
     # Make sure the categorizables referenced are actually in the 
     # categorizableContainer, i.e. they are not deleted
     categorizableIds = ' '.join([categorizable.id() for categorizable in \
         category.categorizables() if inCategorizableContainer(categorizable)])
     if categorizableIds:            
         node.setAttribute('categorizables', categorizableIds)
     return node
Beispiel #4
0
 def categoryNode(self, parentNode, category, *categorizableContainers):  # pylint: disable=W0621
     def inCategorizableContainer(categorizable):
         for container in categorizableContainers:
             if categorizable in container:
                 return True
         return False
     node = self.baseCompositeNode(parentNode, category, 'category', self.categoryNode, 
                                   categorizableContainers)
     if category.isFiltered():
         node.attrib['filtered'] = str(category.isFiltered())
     if category.hasExclusiveSubcategories():
         node.attrib['exclusiveSubcategories'] = str(category.hasExclusiveSubcategories())
     for eachNote in sortedById(category.notes()):
         self.noteNode(node, eachNote)
     for attachment in sortedById(category.attachments()):
         self.attachmentNode(node, attachment)
     # Make sure the categorizables referenced are actually in the 
     # categorizableContainer, i.e. they are not deleted
     categorizableIds = ' '.join([categorizable.id() for categorizable in \
         sortedById(category.categorizables()) if inCategorizableContainer(categorizable)])
     if categorizableIds:            
         node.attrib['categorizables'] = categorizableIds
     return node
Beispiel #5
0
 def attachmentImageIndex(self, category, which):
     return self.imageIndex['attachment'] if category.attachments() else -1