X7ROOT File Manager
Current Path:
/lib/python3.8/site-packages/pip/_vendor/html5lib/filters
lib
/
python3.8
/
site-packages
/
pip
/
_vendor
/
html5lib
/
filters
/
ðŸ“
..
📄
__init__.py
(0 B)
ðŸ“
__pycache__
📄
alphabeticalattributes.py
(919 B)
📄
base.py
(286 B)
📄
inject_meta_charset.py
(2.88 KB)
📄
lint.py
(3.56 KB)
📄
optionaltags.py
(10.34 KB)
📄
sanitizer.py
(25.63 KB)
📄
whitespace.py
(1.19 KB)
Editing: alphabeticalattributes.py
from __future__ import absolute_import, division, unicode_literals from . import base from collections import OrderedDict def _attr_key(attr): """Return an appropriate key for an attribute for sorting Attributes have a namespace that can be either ``None`` or a string. We can't compare the two because they're different types, so we convert ``None`` to an empty string first. """ return (attr[0][0] or ''), attr[0][1] class Filter(base.Filter): """Alphabetizes attributes for elements""" def __iter__(self): for token in base.Filter.__iter__(self): if token["type"] in ("StartTag", "EmptyTag"): attrs = OrderedDict() for name, value in sorted(token["data"].items(), key=_attr_key): attrs[name] = value token["data"] = attrs yield token
Upload File
Create Folder