__init__.py000064400000000320147205642200006652 0ustar00from __future__ import absolute_import, division, unicode_literals from . import sax __all__ = ["sax"] try: from . import genshi # noqa except ImportError: pass else: __all__.append("genshi") __init__.pyc000064400000000746147205642200007031 0ustar00 abc@`snddlmZmZmZddlmZdgZyddlmZWnek r\nXej ddS(i(tabsolute_importtdivisiontunicode_literalsi(tsaxusax(tgenshiugenshiN( t __future__RRRtRt__all__Rt ImportErrortappend(((sN/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/__init__.pyts  __init__.pyo000064400000000746147205642200007045 0ustar00 abc@`snddlmZmZmZddlmZdgZyddlmZWnek r\nXej ddS(i(tabsolute_importtdivisiontunicode_literalsi(tsaxusax(tgenshiugenshiN( t __future__RRRtRt__all__Rt ImportErrortappend(((sN/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/__init__.pyts  genshi.py000064400000003023147205642200006373 0ustar00from __future__ import absolute_import, division, unicode_literals from genshi.core import QName, Attrs from genshi.core import START, END, TEXT, COMMENT, DOCTYPE def to_genshi(walker): text = [] for token in walker: type = token["type"] if type in ("Characters", "SpaceCharacters"): text.append(token["data"]) elif text: yield TEXT, "".join(text), (None, -1, -1) text = [] if type in ("StartTag", "EmptyTag"): if token["namespace"]: name = "{%s}%s" % (token["namespace"], token["name"]) else: name = token["name"] attrs = Attrs([(QName("{%s}%s" % attr if attr[0] is not None else attr[1]), value) for attr, value in token["data"].items()]) yield (START, (QName(name), attrs), (None, -1, -1)) if type == "EmptyTag": type = "EndTag" if type == "EndTag": if token["namespace"]: name = "{%s}%s" % (token["namespace"], token["name"]) else: name = token["name"] yield END, QName(name), (None, -1, -1) elif type == "Comment": yield COMMENT, token["data"], (None, -1, -1) elif type == "Doctype": yield DOCTYPE, (token["name"], token["publicId"], token["systemId"]), (None, -1, -1) else: pass # FIXME: What to do? if text: yield TEXT, "".join(text), (None, -1, -1) genshi.pyc000064400000003275147205642200006547 0ustar00 abc@`sgddlmZmZmZddlmZmZddlmZmZm Z m Z m Z dZ dS(i(tabsolute_importtdivisiontunicode_literals(tQNametAttrs(tSTARTtENDtTEXTtCOMMENTtDOCTYPEcc`sg}x|D]}|d}|dkr=|j|dn&|rctdj|dfVg}n|dkr)|d rd |d |d f}n |d }tg|djD]<\}}t|d dk rd |n|d |f^q}tt||fdfV|dkr)d}q)n|dkr{|d rZd |d |d f}n |d }tt|dfVq |dkrt |ddfVq |dkr t |d |d|dfdfVq q W|rtdj|dfVndS(Nutypeu CharactersuSpaceCharactersudatauiuStartTaguEmptyTagu namespaceu{%s}%sunameiiuEndTaguCommentuDoctypeupublicIdusystemId(u CharactersuSpaceCharacters(Nii(uStartTaguEmptyTag(Nii(Nii(Nii(Nii(Nii( tappendRtjointNoneRtitemsRRRRR (twalkerttextttokenttypetnametattrtvaluetattrs((sL/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/genshi.pyt to_genshis<       S       N( t __future__RRRt genshi.coreRRRRRRR R(((sL/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/genshi.pyts(genshi.pyo000064400000003275147205642200006563 0ustar00 abc@`sgddlmZmZmZddlmZmZddlmZmZm Z m Z m Z dZ dS(i(tabsolute_importtdivisiontunicode_literals(tQNametAttrs(tSTARTtENDtTEXTtCOMMENTtDOCTYPEcc`sg}x|D]}|d}|dkr=|j|dn&|rctdj|dfVg}n|dkr)|d rd |d |d f}n |d }tg|djD]<\}}t|d dk rd |n|d |f^q}tt||fdfV|dkr)d}q)n|dkr{|d rZd |d |d f}n |d }tt|dfVq |dkrt |ddfVq |dkr t |d |d|dfdfVq q W|rtdj|dfVndS(Nutypeu CharactersuSpaceCharactersudatauiuStartTaguEmptyTagu namespaceu{%s}%sunameiiuEndTaguCommentuDoctypeupublicIdusystemId(u CharactersuSpaceCharacters(Nii(uStartTaguEmptyTag(Nii(Nii(Nii(Nii(Nii( tappendRtjointNoneRtitemsRRRRR (twalkerttextttokenttypetnametattrtvaluetattrs((sL/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/genshi.pyt to_genshis<       S       N( t __future__RRRt genshi.coreRRRRRRR R(((sL/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/genshi.pyts(sax.py000064400000003175147205642200005721 0ustar00from __future__ import absolute_import, division, unicode_literals from xml.sax.xmlreader import AttributesNSImpl from ..constants import adjustForeignAttributes, unadjustForeignAttributes prefix_mapping = {} for prefix, localName, namespace in adjustForeignAttributes.values(): if prefix is not None: prefix_mapping[prefix] = namespace def to_sax(walker, handler): """Call SAX-like content handler based on treewalker walker""" handler.startDocument() for prefix, namespace in prefix_mapping.items(): handler.startPrefixMapping(prefix, namespace) for token in walker: type = token["type"] if type == "Doctype": continue elif type in ("StartTag", "EmptyTag"): attrs = AttributesNSImpl(token["data"], unadjustForeignAttributes) handler.startElementNS((token["namespace"], token["name"]), token["name"], attrs) if type == "EmptyTag": handler.endElementNS((token["namespace"], token["name"]), token["name"]) elif type == "EndTag": handler.endElementNS((token["namespace"], token["name"]), token["name"]) elif type in ("Characters", "SpaceCharacters"): handler.characters(token["data"]) elif type == "Comment": pass else: assert False, "Unknown token type" for prefix, namespace in prefix_mapping.items(): handler.endPrefixMapping(prefix) handler.endDocument() sax.pyc000064400000003341147205642200006057 0ustar00 abc@`sddlmZmZmZddlmZddlmZmZiZ x6ej D](\Z Z Z e dk rUe e e q>|dkrt|dt}|j|d|df|d||dkrJ|j|d|df|dqJq>|dkr |j|d|df|dq>|dkr)|j|dq>|d kr8q>t s>t d q>Wx'tjD]\}}|j |q[W|j d S(u8Call SAX-like content handler based on treewalker walkerutypeuDoctypeuStartTaguEmptyTagudatau namespaceunameuEndTagu CharactersuSpaceCharactersuCommentuUnknown token typeN(uStartTaguEmptyTag(u CharactersuSpaceCharacters( t startDocumenttprefix_mappingtitemststartPrefixMappingRRtstartElementNSt endElementNSt characterstFalsetAssertionErrortendPrefixMappingt endDocument(twalkerthandlertprefixt namespacettokenttypetattrs((sI/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/sax.pytto_sax s6           N(t __future__RRRtxml.sax.xmlreaderRt constantsRRRtvaluesRt localNameRtNoneR(((sI/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/sax.pyts sax.pyo000064400000003233147205642200006073 0ustar00 abc@`sddlmZmZmZddlmZddlmZmZiZ x6ej D](\Z Z Z e dk rUe e e q>|d krt|dt}|j|d|df|d||dkr8|j|d|df|dq8q>|dkr |j|d|df|dq>|dkr)|j|dq>|d kr>q>q>Wx'tjD]\}}|j |qIW|j d S(u8Call SAX-like content handler based on treewalker walkerutypeuDoctypeuStartTaguEmptyTagudatau namespaceunameuEndTagu CharactersuSpaceCharactersuCommentN(uStartTaguEmptyTag(u CharactersuSpaceCharacters( t startDocumenttprefix_mappingtitemststartPrefixMappingRRtstartElementNSt endElementNSt characterstendPrefixMappingt endDocument(twalkerthandlertprefixt namespacettokenttypetattrs((sI/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/sax.pytto_sax s6           N(t __future__RRRtxml.sax.xmlreaderRt constantsRRRtvaluesRt localNameRtNoneR(((sI/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treeadapters/sax.pyts