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
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
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