Projet

Général

Profil

0001-fix-deprecation-warning-in-ElementTree.patch

Benjamin Dauvergne, 05 octobre 2018 10:32

Télécharger (7,29 ko)

Voir les différences:

Subject: [PATCH 1/5] fix deprecation warning in ElementTree

 wcs/fields.py                                   |  6 +++---
 wcs/formdef.py                                  |  8 ++++----
 wcs/qommon/publisher.py                         | 12 ++++++------
 wcs/qommon/static/images/categories/generate.py |  4 ++--
 wcs/wf/export_to_model.py                       |  2 +-
 wcs/workflows.py                                |  8 ++++----
 6 files changed, 20 insertions(+), 20 deletions(-)
wcs/fields.py
257 257
                continue
258 258
            if el is None:
259 259
                continue
260
            if el.getchildren():
260
            if list(el):
261 261
                if type(getattr(self, attribute)) is list:
262
                    v = [x.text.encode(charset) for x in el.getchildren()]
262
                    v = [x.text.encode(charset) for x in el]
263 263
                elif type(getattr(self, attribute)) is dict:
264 264
                    v = {}
265
                    for e in el.getchildren():
265
                    for e in el:
266 266
                        v[e.tag] = e.text.encode(charset)
267 267
                else:
268 268
                    print 'currently:', self.__dict__
wcs/formdef.py
1040 1040
            roles_node = tree.find(node_name)
1041 1041
            roles = []
1042 1042
            setattr(formdef, attr_name, roles)
1043
            for child in roles_node.getchildren():
1043
            for child in roles_node:
1044 1044
                role_id = None
1045 1045
                value = child.text.encode(charset)
1046 1046
                if value.startswith('_') or value == 'logged-users':
......
1061 1061
        if tree.find('roles') is not None:
1062 1062
            roles_node = tree.find('roles')
1063 1063
            formdef.workflow_roles = {}
1064
            for child in roles_node.getchildren():
1064
            for child in roles_node:
1065 1065
                role_key = child.attrib['role_key']
1066 1066
                role_id = None
1067 1067
                value = child.text.encode(charset)
......
1083 1083
        if tree.find('geolocations') is not None:
1084 1084
            geolocations_node = tree.find('geolocations')
1085 1085
            formdef.geolocations = {}
1086
            for child in geolocations_node.getchildren():
1086
            for child in geolocations_node:
1087 1087
                geoloc_key = child.attrib['key']
1088 1088
                geoloc_value = child.text.encode(charset)
1089 1089
                formdef.geolocations[geoloc_key] = geoloc_value
......
1091 1091
        if tree.find('required_authentication_contexts') is not None:
1092 1092
            node = tree.find('required_authentication_contexts')
1093 1093
            formdef.required_authentication_contexts = []
1094
            for child in node.getchildren():
1094
            for child in node:
1095 1095
                formdef.required_authentication_contexts.append(str(child.text))
1096 1096

  
1097 1097
        return formdef
wcs/qommon/publisher.py
869 869
            return
870 870

  
871 871
        cfg = {}
872
        for elem in tree.getroot().getchildren():
872
        for elem in tree.getroot():
873 873
            sub_cfg = {}
874 874
            cfg[elem.tag] = sub_cfg
875
            for child in elem.getchildren():
875
            for child in elem:
876 876
                sub_cfg[child.tag] = None
877
                if child.getchildren():
878
                    if child.getchildren()[0].tag == 'item':
877
                if list(child):
878
                    if list(child)[0].tag == 'item':
879 879
                        # list
880 880
                        sub_cfg[child.tag] = []
881
                        for c in child.getchildren():
881
                        for c in child:
882 882
                            if c.text in ('True', 'False'):
883 883
                                value = (c.text == 'True')
884 884
                            else:
......
887 887
                    else:
888 888
                        # dict
889 889
                        sub_cfg[child.tag] = {}
890
                        for c in child.getchildren():
890
                        for c in child:
891 891
                            if c.text in ('True', 'False'):
892 892
                                value = (c.text == 'True')
893 893
                            else:
wcs/qommon/static/images/categories/generate.py
53 53
        tree = ET.fromstring(file(svg_path).read())
54 54

  
55 55
    author = None
56
    for elem in tree.getchildren():
56
    for elem in tree:
57 57
        if elem.tag == '{http://www.w3.org/2000/svg}text' and elem.text.startswith('Created by'):
58 58
            author = elem.text[len('Created by')+1:]
59 59
            tree.remove(elem)
60
    for elem in tree.getchildren():
60
    for elem in tree:
61 61
        if elem.tag == '{http://www.w3.org/2000/svg}text' and 'Noun Project' in elem.text:
62 62
            tree.remove(elem)
63 63

  
wcs/wf/export_to_model.py
443 443
                        continue
444 444
                    if not hasattr(variable_image, 'get_content'):
445 445
                        continue
446
                    image = [x for x in node.getchildren() if x.tag == DRAW_IMAGE][0]
446
                    image = [x for x in node if x.tag == DRAW_IMAGE][0]
447 447
                    new_images[image.attrib.get(XLINK_HREF)] = variable_image
448 448

  
449 449
                for attr in ('text', 'tail'):
wcs/workflows.py
818 818
                continue
819 819
            if el is None:
820 820
                continue
821
            if el.getchildren():
821
            if list(el):
822 822
                if type(getattr(self, attribute)) is list:
823
                    v = [x.text.encode(charset) for x in el.getchildren()]
823
                    v = [x.text.encode(charset) for x in el]
824 824
                elif type(getattr(self, attribute)) is dict:
825 825
                    v = {}
826
                    for e in el.getchildren():
826
                    for e in el:
827 827
                        v[e.tag] = e.text.encode(charset)
828 828
                else:
829 829
                    # ???
......
863 863
            setattr(self, attribute, [])
864 864
        else:
865 865
            imported_roles = []
866
            for child in elem.getchildren():
866
            for child in elem:
867 867
                imported_roles.append(self._get_role_id_from_xml(child,
868 868
                    charset, include_id=include_id))
869 869
            setattr(self, attribute, imported_roles)
870
-