Skip to content
Snippets Groups Projects
Commit 784d55b4 authored by Daniel Hillier's avatar Daniel Hillier
Browse files

Remove pi_factories and comment_factories arguments

These were only needed to support the nsetree subclasses and are no longer
required now that code has been removed.
parent a983c0c7
No related branches found
No related tags found
1 merge request!3And incremental support to the witer
......@@ -59,8 +59,6 @@
method=None,
*,
short_empty_elements=True,
pi_factories=None,
comment_factories=None,
nsmap=None,
root_ns_only=False,
minimal_ns_only=False,
......@@ -119,10 +117,6 @@
raise ValueError("unknown method %r" % method)
if not encoding:
encoding = "us-ascii"
if pi_factories is None:
pi_factories = (ET.ProcessingInstruction,)
if comment_factories is None:
comment_factories = (ET.Comment,)
with _get_writer(file_or_filename, encoding) as (write, declared_encoding):
if method == "xml" and (
......@@ -163,8 +157,6 @@
self._root,
default_namespace,
new_nsmap,
pi_factories,
comment_factories,
el_has_namespaces=self.el_has_namespaces,
)
if not minimal_ns_only:
......@@ -192,8 +184,6 @@
is_html=is_html,
is_root=True,
short_empty_elements=short_empty_elements,
pi_factories=pi_factories,
comment_factories=comment_factories,
use_el_namespaces=use_el_namespaces,
new_nsmap=new_nsmap,
)
......@@ -389,8 +379,6 @@
nsmap_scope,
global_nsmap,
short_empty_elements,
pi_factories,
comment_factories,
is_html,
is_root=False,
uri_to_prefix=None,
......@@ -429,7 +417,7 @@
tag = elem.tag
text = elem.text
if tag in comment_factories:
if tag is ET.Comment:
write("<!--%s-->" % text)
tag = None
next_remains_root = False
......@@ -433,7 +421,7 @@
write("<!--%s-->" % text)
tag = None
next_remains_root = False
elif tag in pi_factories:
elif tag is ET.ProcessingInstruction:
write("<?%s?>" % text)
tag = None
next_remains_root = False
......@@ -585,8 +573,6 @@
nsmap_scope,
global_nsmap,
short_empty_elements,
pi_factories,
comment_factories,
is_html,
is_root=False,
uri_to_prefix=None,
......@@ -613,13 +599,6 @@
Controls the formatting of elements that contain no content. If True
(default) they are emitted as a single self-closed tag, otherwise
they are emitted as a pair of start/end tags.
pi_factories:
A sequence of objects used as processing instruction factories
(eg. ET.ProcessingInstruction). Needed for subclassing ET.Element.
if comment_factories is None:
comment_factories:
A sequence of objects used as comment factories (eg. ET.Comment).
Needed for subclassing ET.Element.
is_html:
Set to True to serialize as HTML otherwise XML.
is_root:
......@@ -670,8 +649,6 @@
nsmap_scope,
global_nsmap,
short_empty_elements,
pi_factories,
comment_factories,
is_html,
is_root,
uri_to_prefix,
......@@ -685,8 +662,6 @@
nsmap_scope,
global_nsmap,
short_empty_elements,
pi_factories,
comment_factories,
is_html,
next_remains_root,
uri_to_prefix,
......@@ -704,8 +679,6 @@
elem,
local_nsmap,
el_has_namespaces,
pi_factories=None,
comment_factories=None,
):
"""Iterate through all the qualified names in elem"""
seen_el_qnames = set()
......@@ -734,7 +707,11 @@
if tag not in seen_el_qnames:
seen_el_qnames.add(tag)
yield tag, True
elif tag is not None and tag not in comment_factories and tag not in pi_factories:
elif (
tag is not None
and tag is not ET.ProcessingInstruction
and tag is not ET.Comment
):
ET._raise_serialization_error(tag)
for key, value in this_elem.items():
......@@ -760,8 +737,6 @@
elem,
default_namespace=None,
nsmap=None,
pi_factories=None,
comment_factories=None,
el_has_namespaces=False,
):
"""Find all namespaces used in the document and return a prefix to uri map"""
......@@ -793,8 +768,6 @@
elem,
local_prefix_map,
el_has_namespaces,
pi_factories,
comment_factories,
):
try:
if qname[:1] == "{":
......
......@@ -40,8 +40,6 @@
def test_namespaces_returns_only_used(self):
"_namespaces only returns uris that were used in the docuemnt"
pi_factories = (ET.ProcessingInstruction,)
comment_factories = (ET.Comment,)
elem = ET.Element("{namespace0}foo")
out_nsmap = etmod._namespaces(
elem,
......@@ -45,8 +43,6 @@
elem = ET.Element("{namespace0}foo")
out_nsmap = etmod._namespaces(
elem,
pi_factories=pi_factories,
comment_factories=comment_factories,
)
self.assertEqual(
out_nsmap,
......@@ -55,9 +51,7 @@
def test_namespaces_default_namespace_not_used(self):
"_namespaces doesn't return default_namespace if not used"
pi_factories = (ET.ProcessingInstruction,)
comment_factories = (ET.Comment,)
elem = ET.Element("{namespace1}foo")
out_nsmap = etmod._namespaces(
elem,
default_namespace="other",
......@@ -60,9 +54,7 @@
elem = ET.Element("{namespace1}foo")
out_nsmap = etmod._namespaces(
elem,
default_namespace="other",
pi_factories=pi_factories,
comment_factories=comment_factories,
)
self.assertEqual(
out_nsmap,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment