Ejemplo n.º 1
0
 def test_spread_nodes(self):
     idml_file = IDMLPackage(os.path.join(IDMLFILES_DIR, "4-pages-layers-with-guides.idml"), mode="r")
     designmap = idml_file.designmap
     self.assertEqual([etree_dom_to_tree(n, True) for n in designmap.spread_nodes], [
         {
             'attrs': {'src': 'Spreads/Spread_ud8.xml'},
             'content': [],
             'tag': '{http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging}Spread',
             'tail': '',
             'text': None
         },
         {
             'attrs': {'src': 'Spreads/Spread_u13b.xml'},
             'content': [],
             'tag': '{http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging}Spread',
             'tail': '',
             'text': None
         },
         {
             'attrs': {'src': 'Spreads/Spread_u142.xml'},
             'content': [],
             'tag': '{http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging}Spread',
             'tail': '',
             'text': None
         }
     ])
     idml_file.close()
Ejemplo n.º 2
0
 def test_get_style_node_by_name(self):
     idml_file = IDMLPackage(os.path.join(IDMLFILES_DIR,
                                          "article-1photo_import-xml.idml"),
                             mode="r")
     style = Style(idml_file)
     style_node = style.get_style_node_by_name("CharacterStyle/bold")
     self.assertEqual(
         style_node.nsmap,
         {'idPkg': 'http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging'})
     self.assertEqual(
         etree_dom_to_tree(style_node, True), {
             'attrs': {
                 'FontStyle': 'Bold',
                 'Imported': 'false',
                 'KeyboardShortcut': '0 0',
                 'Name': 'bold',
                 'Self': 'CharacterStyle/bold'
             },
             'content': [{
                 'attrs': {},
                 'content': [{
                     'attrs': {
                         'type': 'string'
                     },
                     'content': [],
                     'tag': 'BasedOn',
                     'tail': '',
                     'text': '$ID/[No character style]'
                 }, {
                     'attrs': {
                         'type': 'enumeration'
                     },
                     'content': [],
                     'tag': 'PreviewColor',
                     'tail': '',
                     'text': 'Nothing'
                 }],
                 'tag':
                 'Properties',
                 'tail':
                 '',
                 'text':
                 ''
             }],
             'tag':
             'CharacterStyle',
             'tail':
             '',
             'text':
             ''
         })
Ejemplo n.º 3
0
 def test_get_style_node_by_name(self):
     idml_file = IDMLPackage(os.path.join(IDMLFILES_DIR, "article-1photo_import-xml.idml"), mode="r")
     style = Style(idml_file)
     style_node = style.get_style_node_by_name("CharacterStyle/bold")
     self.assertEqual(style_node.nsmap, {'idPkg': 'http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging'})
     self.assertEqual(etree_dom_to_tree(style_node, True), {
         'attrs': {
             'FontStyle': 'Bold',
             'Imported': 'false',
             'KeyboardShortcut': '0 0',
             'Name': 'bold',
             'Self': 'CharacterStyle/bold'
         },
         'content': [
             {
                 'attrs': {},
                 'content': [
                     {
                         'attrs': {'type': 'string'},
                         'content': [],
                         'tag': 'BasedOn',
                         'tail': '',
                         'text': '$ID/[No character style]'
                     },
                     {
                         'attrs': {'type': 'enumeration'},
                         'content': [],
                         'tag': 'PreviewColor',
                         'tail': '',
                         'text': 'Nothing'
                     }
                 ],
                 'tag': 'Properties',
                 'tail': '',
                 'text': ''
             }
         ],
         'tag': 'CharacterStyle',
         'tail': '',
         'text': ''
     })
Ejemplo n.º 4
0
 def test_etree_dom_to_tree(self):
     from simple_idml.utils import etree_dom_to_tree
     dom = etree.fromstring(
         """<XMLTag Self="XMLTag/advertise" Name="advertise">
                            <Properties>
                            <TagColor type="enumeration">Green</TagColor>
                            </Properties>
                            </XMLTag>
                            """)
     self.assertEqual(
         etree_dom_to_tree(dom, True), {
             'attrs': {
                 'Name': 'advertise',
                 'Self': 'XMLTag/advertise'
             },
             'content': [{
                 'attrs': {},
                 'content': [{
                     'attrs': {
                         'type': 'enumeration'
                     },
                     'content': [],
                     'tag': 'TagColor',
                     'tail': '',
                     'text': 'Green'
                 }],
                 'tag':
                 'Properties',
                 'tail':
                 '',
                 'text':
                 ''
             }],
             'tag':
             'XMLTag',
             'tail':
             None,
             'text':
             ''
         })
Ejemplo n.º 5
0
 def test_etree_dom_to_tree(self):
     from simple_idml.utils import etree_dom_to_tree
     dom = etree.fromstring("""<XMLTag Self="XMLTag/advertise" Name="advertise">
                            <Properties>
                            <TagColor type="enumeration">Green</TagColor>
                            </Properties>
                            </XMLTag>
                            """)
     self.assertEqual(etree_dom_to_tree(dom, True), {
         'attrs': {'Name': 'advertise', 'Self': 'XMLTag/advertise'},
         'content': [{'attrs': {},
                      'content': [{'attrs': {'type': 'enumeration'},
                                   'content': [],
                                   'tag': 'TagColor',
                                   'tail': '',
                                   'text': 'Green'}],
                      'tag': 'Properties',
                      'tail': '',
                      'text': ''}],
         'tag': 'XMLTag',
         'tail': None,
         'text': ''
     })