Ejemplo n.º 1
0
    def save(self, tree_name):
        tree = Building.save(self, tree_name)

        # Specify nature
        nature = etree.SubElement(tree, 'type')
        nature.text = 'shop'

        # Specify content
        items = etree.SubElement(tree, 'items')
        for it in self.items:
            item = etree.SubElement(items, 'item')
            name = etree.SubElement(item, 'name')
            name.text = it.name

        return tree
Ejemplo n.º 2
0
    def save(self, tree_name):
        tree = Building.save(self, tree_name)

        # Specify nature
        nature = etree.SubElement(tree, 'type')
        nature.text = 'shop'

        # Specify content
        items = etree.SubElement(tree, 'items')
        for entry in self.stock:
            item = etree.SubElement(items, 'item')

            name = etree.SubElement(item, 'name')
            name.text = entry['item'].name

            quantity = etree.SubElement(item, 'quantity')
            quantity.text = str(entry['quantity'])

        return tree