Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fix use of lists in nested node objects
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2f68ce1cc26842e3d11c505fb548fe1b5b44418c
User & Date: brandon 2018-01-16 21:37:10
Context
2018-10-06
20:35
Fix bug in which a handler initially chosen for the file extension is kept even if it does not claim the file. check-in: de5fe86a8e user: brandon tags: trunk
2018-01-16
21:37
fix use of lists in nested node objects check-in: 2f68ce1cc2 user: brandon tags: trunk
2017-12-24
22:54
support repeated elements when building node dicts check-in: 87b48d4651 user: brandon tags: trunk
Changes

Changes to treatyofbabel/ifiction.py.

1
2
3
4
5
6
7
8
9
10
11
12
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114

115
116
117
118
119
120
121
122
123
124
125
# -*- coding: utf-8 -*-
#
#       ifiction.py
#
#       Copyright © 2012, 2013, 2014, 2015, 2017 Brandon Invergo <brandon@invergo.net>
#
#       This file is part of pyifbabel.
#
#       pyifbabel is free software: you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation, either version 3 of the License, or
#       (at your option) any later version.
................................................................................
        if value is None or value == "":
            continue
        child = None
        if isinstance(value, list):
            for val in value:
                tag = build_node_from_dict(ifiction_dom, key, val)
                node.appendChild(tag)
            return node
        elif isinstance(value, dict):
            if len(value.keys()) > 0:
                tag = build_node_from_dict(ifiction_dom, key, value)
            else:
                tag = ifiction_dom.createElement(key)
                child = ifiction_dom.createTextNode('')

        else:
            tag = ifiction_dom.createElement(key)
            child = ifiction_dom.createTextNode(value)
        node.appendChild(tag)
        if child is not None:
            tag.appendChild(child)
    return node


def is_ifiction(xml_dom_doc):
    """Test if an xml.dom Document contains IFiction data.




|







 







<






>



|







1
2
3
4
5
6
7
8
9
10
11
12
...
101
102
103
104
105
106
107

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# -*- coding: utf-8 -*-
#
#       ifiction.py
#
#       Copyright © 2012, 2013, 2014, 2015, 2017, 2018 Brandon Invergo <brandon@invergo.net>
#
#       This file is part of pyifbabel.
#
#       pyifbabel is free software: you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation, either version 3 of the License, or
#       (at your option) any later version.
................................................................................
        if value is None or value == "":
            continue
        child = None
        if isinstance(value, list):
            for val in value:
                tag = build_node_from_dict(ifiction_dom, key, val)
                node.appendChild(tag)

        elif isinstance(value, dict):
            if len(value.keys()) > 0:
                tag = build_node_from_dict(ifiction_dom, key, value)
            else:
                tag = ifiction_dom.createElement(key)
                child = ifiction_dom.createTextNode('')
            node.appendChild(tag)
        else:
            tag = ifiction_dom.createElement(key)
            child = ifiction_dom.createTextNode(value)
            node.appendChild(tag)
        if child is not None:
            tag.appendChild(child)
    return node


def is_ifiction(xml_dom_doc):
    """Test if an xml.dom Document contains IFiction data.