mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 03:20:08 +01:00
style: Normalise ElementTree imports with import xml.etree.ElementTree as ET
The convention is that `xml.etree.ElementTree` should be imported as `ET`. Fixes: unconventional-import-alias (ICN001) Ruff rule: https://docs.astral.sh/ruff/rules/unconventional-import-alias/
This commit is contained in:
@@ -85,7 +85,7 @@ def parseDoxyXML(module, class_or_filename_list):
|
|||||||
print("Loading %s..." % pathname)
|
print("Loading %s..." % pathname)
|
||||||
_filesparsed.add(pathname)
|
_filesparsed.add(pathname)
|
||||||
|
|
||||||
root = et.parse(pathname).getroot()
|
root = ET.parse(pathname).getroot()
|
||||||
for element in root:
|
for element in root:
|
||||||
# extract and add top-level elements from the XML document
|
# extract and add top-level elements from the XML document
|
||||||
item = module.addElement(element)
|
item = module.addElement(element)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ wxWidgets API info which we need from them.
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import pprint
|
import pprint
|
||||||
import xml.etree.ElementTree as et
|
import xml.etree.ElementTree as ET
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from .tweaker_tools import FixWxPrefix, magicMethods, \
|
from .tweaker_tools import FixWxPrefix, magicMethods, \
|
||||||
@@ -666,7 +666,7 @@ class ParamDef(BaseDef):
|
|||||||
self.default = flattenNode(element.find('defval'))
|
self.default = flattenNode(element.find('defval'))
|
||||||
except:
|
except:
|
||||||
print("error when parsing element:")
|
print("error when parsing element:")
|
||||||
et.dump(element)
|
ET.dump(element)
|
||||||
raise
|
raise
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -740,7 +740,7 @@ class ClassDef(BaseDef):
|
|||||||
return all_classes, specials
|
return all_classes, specials
|
||||||
|
|
||||||
fname = os.path.join(XMLSRC, refid+'.xml')
|
fname = os.path.join(XMLSRC, refid+'.xml')
|
||||||
root = et.parse(fname).getroot()
|
root = ET.parse(fname).getroot()
|
||||||
compounds = findDescendants(root, 'basecompoundref')
|
compounds = findDescendants(root, 'basecompoundref')
|
||||||
else:
|
else:
|
||||||
compounds = element.findall('basecompoundref')
|
compounds = element.findall('basecompoundref')
|
||||||
@@ -783,7 +783,7 @@ class ClassDef(BaseDef):
|
|||||||
from etgtools import XMLSRC
|
from etgtools import XMLSRC
|
||||||
ref = node.get('refid')
|
ref = node.get('refid')
|
||||||
fname = os.path.join(XMLSRC, ref+'.xml')
|
fname = os.path.join(XMLSRC, ref+'.xml')
|
||||||
root = et.parse(fname).getroot()
|
root = ET.parse(fname).getroot()
|
||||||
innerclass = root[0]
|
innerclass = root[0]
|
||||||
kind = innerclass.get('kind')
|
kind = innerclass.get('kind')
|
||||||
assert kind in ['class', 'struct']
|
assert kind in ['class', 'struct']
|
||||||
@@ -1603,7 +1603,7 @@ class ModuleDef(BaseDef):
|
|||||||
from etgtools import XMLSRC
|
from etgtools import XMLSRC
|
||||||
refid = node.get('refid')
|
refid = node.get('refid')
|
||||||
fname = os.path.join(XMLSRC, refid.rsplit('_', 1)[0]) + '.xml'
|
fname = os.path.join(XMLSRC, refid.rsplit('_', 1)[0]) + '.xml'
|
||||||
root = et.parse(fname).getroot()
|
root = ET.parse(fname).getroot()
|
||||||
return root.find(".//memberdef[@id='{}']".format(refid))
|
return root.find(".//memberdef[@id='{}']".format(refid))
|
||||||
|
|
||||||
|
|
||||||
@@ -1749,7 +1749,7 @@ def prependText(node, text):
|
|||||||
|
|
||||||
|
|
||||||
def makeTextElement(text):
|
def makeTextElement(text):
|
||||||
element = et.Element('para')
|
element = ET.Element('para')
|
||||||
element.text = text
|
element.text = text
|
||||||
return element
|
return element
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import textwrap
|
|||||||
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
import xml.etree.ElementTree as et
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
# Phoenix-specific stuff
|
# Phoenix-specific stuff
|
||||||
import etgtools.extractors as extractors
|
import etgtools.extractors as extractors
|
||||||
@@ -783,7 +783,7 @@ class Paragraph(Node):
|
|||||||
|
|
||||||
first = line.index('Availability:')
|
first = line.index('Availability:')
|
||||||
|
|
||||||
element = et.Element('available', kind='available')
|
element = ET.Element('available', kind='available')
|
||||||
element.text = line[first+13:]
|
element.text = line[first+13:]
|
||||||
|
|
||||||
section = Section(element, None, self.kind)
|
section = Section(element, None, self.kind)
|
||||||
@@ -2002,7 +2002,7 @@ class XMLDocString(object):
|
|||||||
# non-empty string. In such cases, this branch will insert a deprecated section into the xml tree
|
# non-empty string. In such cases, this branch will insert a deprecated section into the xml tree
|
||||||
# so that the Node Tree (see classes above) will generate the deprecated tag on their own in self.RecurseXML
|
# so that the Node Tree (see classes above) will generate the deprecated tag on their own in self.RecurseXML
|
||||||
if hasattr(xml_item, 'deprecated') and xml_item.deprecated and isinstance(xml_item.deprecated, str):
|
if hasattr(xml_item, 'deprecated') and xml_item.deprecated and isinstance(xml_item.deprecated, str):
|
||||||
element = et.Element('deprecated', kind='deprecated')
|
element = ET.Element('deprecated', kind='deprecated')
|
||||||
element.text = xml_item.deprecated
|
element.text = xml_item.deprecated
|
||||||
|
|
||||||
deprecated_section = Section(element, None, self.kind, self.is_overload, self.share_docstrings)
|
deprecated_section = Section(element, None, self.kind, self.is_overload, self.share_docstrings)
|
||||||
@@ -2227,7 +2227,7 @@ class XMLDocString(object):
|
|||||||
rest_class = ULink(element, parent)
|
rest_class = ULink(element, parent)
|
||||||
|
|
||||||
elif tag == 'onlyfor':
|
elif tag == 'onlyfor':
|
||||||
onlyfor = et.Element('available', kind='available')
|
onlyfor = ET.Element('available', kind='available')
|
||||||
onlyfor.text = text
|
onlyfor.text = text
|
||||||
onlyfor.tail = tail
|
onlyfor.tail = tail
|
||||||
|
|
||||||
@@ -2586,7 +2586,7 @@ class XMLDocString(object):
|
|||||||
else:
|
else:
|
||||||
new_section.append('`%s`' % stripped)
|
new_section.append('`%s`' % stripped)
|
||||||
|
|
||||||
element = et.Element('return', kind='return')
|
element = ET.Element('return', kind='return')
|
||||||
element.text = '( %s )'%(', '.join(new_section))
|
element.text = '( %s )'%(', '.join(new_section))
|
||||||
|
|
||||||
return_section = Section(element, None, self.kind, self.is_overload, self.share_docstrings)
|
return_section = Section(element, None, self.kind, self.is_overload, self.share_docstrings)
|
||||||
@@ -3571,7 +3571,7 @@ class SphinxGenerator(generators.DocsGeneratorBase):
|
|||||||
else:
|
else:
|
||||||
new_section.append('`%s`'%stripped)
|
new_section.append('`%s`'%stripped)
|
||||||
|
|
||||||
element = et.Element('return', kind='return')
|
element = ET.Element('return', kind='return')
|
||||||
element.text = '( %s )'%(', '.join(new_section))
|
element.text = '( %s )'%(', '.join(new_section))
|
||||||
|
|
||||||
rtype2 = Section(element, None, 'method')
|
rtype2 = Section(element, None, 'method')
|
||||||
|
|||||||
Reference in New Issue
Block a user