Skip to content

Commit

Permalink
Global etree selector
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrajina committed Nov 16, 2023
1 parent 5b0ba61 commit b75314d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions gpxpy/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,29 @@

try:
# Load LXML or fallback to cET or ET
import lxml.etree as mod_etree # type: ignore
import lxml.etree as mod_lxml_etree # type: ignore
except ImportError:
try:
import xml.etree.cElementTree as mod_etree # type: ignore
except ImportError:
import xml.etree.ElementTree as mod_etree # type: ignore
pass

try:
import xml.etree.cElementTree as mod_xml_etree # type: ignore
except ImportError:
import xml.etree.ElementTree as mod_xml_etree # type: ignore

mod_etree = mod_xml_etree

""" Change the etree implementation, use gpx.set_xml_etree(mod_lxml_etree) for lxml """
def set_xml_etree(etre):
global mod_etree
mod_etree = etre

from . import gpx as mod_gpx
from . import utils as mod_utils
from . import gpxfield as mod_gpxfield

log = mod_logging.getLogger(__name__)


def library() -> str:
"""
Return the underlying ETree.
Expand Down

0 comments on commit b75314d

Please sign in to comment.