-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbae97d
commit b926877
Showing
9 changed files
with
58 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,37 +4,33 @@ | |
# Contact email: [email protected] | ||
# ============================================================================= | ||
|
||
|
||
from lxml import etree | ||
from lxml.etree import ParseError | ||
ElementType = etree._Element | ||
|
||
from owslib.namespaces import Namespaces | ||
|
||
|
||
def patch_well_known_namespaces(etree_module): | ||
"""Monkey patches the etree module to add some well-known namespaces.""" | ||
def patch_well_known_namespaces(): | ||
"""Monkey patches lxml.etree to add some well-known namespaces.""" | ||
|
||
ns = Namespaces() | ||
|
||
try: | ||
register_namespace = etree_module.register_namespace | ||
register_namespace = etree.register_namespace | ||
except AttributeError: | ||
etree_module._namespace_map | ||
etree._namespace_map | ||
|
||
def register_namespace(prefix, uri): | ||
etree_module._namespace_map[uri] = prefix | ||
etree._namespace_map[uri] = prefix | ||
|
||
for k, v in list(ns.get_namespaces().items()): | ||
register_namespace(k, v) | ||
|
||
etree.set_default_parser( | ||
parser=etree.XMLParser(resolve_entities=False) | ||
) | ||
|
||
# try to find lxml or elementtree | ||
try: | ||
from lxml import etree | ||
from lxml.etree import ParseError | ||
ElementType = etree._Element | ||
except ImportError: | ||
import xml.etree.ElementTree as etree | ||
ElementType = etree.Element | ||
try: | ||
from xml.etree.ElementTree import ParseError | ||
except ImportError: | ||
from xml.parsers.expat import ExpatError as ParseError | ||
|
||
patch_well_known_namespaces(etree) | ||
patch_well_known_namespaces() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
dataclasses; python_version < '3.7' | ||
lxml | ||
python-dateutil>=1.5 | ||
pytz | ||
requests>=1.0 | ||
pyyaml | ||
dataclasses; python_version < '3.7' | ||
requests>=1.0 |