Skip to content

Commit

Permalink
use common convention for xml element tree import
Browse files Browse the repository at this point in the history
Updating the imports for `xml.etree.ElementTree` to use the common
convention for its alias. Makes linters happy.

Signed-off-by: James Knight <james.d.knight@live.com>
  • Loading branch information
jdknight committed Oct 5, 2024
1 parent bb26168 commit ddbe0d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions sphinxcontrib/confluencebuilder/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sphinxcontrib.confluencebuilder.util import convert_length
from sphinxcontrib.confluencebuilder.util import extract_length
from sphinxcontrib.confluencebuilder.util import find_env_abspath
import xml.etree.ElementTree as xml_et
import xml.etree.ElementTree as ET


# xml declaration string
Expand All @@ -23,7 +23,7 @@ def svg_initialize():
"""

# prevent ns0 namespace introduction if ever generating svg files
xml_et.register_namespace('', 'http://www.w3.org/2000/svg')
ET.register_namespace('', 'http://www.w3.org/2000/svg')


def confluence_supported_svg(builder, node):
Expand Down Expand Up @@ -77,7 +77,7 @@ def confluence_supported_svg(builder, node):
return

modified = False
svg_root = xml_et.fromstring(svg_data) # noqa: S314
svg_root = ET.fromstring(svg_data) # noqa: S314

# determine (if possible) the svgs desired width/height
svg_height = None
Expand Down Expand Up @@ -179,7 +179,7 @@ def confluence_supported_svg(builder, node):
if height and width:
svg_root.attrib['height'] = str(height)
svg_root.attrib['width'] = str(width)
svg_data = xml_et.tostring(svg_root)
svg_data = ET.tostring(svg_root)
modified = True

# ensure xml declaration exists
Expand Down
4 changes: 2 additions & 2 deletions tests/unit-tests/test_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from tests.lib.parse import parse
from tests.lib.testcase import ConfluenceTestCase
from tests.lib.testcase import setup_builder
import xml.etree.ElementTree as xml_et
import xml.etree.ElementTree as ET


class TestSvg(ConfluenceTestCase):
Expand All @@ -18,7 +18,7 @@ def _extract_svg_size(self, svg_file):
with svg_file.open('rb') as f:
svg_data = f.read()

svg_root = xml_et.fromstring(svg_data) # noqa: S314
svg_root = ET.fromstring(svg_data) # noqa: S314
return int(svg_root.attrib['width']), int(svg_root.attrib['height'])

@setup_builder('confluence')
Expand Down

0 comments on commit ddbe0d3

Please sign in to comment.