/usr/local/lib/python3.9/site-packages/django/utils
""" Utilities for XML generation/parsing. """ import re from xml.sax.saxutils import XMLGenerator class UnserializableContentError(ValueError): pass class SimplerXMLGenerator(XMLGenerator): def addQuickElement(self, name, contents=None, attrs=None): "Convenience method for adding an element with no children" if attrs is None: attrs = {} self.startElement(name, attrs) if contents is not None: self.characters(contents) self.endElement(name) def characters(self, content): if content and re.search(r"[\x00-\x08\x0B-\x0C\x0E-\x1F]", content): # Fail loudly when content has control chars (unsupported in XML 1.0) # See https://www.w3.org/International/questions/qa-controls raise UnserializableContentError( "Control characters are not supported in XML 1.0" ) XMLGenerator.characters(self, content) def startElement(self, name, attrs): # Sort attrs for a deterministic output. sorted_attrs = dict(sorted(attrs.items())) if attrs else attrs super().startElement(name, sorted_attrs)
.
Edit
..
Edit
__init__.py
Edit
__pycache__
Edit
_os.py
Edit
archive.py
Edit
asyncio.py
Edit
autoreload.py
Edit
baseconv.py
Edit
cache.py
Edit
connection.py
Edit
crypto.py
Edit
datastructures.py
Edit
dateformat.py
Edit
dateparse.py
Edit
dates.py
Edit
datetime_safe.py
Edit
deconstruct.py
Edit
decorators.py
Edit
deprecation.py
Edit
duration.py
Edit
encoding.py
Edit
feedgenerator.py
Edit
formats.py
Edit
functional.py
Edit
hashable.py
Edit
html.py
Edit
http.py
Edit
inspect.py
Edit
ipv6.py
Edit
itercompat.py
Edit
jslex.py
Edit
log.py
Edit
lorem_ipsum.py
Edit
module_loading.py
Edit
numberformat.py
Edit
regex_helper.py
Edit
safestring.py
Edit
termcolors.py
Edit
text.py
Edit
timesince.py
Edit
timezone.py
Edit
topological_sort.py
Edit
translation
Edit
tree.py
Edit
version.py
Edit
xmlutils.py
Edit