├── src ├── workflow │ ├── version │ ├── web.pyc │ ├── update.pyc │ ├── __init__.pyc │ ├── workflow.pyc │ ├── background.pyc │ └── __init__.py ├── lib │ ├── lxml │ │ ├── includes │ │ │ ├── __init__.py │ │ │ ├── lxml-version.h │ │ │ ├── __init__.pyc │ │ │ ├── config.pxd │ │ │ ├── uri.pxd │ │ │ ├── dtdvalid.pxd │ │ │ ├── xinclude.pxd │ │ │ ├── c14n.pxd │ │ │ ├── schematron.pxd │ │ │ ├── xmlschema.pxd │ │ │ ├── relaxng.pxd │ │ │ └── htmlparser.pxd │ │ ├── etree.so │ │ ├── sax.pyc │ │ ├── builder.pyc │ │ ├── __init__.pyc │ │ ├── cssselect.pyc │ │ ├── html │ │ │ ├── defs.pyc │ │ │ ├── diff.pyc │ │ │ ├── builder.pyc │ │ │ ├── clean.pyc │ │ │ ├── __init__.pyc │ │ │ ├── _setmixin.pyc │ │ │ ├── formfill.pyc │ │ │ ├── ElementSoup.pyc │ │ │ ├── _diffcommand.pyc │ │ │ ├── html5parser.pyc │ │ │ ├── soupparser.pyc │ │ │ ├── usedoctest.pyc │ │ │ ├── _html5builder.pyc │ │ │ ├── usedoctest.py │ │ │ ├── ElementSoup.py │ │ │ ├── _diffcommand.py │ │ │ ├── _setmixin.py │ │ │ ├── _html5builder.py │ │ │ ├── defs.py │ │ │ ├── builder.py │ │ │ └── soupparser.py │ │ ├── objectify.so │ │ ├── _elementpath.pyc │ │ ├── usedoctest.pyc │ │ ├── ElementInclude.pyc │ │ ├── doctestcompare.pyc │ │ ├── pyclasslookup.pyc │ │ ├── pyclasslookup.py │ │ ├── isoschematron │ │ │ ├── __init__.pyc │ │ │ └── resources │ │ │ │ └── xsl │ │ │ │ ├── iso-schematron-xslt1 │ │ │ │ ├── iso_schematron_message.xsl │ │ │ │ └── readme.txt │ │ │ │ ├── RNG2Schtrn.xsl │ │ │ │ └── XSD2Schtrn.xsl │ │ ├── usedoctest.py │ │ ├── __init__.py │ │ └── cssselect.py │ ├── lxml-3.4.4-py2.7.egg-info │ │ ├── not-zip-safe │ │ ├── top_level.txt │ │ ├── dependency_links.txt │ │ ├── requires.txt │ │ ├── installed-files.txt │ │ └── PKG-INFO │ ├── requests │ │ ├── packages │ │ │ ├── urllib3 │ │ │ │ ├── contrib │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── __init__.pyc │ │ │ │ │ ├── ntlmpool.pyc │ │ │ │ │ ├── pyopenssl.pyc │ │ │ │ │ └── ntlmpool.py │ │ │ │ ├── packages │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── six.pyc │ │ │ │ │ ├── __init__.pyc │ │ │ │ │ ├── ordered_dict.pyc │ │ │ │ │ └── ssl_match_hostname │ │ │ │ │ │ ├── __init__.pyc │ │ │ │ │ │ ├── _implementation.pyc │ │ │ │ │ │ ├── __init__.py │ │ │ │ │ │ └── _implementation.py │ │ │ │ ├── fields.pyc │ │ │ │ ├── __init__.pyc │ │ │ │ ├── filepost.pyc │ │ │ │ ├── request.pyc │ │ │ │ ├── response.pyc │ │ │ │ ├── util │ │ │ │ │ ├── url.pyc │ │ │ │ │ ├── retry.pyc │ │ │ │ │ ├── ssl_.pyc │ │ │ │ │ ├── __init__.pyc │ │ │ │ │ ├── request.pyc │ │ │ │ │ ├── response.pyc │ │ │ │ │ ├── timeout.pyc │ │ │ │ │ ├── connection.pyc │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── response.py │ │ │ │ │ ├── request.py │ │ │ │ │ └── connection.py │ │ │ │ ├── connection.pyc │ │ │ │ ├── exceptions.pyc │ │ │ │ ├── poolmanager.pyc │ │ │ │ ├── _collections.pyc │ │ │ │ ├── connectionpool.pyc │ │ │ │ ├── __init__.py │ │ │ │ ├── filepost.py │ │ │ │ └── exceptions.py │ │ │ ├── __init__.py │ │ │ ├── __init__.pyc │ │ │ └── chardet │ │ │ │ ├── compat.pyc │ │ │ │ ├── escsm.pyc │ │ │ │ ├── jpcntx.pyc │ │ │ │ ├── mbcssm.pyc │ │ │ │ ├── __init__.pyc │ │ │ │ ├── big5freq.pyc │ │ │ │ ├── jisfreq.pyc │ │ │ │ ├── big5prober.pyc │ │ │ │ ├── chardetect.pyc │ │ │ │ ├── constants.pyc │ │ │ │ ├── cp949prober.pyc │ │ │ │ ├── escprober.pyc │ │ │ │ ├── eucjpprober.pyc │ │ │ │ ├── euckrfreq.pyc │ │ │ │ ├── euckrprober.pyc │ │ │ │ ├── euctwfreq.pyc │ │ │ │ ├── euctwprober.pyc │ │ │ │ ├── gb2312freq.pyc │ │ │ │ ├── sjisprober.pyc │ │ │ │ ├── utf8prober.pyc │ │ │ │ ├── charsetprober.pyc │ │ │ │ ├── gb2312prober.pyc │ │ │ │ ├── hebrewprober.pyc │ │ │ │ ├── langthaimodel.pyc │ │ │ │ ├── latin1prober.pyc │ │ │ │ ├── chardistribution.pyc │ │ │ │ ├── langgreekmodel.pyc │ │ │ │ ├── langhebrewmodel.pyc │ │ │ │ ├── mbcharsetprober.pyc │ │ │ │ ├── mbcsgroupprober.pyc │ │ │ │ ├── sbcharsetprober.pyc │ │ │ │ ├── sbcsgroupprober.pyc │ │ │ │ ├── charsetgroupprober.pyc │ │ │ │ ├── codingstatemachine.pyc │ │ │ │ ├── langbulgarianmodel.pyc │ │ │ │ ├── langcyrillicmodel.pyc │ │ │ │ ├── langhungarianmodel.pyc │ │ │ │ ├── universaldetector.pyc │ │ │ │ ├── compat.py │ │ │ │ ├── __init__.py │ │ │ │ ├── constants.py │ │ │ │ ├── euctwprober.py │ │ │ │ ├── euckrprober.py │ │ │ │ ├── gb2312prober.py │ │ │ │ ├── big5prober.py │ │ │ │ ├── cp949prober.py │ │ │ │ ├── charsetprober.py │ │ │ │ ├── mbcsgroupprober.py │ │ │ │ ├── codingstatemachine.py │ │ │ │ ├── chardetect.py │ │ │ │ ├── utf8prober.py │ │ │ │ ├── escprober.py │ │ │ │ ├── sbcsgroupprober.py │ │ │ │ ├── mbcharsetprober.py │ │ │ │ ├── eucjpprober.py │ │ │ │ ├── sjisprober.py │ │ │ │ ├── charsetgroupprober.py │ │ │ │ ├── sbcharsetprober.py │ │ │ │ └── latin1prober.py │ │ ├── api.pyc │ │ ├── auth.pyc │ │ ├── certs.pyc │ │ ├── hooks.pyc │ │ ├── utils.pyc │ │ ├── __init__.pyc │ │ ├── adapters.pyc │ │ ├── compat.pyc │ │ ├── cookies.pyc │ │ ├── models.pyc │ │ ├── sessions.pyc │ │ ├── exceptions.pyc │ │ ├── structures.pyc │ │ ├── status_codes.pyc │ │ ├── certs.py │ │ ├── hooks.py │ │ ├── compat.py │ │ ├── __init__.py │ │ ├── exceptions.py │ │ ├── structures.py │ │ ├── status_codes.py │ │ └── api.py │ └── requests-2.7.0.dist-info │ │ ├── top_level.txt │ │ ├── WHEEL │ │ └── metadata.json ├── Alfred_Workflow-1.13-py2.7.egg-info │ ├── not-zip-safe │ ├── dependency_links.txt │ ├── top_level.txt │ ├── installed-files.txt │ └── SOURCES.txt ├── icon.png ├── appbar.check.png ├── appbar.question.png ├── E58B4AFD-77EB-493A-BC02-7AC3F89BE458.png ├── README.md ├── info.plist └── stackoverflow.py ├── demo.gif ├── StackOverflow.alfredworkflow └── README.md /src/workflow/version: -------------------------------------------------------------------------------- 1 | 1.13 -------------------------------------------------------------------------------- /src/lib/lxml/includes/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/lib/lxml-3.4.4-py2.7.egg-info/not-zip-safe: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/contrib/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Alfred_Workflow-1.13-py2.7.egg-info/not-zip-safe: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/lib/lxml-3.4.4-py2.7.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | lxml 2 | -------------------------------------------------------------------------------- /src/lib/lxml-3.4.4-py2.7.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/lib/requests-2.7.0.dist-info/top_level.txt: -------------------------------------------------------------------------------- 1 | requests 2 | -------------------------------------------------------------------------------- /src/Alfred_Workflow-1.13-py2.7.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/Alfred_Workflow-1.13-py2.7.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | workflow 2 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/demo.gif -------------------------------------------------------------------------------- /src/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/icon.png -------------------------------------------------------------------------------- /src/appbar.check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/appbar.check.png -------------------------------------------------------------------------------- /src/lib/lxml/etree.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/etree.so -------------------------------------------------------------------------------- /src/lib/lxml/sax.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/sax.pyc -------------------------------------------------------------------------------- /src/workflow/web.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/workflow/web.pyc -------------------------------------------------------------------------------- /src/appbar.question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/appbar.question.png -------------------------------------------------------------------------------- /src/lib/lxml/builder.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/builder.pyc -------------------------------------------------------------------------------- /src/lib/requests/api.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/api.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import urllib3 4 | -------------------------------------------------------------------------------- /src/workflow/update.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/workflow/update.pyc -------------------------------------------------------------------------------- /src/lib/lxml/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/__init__.pyc -------------------------------------------------------------------------------- /src/lib/lxml/cssselect.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/cssselect.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/defs.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/defs.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/diff.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/diff.pyc -------------------------------------------------------------------------------- /src/lib/lxml/objectify.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/objectify.so -------------------------------------------------------------------------------- /src/lib/requests/auth.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/auth.pyc -------------------------------------------------------------------------------- /src/lib/requests/certs.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/certs.pyc -------------------------------------------------------------------------------- /src/lib/requests/hooks.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/hooks.pyc -------------------------------------------------------------------------------- /src/lib/requests/utils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/utils.pyc -------------------------------------------------------------------------------- /src/workflow/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/workflow/__init__.pyc -------------------------------------------------------------------------------- /src/workflow/workflow.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/workflow/workflow.pyc -------------------------------------------------------------------------------- /StackOverflow.alfredworkflow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/StackOverflow.alfredworkflow -------------------------------------------------------------------------------- /src/lib/lxml/_elementpath.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/_elementpath.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/builder.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/builder.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/clean.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/clean.pyc -------------------------------------------------------------------------------- /src/lib/lxml/includes/lxml-version.h: -------------------------------------------------------------------------------- 1 | #ifndef LXML_VERSION_STRING 2 | #define LXML_VERSION_STRING "3.4.4" 3 | #endif 4 | -------------------------------------------------------------------------------- /src/lib/lxml/usedoctest.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/usedoctest.pyc -------------------------------------------------------------------------------- /src/lib/requests/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/__init__.pyc -------------------------------------------------------------------------------- /src/lib/requests/adapters.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/adapters.pyc -------------------------------------------------------------------------------- /src/lib/requests/compat.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/compat.pyc -------------------------------------------------------------------------------- /src/lib/requests/cookies.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/cookies.pyc -------------------------------------------------------------------------------- /src/lib/requests/models.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/models.pyc -------------------------------------------------------------------------------- /src/lib/requests/sessions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/sessions.pyc -------------------------------------------------------------------------------- /src/workflow/background.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/workflow/background.pyc -------------------------------------------------------------------------------- /src/lib/lxml/ElementInclude.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/ElementInclude.pyc -------------------------------------------------------------------------------- /src/lib/lxml/doctestcompare.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/doctestcompare.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/__init__.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/_setmixin.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/_setmixin.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/formfill.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/formfill.pyc -------------------------------------------------------------------------------- /src/lib/lxml/pyclasslookup.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/pyclasslookup.pyc -------------------------------------------------------------------------------- /src/lib/requests/exceptions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/exceptions.pyc -------------------------------------------------------------------------------- /src/lib/requests/structures.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/structures.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/ElementSoup.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/ElementSoup.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/_diffcommand.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/_diffcommand.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/html5parser.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/html5parser.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/soupparser.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/soupparser.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/usedoctest.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/usedoctest.pyc -------------------------------------------------------------------------------- /src/lib/lxml/includes/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/includes/__init__.pyc -------------------------------------------------------------------------------- /src/lib/lxml/pyclasslookup.py: -------------------------------------------------------------------------------- 1 | # dummy module for backwards compatibility 2 | 3 | from lxml.etree import PythonElementClassLookup 4 | -------------------------------------------------------------------------------- /src/lib/requests/status_codes.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/status_codes.pyc -------------------------------------------------------------------------------- /src/lib/lxml/html/_html5builder.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/html/_html5builder.pyc -------------------------------------------------------------------------------- /src/lib/lxml/includes/config.pxd: -------------------------------------------------------------------------------- 1 | cdef extern from "etree_defs.h": 2 | cdef bint ENABLE_THREADING 3 | cdef bint ENABLE_SCHEMATRON 4 | -------------------------------------------------------------------------------- /src/lib/lxml/isoschematron/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/lxml/isoschematron/__init__.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/__init__.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import ssl_match_hostname 4 | 5 | -------------------------------------------------------------------------------- /src/E58B4AFD-77EB-493A-BC02-7AC3F89BE458.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/E58B4AFD-77EB-493A-BC02-7AC3F89BE458.png -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/compat.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/compat.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/escsm.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/escsm.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/jpcntx.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/jpcntx.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/mbcssm.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/mbcssm.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/fields.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/fields.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/__init__.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/big5freq.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/big5freq.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/jisfreq.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/jisfreq.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/__init__.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/filepost.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/filepost.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/request.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/request.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/response.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/response.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/url.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/util/url.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/big5prober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/big5prober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/chardetect.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/chardetect.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/constants.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/constants.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/cp949prober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/cp949prober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/escprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/escprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/eucjpprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/eucjpprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/euckrfreq.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/euckrfreq.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/euckrprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/euckrprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/euctwfreq.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/euctwfreq.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/euctwprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/euctwprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/gb2312freq.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/gb2312freq.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/sjisprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/sjisprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/utf8prober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/utf8prober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/connection.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/connection.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/exceptions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/exceptions.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/poolmanager.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/poolmanager.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/retry.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/util/retry.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/ssl_.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/util/ssl_.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/charsetprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/charsetprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/gb2312prober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/gb2312prober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/hebrewprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/hebrewprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/langthaimodel.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/langthaimodel.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/latin1prober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/latin1prober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/_collections.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/_collections.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/packages/six.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/packages/six.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/util/__init__.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/request.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/util/request.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/response.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/util/response.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/timeout.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/util/timeout.pyc -------------------------------------------------------------------------------- /src/lib/requests-2.7.0.dist-info/WHEEL: -------------------------------------------------------------------------------- 1 | Wheel-Version: 1.0 2 | Generator: bdist_wheel (0.24.0) 3 | Root-Is-Purelib: true 4 | Tag: py2-none-any 5 | Tag: py3-none-any 6 | 7 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/chardistribution.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/chardistribution.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/langgreekmodel.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/langgreekmodel.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/langhebrewmodel.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/langhebrewmodel.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/mbcharsetprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/mbcharsetprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/mbcsgroupprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/mbcsgroupprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/sbcharsetprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/sbcharsetprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/sbcsgroupprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/sbcsgroupprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/connectionpool.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/connectionpool.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/contrib/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/contrib/__init__.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/contrib/ntlmpool.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/contrib/ntlmpool.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/connection.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/util/connection.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/charsetgroupprober.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/charsetgroupprober.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/codingstatemachine.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/codingstatemachine.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/langbulgarianmodel.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/langbulgarianmodel.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/langcyrillicmodel.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/langcyrillicmodel.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/langhungarianmodel.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/langhungarianmodel.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/universaldetector.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/chardet/universaldetector.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/contrib/pyopenssl.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/contrib/pyopenssl.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/packages/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/packages/__init__.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/packages/ordered_dict.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/packages/ordered_dict.pyc -------------------------------------------------------------------------------- /src/lib/lxml/includes/uri.pxd: -------------------------------------------------------------------------------- 1 | cdef extern from "libxml/uri.h": 2 | ctypedef struct xmlURI 3 | 4 | cdef xmlURI* xmlParseURI(char* str) 5 | cdef void xmlFreeURI(xmlURI* uri) 6 | -------------------------------------------------------------------------------- /src/lib/lxml-3.4.4-py2.7.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | [source] 4 | Cython>=0.20 5 | 6 | [cssselect] 7 | cssselect>=0.7 8 | 9 | [html5] 10 | html5lib 11 | 12 | [htmlsoup] 13 | BeautifulSoup4 -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Que3216/alfred-stack-overflow/HEAD/src/lib/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyc -------------------------------------------------------------------------------- /src/lib/lxml/usedoctest.py: -------------------------------------------------------------------------------- 1 | """Doctest module for XML comparison. 2 | 3 | Usage:: 4 | 5 | >>> import lxml.usedoctest 6 | >>> # now do your XML doctests ... 7 | 8 | See `lxml.doctestcompare` 9 | """ 10 | 11 | from lxml import doctestcompare 12 | 13 | doctestcompare.temp_install(del_module=__name__) 14 | -------------------------------------------------------------------------------- /src/lib/lxml/html/usedoctest.py: -------------------------------------------------------------------------------- 1 | """Doctest module for HTML comparison. 2 | 3 | Usage:: 4 | 5 | >>> import lxml.html.usedoctest 6 | >>> # now do your HTML doctests ... 7 | 8 | See `lxml.doctestcompare`. 9 | """ 10 | 11 | from lxml import doctestcompare 12 | 13 | doctestcompare.temp_install(html=True, del_module=__name__) 14 | -------------------------------------------------------------------------------- /src/lib/lxml/html/ElementSoup.py: -------------------------------------------------------------------------------- 1 | __doc__ = """Legacy interface to the BeautifulSoup HTML parser. 2 | """ 3 | 4 | __all__ = ["parse", "convert_tree"] 5 | 6 | from soupparser import convert_tree, parse as _parse 7 | 8 | def parse(file, beautifulsoup=None, makeelement=None): 9 | root = _parse(file, beautifulsoup=beautifulsoup, makeelement=makeelement) 10 | return root.getroot() 11 | -------------------------------------------------------------------------------- /src/Alfred_Workflow-1.13-py2.7.egg-info/installed-files.txt: -------------------------------------------------------------------------------- 1 | ../workflow/__init__.py 2 | ../workflow/background.py 3 | ../workflow/update.py 4 | ../workflow/web.py 5 | ../workflow/workflow.py 6 | ../workflow/version 7 | ../workflow/__init__.pyc 8 | ../workflow/background.pyc 9 | ../workflow/update.pyc 10 | ../workflow/web.pyc 11 | ../workflow/workflow.pyc 12 | ./ 13 | dependency_links.txt 14 | not-zip-safe 15 | PKG-INFO 16 | SOURCES.txt 17 | top_level.txt 18 | -------------------------------------------------------------------------------- /src/Alfred_Workflow-1.13-py2.7.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | MANIFEST.in 2 | README.rst 3 | setup.cfg 4 | setup.py 5 | Alfred_Workflow.egg-info/PKG-INFO 6 | Alfred_Workflow.egg-info/SOURCES.txt 7 | Alfred_Workflow.egg-info/dependency_links.txt 8 | Alfred_Workflow.egg-info/not-zip-safe 9 | Alfred_Workflow.egg-info/top_level.txt 10 | workflow/__init__.py 11 | workflow/background.py 12 | workflow/update.py 13 | workflow/version 14 | workflow/web.py 15 | workflow/workflow.py -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | # Python 3.2+ 3 | from ssl import CertificateError, match_hostname 4 | except ImportError: 5 | try: 6 | # Backport of the function from a pypi module 7 | from backports.ssl_match_hostname import CertificateError, match_hostname 8 | except ImportError: 9 | # Our vendored copy 10 | from ._implementation import CertificateError, match_hostname 11 | 12 | # Not needed, but documenting what we provide. 13 | __all__ = ('CertificateError', 'match_hostname') 14 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/__init__.py: -------------------------------------------------------------------------------- 1 | # For backwards compatibility, provide imports that used to be here. 2 | from .connection import is_connection_dropped 3 | from .request import make_headers 4 | from .response import is_fp_closed 5 | from .ssl_ import ( 6 | SSLContext, 7 | HAS_SNI, 8 | assert_fingerprint, 9 | resolve_cert_reqs, 10 | resolve_ssl_version, 11 | ssl_wrap_socket, 12 | ) 13 | from .timeout import ( 14 | current_time, 15 | Timeout, 16 | ) 17 | 18 | from .retry import Retry 19 | from .url import ( 20 | get_host, 21 | parse_url, 22 | split_first, 23 | Url, 24 | ) 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Alfred Stack Overflow 2 | 3 | Get answers to simple questions like *"python function syntax"*, without having to open your web browser: 4 | 5 | ![Alt text](demo.gif?raw=true "Demo of searching for the python lambda syntax") 6 | 7 | ### Usage 8 | 9 | Type `so` followed by your query. 10 | 11 | The first result shows the first code block or paragraph in the top voted answer to the most relevant question. To view the full answer press: `CMD` + `L`. 12 | 13 | The following results show the other questions. 14 | 15 | To view all the answers for a question press: `TAB` 16 | 17 | To open the web page for the question press: `ENTER` -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | ## Alfred Stack Overflow 2 | 3 | Gets you answers to simple questions like *"python function syntax"*, without having to open your web browser: 4 | 5 | ![Alt text](demo.gif?raw=true "Demo of searching for the python lambda syntax") 6 | 7 | ### Usage 8 | 9 | Type `so` followed by your query. 10 | 11 | The first result shows the first code block or paragraph in the top voted answer to the most relevant question. To view the full answer press: `CMD` + `L`. 12 | 13 | The following results show the other questions. 14 | 15 | To view all the answers for a question press: `TAB` 16 | 17 | To open the web page for the question press: `ENTER` -------------------------------------------------------------------------------- /src/lib/lxml/__init__.py: -------------------------------------------------------------------------------- 1 | # this is a package 2 | 3 | def get_include(): 4 | """ 5 | Returns a list of header include paths (for lxml itself, libxml2 6 | and libxslt) needed to compile C code against lxml if it was built 7 | with statically linked libraries. 8 | """ 9 | import os 10 | lxml_path = __path__[0] 11 | include_path = os.path.join(lxml_path, 'includes') 12 | includes = [include_path, lxml_path] 13 | 14 | for name in os.listdir(include_path): 15 | path = os.path.join(include_path, name) 16 | if os.path.isdir(path): 17 | includes.append(path) 18 | 19 | return includes 20 | 21 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/response.py: -------------------------------------------------------------------------------- 1 | def is_fp_closed(obj): 2 | """ 3 | Checks whether a given file-like object is closed. 4 | 5 | :param obj: 6 | The file-like object to check. 7 | """ 8 | 9 | try: 10 | # Check via the official file-like-object way. 11 | return obj.closed 12 | except AttributeError: 13 | pass 14 | 15 | try: 16 | # Check if the object is a container for another file-like object that 17 | # gets released on exhaustion (e.g. HTTPResponse). 18 | return obj.fp is None 19 | except AttributeError: 20 | pass 21 | 22 | raise ValueError("Unable to determine whether fp is closed.") 23 | -------------------------------------------------------------------------------- /src/lib/requests/certs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | certs.py 6 | ~~~~~~~~ 7 | 8 | This module returns the preferred default CA certificate bundle. 9 | 10 | If you are packaging Requests, e.g., for a Linux distribution or a managed 11 | environment, you can change the definition of where() to return a separately 12 | packaged CA bundle. 13 | """ 14 | import os.path 15 | 16 | try: 17 | from certifi import where 18 | except ImportError: 19 | def where(): 20 | """Return the preferred certificate bundle.""" 21 | # vendored bundle inside Requests 22 | return os.path.join(os.path.dirname(__file__), 'cacert.pem') 23 | 24 | if __name__ == '__main__': 25 | print(where()) 26 | -------------------------------------------------------------------------------- /src/lib/lxml/includes/dtdvalid.pxd: -------------------------------------------------------------------------------- 1 | from lxml.includes cimport tree 2 | from lxml.includes.tree cimport xmlDoc, xmlDtd 3 | 4 | cdef extern from "libxml/valid.h" nogil: 5 | ctypedef void (*xmlValidityErrorFunc)(void * ctx, const char * msg, ...) 6 | ctypedef void (*xmlValidityWarningFunc)(void * ctx, const char * msg, ...) 7 | 8 | ctypedef struct xmlValidCtxt: 9 | void *userData 10 | xmlValidityErrorFunc error 11 | xmlValidityWarningFunc warning 12 | 13 | cdef xmlValidCtxt* xmlNewValidCtxt() 14 | cdef void xmlFreeValidCtxt(xmlValidCtxt* cur) 15 | 16 | cdef int xmlValidateDtd(xmlValidCtxt* ctxt, xmlDoc* doc, xmlDtd* dtd) 17 | cdef tree.xmlElement* xmlGetDtdElementDesc( 18 | xmlDtd* dtd, tree.const_xmlChar* name) 19 | -------------------------------------------------------------------------------- /src/lib/requests-2.7.0.dist-info/metadata.json: -------------------------------------------------------------------------------- 1 | {"license": "Apache 2.0", "name": "requests", "metadata_version": "2.0", "generator": "bdist_wheel (0.24.0)", "summary": "Python HTTP for Humans.", "run_requires": [{"requires": ["pyOpenSSL", "ndg-httpsclient", "pyasn1"], "extra": "security"}], "version": "2.7.0", "extensions": {"python.details": {"project_urls": {"Home": "http://python-requests.org"}, "document_names": {"description": "DESCRIPTION.rst"}, "contacts": [{"role": "author", "email": "me@kennethreitz.com", "name": "Kenneth Reitz"}]}}, "classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Natural Language :: English", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4"], "extras": ["security"]} -------------------------------------------------------------------------------- /src/lib/lxml/includes/xinclude.pxd: -------------------------------------------------------------------------------- 1 | from lxml.includes.tree cimport xmlDoc, xmlNode 2 | 3 | cdef extern from "libxml/xinclude.h": 4 | 5 | ctypedef struct xmlXIncludeCtxt 6 | 7 | cdef int xmlXIncludeProcess(xmlDoc* doc) nogil 8 | cdef int xmlXIncludeProcessFlags(xmlDoc* doc, int parser_opts) nogil 9 | cdef int xmlXIncludeProcessTree(xmlNode* doc) nogil 10 | cdef int xmlXIncludeProcessTreeFlags(xmlNode* doc, int parser_opts) nogil 11 | 12 | # libxml2 >= 2.7.4 13 | cdef int xmlXIncludeProcessTreeFlagsData( 14 | xmlNode* doc, int parser_opts, void* data) nogil 15 | 16 | cdef xmlXIncludeCtxt* xmlXIncludeNewContext(xmlDoc* doc) nogil 17 | cdef int xmlXIncludeProcessNode(xmlXIncludeCtxt* ctxt, xmlNode* node) nogil 18 | cdef int xmlXIncludeSetFlags(xmlXIncludeCtxt* ctxt, int flags) nogil 19 | 20 | # libxml2 >= 2.6.27 21 | cdef int xmlXIncludeProcessFlagsData( 22 | xmlDoc* doc, int flags, void* data) nogil 23 | -------------------------------------------------------------------------------- /src/lib/requests/hooks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.hooks 5 | ~~~~~~~~~~~~~~ 6 | 7 | This module provides the capabilities for the Requests hooks system. 8 | 9 | Available hooks: 10 | 11 | ``response``: 12 | The response generated from a Request. 13 | 14 | """ 15 | 16 | 17 | HOOKS = ['response'] 18 | 19 | 20 | def default_hooks(): 21 | hooks = {} 22 | for event in HOOKS: 23 | hooks[event] = [] 24 | return hooks 25 | 26 | # TODO: response is the only one 27 | 28 | 29 | def dispatch_hook(key, hooks, hook_data, **kwargs): 30 | """Dispatches a hook dictionary on a given piece of data.""" 31 | 32 | hooks = hooks or dict() 33 | 34 | if key in hooks: 35 | hooks = hooks.get(key) 36 | 37 | if hasattr(hooks, '__call__'): 38 | hooks = [hooks] 39 | 40 | for hook in hooks: 41 | _hook_data = hook(hook_data, **kwargs) 42 | if _hook_data is not None: 43 | hook_data = _hook_data 44 | 45 | return hook_data 46 | -------------------------------------------------------------------------------- /src/lib/lxml/includes/c14n.pxd: -------------------------------------------------------------------------------- 1 | from lxml.includes.tree cimport xmlDoc, xmlOutputBuffer, xmlChar 2 | from lxml.includes.xpath cimport xmlNodeSet 3 | 4 | cdef extern from "libxml/c14n.h": 5 | cdef int xmlC14NDocDumpMemory(xmlDoc* doc, 6 | xmlNodeSet* nodes, 7 | int exclusive, 8 | xmlChar** inclusive_ns_prefixes, 9 | int with_comments, 10 | xmlChar** doc_txt_ptr) nogil 11 | 12 | cdef int xmlC14NDocSave(xmlDoc* doc, 13 | xmlNodeSet* nodes, 14 | int exclusive, 15 | xmlChar** inclusive_ns_prefixes, 16 | int with_comments, 17 | char* filename, 18 | int compression) nogil 19 | 20 | cdef int xmlC14NDocSaveTo(xmlDoc* doc, 21 | xmlNodeSet* nodes, 22 | int exclusive, 23 | xmlChar** inclusive_ns_prefixes, 24 | int with_comments, 25 | xmlOutputBuffer* buffer) nogil 26 | 27 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/compat.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # Contributor(s): 3 | # Ian Cordasco - port to Python 4 | # 5 | # This library is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU Lesser General Public 7 | # License as published by the Free Software Foundation; either 8 | # version 2.1 of the License, or (at your option) any later version. 9 | # 10 | # This library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with this library; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | # 02110-1301 USA 19 | ######################### END LICENSE BLOCK ######################### 20 | 21 | import sys 22 | 23 | 24 | if sys.version_info < (3, 0): 25 | base_str = (str, unicode) 26 | else: 27 | base_str = (bytes, str) 28 | 29 | 30 | def wrap_ord(a): 31 | if sys.version_info < (3, 0) and isinstance(a, base_str): 32 | return ord(a) 33 | else: 34 | return a 35 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/__init__.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # This library is free software; you can redistribute it and/or 3 | # modify it under the terms of the GNU Lesser General Public 4 | # License as published by the Free Software Foundation; either 5 | # version 2.1 of the License, or (at your option) any later version. 6 | # 7 | # This library is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | # Lesser General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Lesser General Public 13 | # License along with this library; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 15 | # 02110-1301 USA 16 | ######################### END LICENSE BLOCK ######################### 17 | 18 | __version__ = "2.3.0" 19 | from sys import version_info 20 | 21 | 22 | def detect(aBuf): 23 | if ((version_info < (3, 0) and isinstance(aBuf, unicode)) or 24 | (version_info >= (3, 0) and not isinstance(aBuf, bytes))): 25 | raise ValueError('Expected a bytes object, not a unicode object') 26 | 27 | from . import universaldetector 28 | u = universaldetector.UniversalDetector() 29 | u.reset() 30 | u.feed(aBuf) 31 | u.close() 32 | return u.result 33 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/constants.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | _debug = 0 30 | 31 | eDetecting = 0 32 | eFoundIt = 1 33 | eNotMe = 2 34 | 35 | eStart = 0 36 | eError = 1 37 | eItsMe = 2 38 | 39 | SHORTCUT_THRESHOLD = 0.95 40 | -------------------------------------------------------------------------------- /src/lib/requests/compat.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | pythoncompat 5 | """ 6 | 7 | from .packages import chardet 8 | 9 | import sys 10 | 11 | # ------- 12 | # Pythons 13 | # ------- 14 | 15 | # Syntax sugar. 16 | _ver = sys.version_info 17 | 18 | #: Python 2.x? 19 | is_py2 = (_ver[0] == 2) 20 | 21 | #: Python 3.x? 22 | is_py3 = (_ver[0] == 3) 23 | 24 | try: 25 | import simplejson as json 26 | except (ImportError, SyntaxError): 27 | # simplejson does not support Python 3.2, it throws a SyntaxError 28 | # because of u'...' Unicode literals. 29 | import json 30 | 31 | # --------- 32 | # Specifics 33 | # --------- 34 | 35 | if is_py2: 36 | from urllib import quote, unquote, quote_plus, unquote_plus, urlencode, getproxies, proxy_bypass 37 | from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag 38 | from urllib2 import parse_http_list 39 | import cookielib 40 | from Cookie import Morsel 41 | from StringIO import StringIO 42 | from .packages.urllib3.packages.ordered_dict import OrderedDict 43 | 44 | builtin_str = str 45 | bytes = str 46 | str = unicode 47 | basestring = basestring 48 | numeric_types = (int, long, float) 49 | 50 | elif is_py3: 51 | from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag 52 | from urllib.request import parse_http_list, getproxies, proxy_bypass 53 | from http import cookiejar as cookielib 54 | from http.cookies import Morsel 55 | from io import StringIO 56 | from collections import OrderedDict 57 | 58 | builtin_str = str 59 | str = str 60 | bytes = bytes 61 | basestring = (str, bytes) 62 | numeric_types = (int, float) 63 | -------------------------------------------------------------------------------- /src/lib/lxml/includes/schematron.pxd: -------------------------------------------------------------------------------- 1 | from lxml.includes cimport xmlerror 2 | from lxml.includes.tree cimport xmlDoc 3 | 4 | cdef extern from "libxml/schematron.h": 5 | ctypedef struct xmlSchematron 6 | ctypedef struct xmlSchematronParserCtxt 7 | ctypedef struct xmlSchematronValidCtxt 8 | 9 | ctypedef enum xmlSchematronValidOptions: 10 | XML_SCHEMATRON_OUT_QUIET = 1 # quiet no report 11 | XML_SCHEMATRON_OUT_TEXT = 2 # build a textual report 12 | XML_SCHEMATRON_OUT_XML = 4 # output SVRL 13 | XML_SCHEMATRON_OUT_ERROR = 8 # output via xmlStructuredErrorFunc 14 | XML_SCHEMATRON_OUT_FILE = 256 # output to a file descriptor 15 | XML_SCHEMATRON_OUT_BUFFER = 512 # output to a buffer 16 | XML_SCHEMATRON_OUT_IO = 1024 # output to I/O mechanism 17 | 18 | cdef xmlSchematronParserCtxt* xmlSchematronNewDocParserCtxt( 19 | xmlDoc* doc) nogil 20 | cdef xmlSchematronParserCtxt* xmlSchematronNewParserCtxt( 21 | char* filename) nogil 22 | cdef xmlSchematronValidCtxt* xmlSchematronNewValidCtxt( 23 | xmlSchematron* schema, int options) nogil 24 | 25 | cdef xmlSchematron* xmlSchematronParse(xmlSchematronParserCtxt* ctxt) nogil 26 | cdef int xmlSchematronValidateDoc(xmlSchematronValidCtxt* ctxt, 27 | xmlDoc* instance) nogil 28 | 29 | cdef void xmlSchematronFreeParserCtxt(xmlSchematronParserCtxt* ctxt) nogil 30 | cdef void xmlSchematronFreeValidCtxt(xmlSchematronValidCtxt* ctxt) nogil 31 | cdef void xmlSchematronFree(xmlSchematron* schema) nogil 32 | cdef void xmlSchematronSetValidStructuredErrors( 33 | xmlSchematronValidCtxt* ctxt, 34 | xmlerror.xmlStructuredErrorFunc error_func, void *data) 35 | -------------------------------------------------------------------------------- /src/lib/lxml/includes/xmlschema.pxd: -------------------------------------------------------------------------------- 1 | from lxml.includes.tree cimport xmlDoc 2 | from lxml.includes.xmlparser cimport xmlSAXHandler 3 | from lxml.includes.xmlerror cimport xmlStructuredErrorFunc 4 | 5 | cdef extern from "libxml/xmlschemas.h": 6 | ctypedef struct xmlSchema 7 | ctypedef struct xmlSchemaParserCtxt 8 | 9 | ctypedef struct xmlSchemaSAXPlugStruct 10 | ctypedef struct xmlSchemaValidCtxt 11 | 12 | ctypedef enum xmlSchemaValidOption: 13 | XML_SCHEMA_VAL_VC_I_CREATE = 1 14 | 15 | cdef xmlSchemaValidCtxt* xmlSchemaNewValidCtxt(xmlSchema* schema) nogil 16 | cdef void xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxt* ctxt, 17 | xmlStructuredErrorFunc serror, void *ctx) 18 | cdef void xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxt* ctxt, 19 | xmlStructuredErrorFunc serror, void *ctx) 20 | 21 | cdef int xmlSchemaValidateDoc(xmlSchemaValidCtxt* ctxt, xmlDoc* doc) nogil 22 | cdef xmlSchema* xmlSchemaParse(xmlSchemaParserCtxt* ctxt) nogil 23 | cdef xmlSchemaParserCtxt* xmlSchemaNewParserCtxt(char* URL) nogil 24 | cdef xmlSchemaParserCtxt* xmlSchemaNewDocParserCtxt(xmlDoc* doc) nogil 25 | cdef void xmlSchemaFree(xmlSchema* schema) nogil 26 | cdef void xmlSchemaFreeParserCtxt(xmlSchemaParserCtxt* ctxt) nogil 27 | cdef void xmlSchemaFreeValidCtxt(xmlSchemaValidCtxt* ctxt) nogil 28 | cdef int xmlSchemaSetValidOptions(xmlSchemaValidCtxt* ctxt, 29 | int options) nogil 30 | 31 | cdef xmlSchemaSAXPlugStruct* xmlSchemaSAXPlug(xmlSchemaValidCtxt* ctxt, 32 | xmlSAXHandler** sax, 33 | void** data) nogil 34 | cdef int xmlSchemaSAXUnplug(xmlSchemaSAXPlugStruct* sax_plug) 35 | cdef int xmlSchemaIsValid(xmlSchemaValidCtxt* ctxt) 36 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/euctwprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCTWDistributionAnalysis 31 | from .mbcssm import EUCTWSMModel 32 | 33 | class EUCTWProber(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(EUCTWSMModel) 37 | self._mDistributionAnalyzer = EUCTWDistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "EUC-TW" 42 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/euckrprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCKRDistributionAnalysis 31 | from .mbcssm import EUCKRSMModel 32 | 33 | 34 | class EUCKRProber(MultiByteCharSetProber): 35 | def __init__(self): 36 | MultiByteCharSetProber.__init__(self) 37 | self._mCodingSM = CodingStateMachine(EUCKRSMModel) 38 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis() 39 | self.reset() 40 | 41 | def get_charset_name(self): 42 | return "EUC-KR" 43 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/gb2312prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import GB2312DistributionAnalysis 31 | from .mbcssm import GB2312SMModel 32 | 33 | class GB2312Prober(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(GB2312SMModel) 37 | self._mDistributionAnalyzer = GB2312DistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "GB2312" 42 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/big5prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Communicator client code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import Big5DistributionAnalysis 31 | from .mbcssm import Big5SMModel 32 | 33 | 34 | class Big5Prober(MultiByteCharSetProber): 35 | def __init__(self): 36 | MultiByteCharSetProber.__init__(self) 37 | self._mCodingSM = CodingStateMachine(Big5SMModel) 38 | self._mDistributionAnalyzer = Big5DistributionAnalysis() 39 | self.reset() 40 | 41 | def get_charset_name(self): 42 | return "Big5" 43 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/cp949prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCKRDistributionAnalysis 31 | from .mbcssm import CP949SMModel 32 | 33 | 34 | class CP949Prober(MultiByteCharSetProber): 35 | def __init__(self): 36 | MultiByteCharSetProber.__init__(self) 37 | self._mCodingSM = CodingStateMachine(CP949SMModel) 38 | # NOTE: CP949 is a superset of EUC-KR, so the distribution should be 39 | # not different. 40 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis() 41 | self.reset() 42 | 43 | def get_charset_name(self): 44 | return "CP949" 45 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/charsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | from . import constants 30 | import re 31 | 32 | 33 | class CharSetProber: 34 | def __init__(self): 35 | pass 36 | 37 | def reset(self): 38 | self._mState = constants.eDetecting 39 | 40 | def get_charset_name(self): 41 | return None 42 | 43 | def feed(self, aBuf): 44 | pass 45 | 46 | def get_state(self): 47 | return self._mState 48 | 49 | def get_confidence(self): 50 | return 0.0 51 | 52 | def filter_high_bit_only(self, aBuf): 53 | aBuf = re.sub(b'([\x00-\x7F])+', b' ', aBuf) 54 | return aBuf 55 | 56 | def filter_without_english_letters(self, aBuf): 57 | aBuf = re.sub(b'([A-Za-z])+', b' ', aBuf) 58 | return aBuf 59 | 60 | def filter_with_english_letters(self, aBuf): 61 | # TODO 62 | return aBuf 63 | -------------------------------------------------------------------------------- /src/lib/requests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # __ 4 | # /__) _ _ _ _ _/ _ 5 | # / ( (- (/ (/ (- _) / _) 6 | # / 7 | 8 | """ 9 | requests HTTP library 10 | ~~~~~~~~~~~~~~~~~~~~~ 11 | 12 | Requests is an HTTP library, written in Python, for human beings. Basic GET 13 | usage: 14 | 15 | >>> import requests 16 | >>> r = requests.get('https://www.python.org') 17 | >>> r.status_code 18 | 200 19 | >>> 'Python is a programming language' in r.content 20 | True 21 | 22 | ... or POST: 23 | 24 | >>> payload = dict(key1='value1', key2='value2') 25 | >>> r = requests.post('http://httpbin.org/post', data=payload) 26 | >>> print(r.text) 27 | { 28 | ... 29 | "form": { 30 | "key2": "value2", 31 | "key1": "value1" 32 | }, 33 | ... 34 | } 35 | 36 | The other HTTP methods are supported - see `requests.api`. Full documentation 37 | is at . 38 | 39 | :copyright: (c) 2015 by Kenneth Reitz. 40 | :license: Apache 2.0, see LICENSE for more details. 41 | 42 | """ 43 | 44 | __title__ = 'requests' 45 | __version__ = '2.7.0' 46 | __build__ = 0x020700 47 | __author__ = 'Kenneth Reitz' 48 | __license__ = 'Apache 2.0' 49 | __copyright__ = 'Copyright 2015 Kenneth Reitz' 50 | 51 | # Attempt to enable urllib3's SNI support, if possible 52 | try: 53 | from .packages.urllib3.contrib import pyopenssl 54 | pyopenssl.inject_into_urllib3() 55 | except ImportError: 56 | pass 57 | 58 | from . import utils 59 | from .models import Request, Response, PreparedRequest 60 | from .api import request, get, head, post, patch, put, delete, options 61 | from .sessions import session, Session 62 | from .status_codes import codes 63 | from .exceptions import ( 64 | RequestException, Timeout, URLRequired, 65 | TooManyRedirects, HTTPError, ConnectionError 66 | ) 67 | 68 | # Set default logging handler to avoid "No handler found" warnings. 69 | import logging 70 | try: # Python 2.7+ 71 | from logging import NullHandler 72 | except ImportError: 73 | class NullHandler(logging.Handler): 74 | def emit(self, record): 75 | pass 76 | 77 | logging.getLogger(__name__).addHandler(NullHandler()) 78 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/mbcsgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # Proofpoint, Inc. 13 | # 14 | # This library is free software; you can redistribute it and/or 15 | # modify it under the terms of the GNU Lesser General Public 16 | # License as published by the Free Software Foundation; either 17 | # version 2.1 of the License, or (at your option) any later version. 18 | # 19 | # This library is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | # Lesser General Public License for more details. 23 | # 24 | # You should have received a copy of the GNU Lesser General Public 25 | # License along with this library; if not, write to the Free Software 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 27 | # 02110-1301 USA 28 | ######################### END LICENSE BLOCK ######################### 29 | 30 | from .charsetgroupprober import CharSetGroupProber 31 | from .utf8prober import UTF8Prober 32 | from .sjisprober import SJISProber 33 | from .eucjpprober import EUCJPProber 34 | from .gb2312prober import GB2312Prober 35 | from .euckrprober import EUCKRProber 36 | from .cp949prober import CP949Prober 37 | from .big5prober import Big5Prober 38 | from .euctwprober import EUCTWProber 39 | 40 | 41 | class MBCSGroupProber(CharSetGroupProber): 42 | def __init__(self): 43 | CharSetGroupProber.__init__(self) 44 | self._mProbers = [ 45 | UTF8Prober(), 46 | SJISProber(), 47 | EUCJPProber(), 48 | GB2312Prober(), 49 | EUCKRProber(), 50 | CP949Prober(), 51 | Big5Prober(), 52 | EUCTWProber() 53 | ] 54 | self.reset() 55 | -------------------------------------------------------------------------------- /src/lib/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | ( 51 | / 52 | ) 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | urllib3 - Thread-safe connection pooling and re-using. 3 | """ 4 | 5 | __author__ = 'Andrey Petrov (andrey.petrov@shazow.net)' 6 | __license__ = 'MIT' 7 | __version__ = '1.10.4' 8 | 9 | 10 | from .connectionpool import ( 11 | HTTPConnectionPool, 12 | HTTPSConnectionPool, 13 | connection_from_url 14 | ) 15 | 16 | from . import exceptions 17 | from .filepost import encode_multipart_formdata 18 | from .poolmanager import PoolManager, ProxyManager, proxy_from_url 19 | from .response import HTTPResponse 20 | from .util.request import make_headers 21 | from .util.url import get_host 22 | from .util.timeout import Timeout 23 | from .util.retry import Retry 24 | 25 | 26 | # Set default logging handler to avoid "No handler found" warnings. 27 | import logging 28 | try: # Python 2.7+ 29 | from logging import NullHandler 30 | except ImportError: 31 | class NullHandler(logging.Handler): 32 | def emit(self, record): 33 | pass 34 | 35 | logging.getLogger(__name__).addHandler(NullHandler()) 36 | 37 | def add_stderr_logger(level=logging.DEBUG): 38 | """ 39 | Helper for quickly adding a StreamHandler to the logger. Useful for 40 | debugging. 41 | 42 | Returns the handler after adding it. 43 | """ 44 | # This method needs to be in this __init__.py to get the __name__ correct 45 | # even if urllib3 is vendored within another package. 46 | logger = logging.getLogger(__name__) 47 | handler = logging.StreamHandler() 48 | handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s')) 49 | logger.addHandler(handler) 50 | logger.setLevel(level) 51 | logger.debug('Added a stderr logging handler to logger: %s' % __name__) 52 | return handler 53 | 54 | # ... Clean up. 55 | del NullHandler 56 | 57 | 58 | import warnings 59 | # SecurityWarning's always go off by default. 60 | warnings.simplefilter('always', exceptions.SecurityWarning, append=True) 61 | # InsecurePlatformWarning's don't vary between requests, so we keep it default. 62 | warnings.simplefilter('default', exceptions.InsecurePlatformWarning, 63 | append=True) 64 | 65 | def disable_warnings(category=exceptions.HTTPWarning): 66 | """ 67 | Helper for quickly disabling all urllib3 warnings. 68 | """ 69 | warnings.simplefilter('ignore', category) 70 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/request.py: -------------------------------------------------------------------------------- 1 | from base64 import b64encode 2 | 3 | from ..packages.six import b 4 | 5 | ACCEPT_ENCODING = 'gzip,deflate' 6 | 7 | 8 | def make_headers(keep_alive=None, accept_encoding=None, user_agent=None, 9 | basic_auth=None, proxy_basic_auth=None, disable_cache=None): 10 | """ 11 | Shortcuts for generating request headers. 12 | 13 | :param keep_alive: 14 | If ``True``, adds 'connection: keep-alive' header. 15 | 16 | :param accept_encoding: 17 | Can be a boolean, list, or string. 18 | ``True`` translates to 'gzip,deflate'. 19 | List will get joined by comma. 20 | String will be used as provided. 21 | 22 | :param user_agent: 23 | String representing the user-agent you want, such as 24 | "python-urllib3/0.6" 25 | 26 | :param basic_auth: 27 | Colon-separated username:password string for 'authorization: basic ...' 28 | auth header. 29 | 30 | :param proxy_basic_auth: 31 | Colon-separated username:password string for 'proxy-authorization: basic ...' 32 | auth header. 33 | 34 | :param disable_cache: 35 | If ``True``, adds 'cache-control: no-cache' header. 36 | 37 | Example:: 38 | 39 | >>> make_headers(keep_alive=True, user_agent="Batman/1.0") 40 | {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'} 41 | >>> make_headers(accept_encoding=True) 42 | {'accept-encoding': 'gzip,deflate'} 43 | """ 44 | headers = {} 45 | if accept_encoding: 46 | if isinstance(accept_encoding, str): 47 | pass 48 | elif isinstance(accept_encoding, list): 49 | accept_encoding = ','.join(accept_encoding) 50 | else: 51 | accept_encoding = ACCEPT_ENCODING 52 | headers['accept-encoding'] = accept_encoding 53 | 54 | if user_agent: 55 | headers['user-agent'] = user_agent 56 | 57 | if keep_alive: 58 | headers['connection'] = 'keep-alive' 59 | 60 | if basic_auth: 61 | headers['authorization'] = 'Basic ' + \ 62 | b64encode(b(basic_auth)).decode('utf-8') 63 | 64 | if proxy_basic_auth: 65 | headers['proxy-authorization'] = 'Basic ' + \ 66 | b64encode(b(proxy_basic_auth)).decode('utf-8') 67 | 68 | if disable_cache: 69 | headers['cache-control'] = 'no-cache' 70 | 71 | return headers 72 | -------------------------------------------------------------------------------- /src/lib/lxml/html/_diffcommand.py: -------------------------------------------------------------------------------- 1 | import optparse 2 | import sys 3 | import re 4 | import os 5 | from lxml.html.diff import htmldiff 6 | 7 | description = """\ 8 | """ 9 | 10 | parser = optparse.OptionParser( 11 | usage="%prog [OPTIONS] FILE1 FILE2\n" 12 | "%prog --annotate [OPTIONS] INFO1 FILE1 INFO2 FILE2 ...", 13 | description=description, 14 | ) 15 | 16 | parser.add_option( 17 | '-o', '--output', 18 | metavar="FILE", 19 | dest="output", 20 | default="-", 21 | help="File to write the difference to", 22 | ) 23 | 24 | parser.add_option( 25 | '-a', '--annotation', 26 | action="store_true", 27 | dest="annotation", 28 | help="Do an annotation") 29 | 30 | def main(args=None): 31 | if args is None: 32 | args = sys.argv[1:] 33 | options, args = parser.parse_args(args) 34 | if options.annotation: 35 | return annotate(options, args) 36 | if len(args) != 2: 37 | print('Error: you must give two files') 38 | parser.print_help() 39 | sys.exit(1) 40 | file1, file2 = args 41 | input1 = read_file(file1) 42 | input2 = read_file(file2) 43 | body1 = split_body(input1)[1] 44 | pre, body2, post = split_body(input2) 45 | result = htmldiff(body1, body2) 46 | result = pre + result + post 47 | if options.output == '-': 48 | if not result.endswith('\n'): 49 | result += '\n' 50 | sys.stdout.write(result) 51 | else: 52 | f = open(options.output, 'wb') 53 | f.write(result) 54 | f.close() 55 | 56 | def read_file(filename): 57 | if filename == '-': 58 | c = sys.stdin.read() 59 | elif not os.path.exists(filename): 60 | raise OSError( 61 | "Input file %s does not exist" % filename) 62 | else: 63 | f = open(filename, 'rb') 64 | c = f.read() 65 | f.close() 66 | return c 67 | 68 | body_start_re = re.compile( 69 | r"", re.I|re.S) 70 | body_end_re = re.compile( 71 | r"", re.I|re.S) 72 | 73 | def split_body(html): 74 | match = body_start_re.search(html) 75 | if match: 76 | pre = html[:match.end()] 77 | html = html[match.end():] 78 | match = body_end_re.search(html) 79 | if match: 80 | post = html[match.start():] 81 | html = html[:match.start()] 82 | return pre, html, post 83 | 84 | def annotate(options, args): 85 | print("Not yet implemented") 86 | sys.exit(1) 87 | 88 | -------------------------------------------------------------------------------- /src/workflow/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # 4 | # Copyright (c) 2014 Dean Jackson 5 | # 6 | # MIT Licence. See http://opensource.org/licenses/MIT 7 | # 8 | # Created on 2014-02-15 9 | # 10 | 11 | """ 12 | A Python helper library for `Alfred 2 `_ Workflow 13 | authors. 14 | """ 15 | 16 | import os 17 | 18 | __title__ = 'Alfred-Workflow' 19 | __version__ = open(os.path.join(os.path.dirname(__file__), 'version')).read() 20 | __author__ = 'Dean Jackson' 21 | __licence__ = 'MIT' 22 | __copyright__ = 'Copyright 2014 Dean Jackson' 23 | 24 | 25 | # Workflow objects 26 | from .workflow import Workflow, manager 27 | 28 | # Exceptions 29 | from .workflow import PasswordNotFound, KeychainError 30 | 31 | # Icons 32 | from .workflow import ( 33 | ICON_ACCOUNT, 34 | ICON_BURN, 35 | ICON_CLOCK, 36 | ICON_COLOR, 37 | ICON_COLOUR, 38 | ICON_EJECT, 39 | ICON_ERROR, 40 | ICON_FAVORITE, 41 | ICON_FAVOURITE, 42 | ICON_GROUP, 43 | ICON_HELP, 44 | ICON_HOME, 45 | ICON_INFO, 46 | ICON_NETWORK, 47 | ICON_NOTE, 48 | ICON_SETTINGS, 49 | ICON_SWIRL, 50 | ICON_SWITCH, 51 | ICON_SYNC, 52 | ICON_TRASH, 53 | ICON_USER, 54 | ICON_WARNING, 55 | ICON_WEB, 56 | ) 57 | 58 | # Filter matching rules 59 | from .workflow import ( 60 | MATCH_ALL, 61 | MATCH_ALLCHARS, 62 | MATCH_ATOM, 63 | MATCH_CAPITALS, 64 | MATCH_INITIALS, 65 | MATCH_INITIALS_CONTAIN, 66 | MATCH_INITIALS_STARTSWITH, 67 | MATCH_STARTSWITH, 68 | MATCH_SUBSTRING, 69 | ) 70 | 71 | __all__ = [ 72 | 'Workflow', 73 | 'manager', 74 | 'PasswordNotFound', 75 | 'KeychainError', 76 | 'ICON_ACCOUNT', 77 | 'ICON_BURN', 78 | 'ICON_CLOCK', 79 | 'ICON_COLOR', 80 | 'ICON_COLOUR', 81 | 'ICON_EJECT', 82 | 'ICON_ERROR', 83 | 'ICON_FAVORITE', 84 | 'ICON_FAVOURITE', 85 | 'ICON_GROUP', 86 | 'ICON_HELP', 87 | 'ICON_HOME', 88 | 'ICON_INFO', 89 | 'ICON_NETWORK', 90 | 'ICON_NOTE', 91 | 'ICON_SETTINGS', 92 | 'ICON_SWIRL', 93 | 'ICON_SWITCH', 94 | 'ICON_SYNC', 95 | 'ICON_TRASH', 96 | 'ICON_USER', 97 | 'ICON_WARNING', 98 | 'ICON_WEB', 99 | 'MATCH_ALL', 100 | 'MATCH_ALLCHARS', 101 | 'MATCH_ATOM', 102 | 'MATCH_CAPITALS', 103 | 'MATCH_INITIALS', 104 | 'MATCH_INITIALS_CONTAIN', 105 | 'MATCH_INITIALS_STARTSWITH', 106 | 'MATCH_STARTSWITH', 107 | 'MATCH_SUBSTRING', 108 | ] 109 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/codingstatemachine.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .constants import eStart 29 | from .compat import wrap_ord 30 | 31 | 32 | class CodingStateMachine: 33 | def __init__(self, sm): 34 | self._mModel = sm 35 | self._mCurrentBytePos = 0 36 | self._mCurrentCharLen = 0 37 | self.reset() 38 | 39 | def reset(self): 40 | self._mCurrentState = eStart 41 | 42 | def next_state(self, c): 43 | # for each byte we get its class 44 | # if it is first byte, we also get byte length 45 | # PY3K: aBuf is a byte stream, so c is an int, not a byte 46 | byteCls = self._mModel['classTable'][wrap_ord(c)] 47 | if self._mCurrentState == eStart: 48 | self._mCurrentBytePos = 0 49 | self._mCurrentCharLen = self._mModel['charLenTable'][byteCls] 50 | # from byte's class and stateTable, we get its next state 51 | curr_state = (self._mCurrentState * self._mModel['classFactor'] 52 | + byteCls) 53 | self._mCurrentState = self._mModel['stateTable'][curr_state] 54 | self._mCurrentBytePos += 1 55 | return self._mCurrentState 56 | 57 | def get_current_charlen(self): 58 | return self._mCurrentCharLen 59 | 60 | def get_coding_state_machine(self): 61 | return self._mModel['name'] 62 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/filepost.py: -------------------------------------------------------------------------------- 1 | import codecs 2 | 3 | from uuid import uuid4 4 | from io import BytesIO 5 | 6 | from .packages import six 7 | from .packages.six import b 8 | from .fields import RequestField 9 | 10 | writer = codecs.lookup('utf-8')[3] 11 | 12 | 13 | def choose_boundary(): 14 | """ 15 | Our embarassingly-simple replacement for mimetools.choose_boundary. 16 | """ 17 | return uuid4().hex 18 | 19 | 20 | def iter_field_objects(fields): 21 | """ 22 | Iterate over fields. 23 | 24 | Supports list of (k, v) tuples and dicts, and lists of 25 | :class:`~urllib3.fields.RequestField`. 26 | 27 | """ 28 | if isinstance(fields, dict): 29 | i = six.iteritems(fields) 30 | else: 31 | i = iter(fields) 32 | 33 | for field in i: 34 | if isinstance(field, RequestField): 35 | yield field 36 | else: 37 | yield RequestField.from_tuples(*field) 38 | 39 | 40 | def iter_fields(fields): 41 | """ 42 | .. deprecated:: 1.6 43 | 44 | Iterate over fields. 45 | 46 | The addition of :class:`~urllib3.fields.RequestField` makes this function 47 | obsolete. Instead, use :func:`iter_field_objects`, which returns 48 | :class:`~urllib3.fields.RequestField` objects. 49 | 50 | Supports list of (k, v) tuples and dicts. 51 | """ 52 | if isinstance(fields, dict): 53 | return ((k, v) for k, v in six.iteritems(fields)) 54 | 55 | return ((k, v) for k, v in fields) 56 | 57 | 58 | def encode_multipart_formdata(fields, boundary=None): 59 | """ 60 | Encode a dictionary of ``fields`` using the multipart/form-data MIME format. 61 | 62 | :param fields: 63 | Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`). 64 | 65 | :param boundary: 66 | If not specified, then a random boundary will be generated using 67 | :func:`mimetools.choose_boundary`. 68 | """ 69 | body = BytesIO() 70 | if boundary is None: 71 | boundary = choose_boundary() 72 | 73 | for field in iter_field_objects(fields): 74 | body.write(b('--%s\r\n' % (boundary))) 75 | 76 | writer(body).write(field.render_headers()) 77 | data = field.data 78 | 79 | if isinstance(data, int): 80 | data = str(data) # Backwards compatibility 81 | 82 | if isinstance(data, six.text_type): 83 | writer(body).write(data) 84 | else: 85 | body.write(data) 86 | 87 | body.write(b'\r\n') 88 | 89 | body.write(b('--%s--\r\n' % (boundary))) 90 | 91 | content_type = str('multipart/form-data; boundary=%s' % boundary) 92 | 93 | return body.getvalue(), content_type 94 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/chardetect.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Script which takes one or more file paths and reports on their detected 4 | encodings 5 | 6 | Example:: 7 | 8 | % chardetect somefile someotherfile 9 | somefile: windows-1252 with confidence 0.5 10 | someotherfile: ascii with confidence 1.0 11 | 12 | If no paths are provided, it takes its input from stdin. 13 | 14 | """ 15 | 16 | from __future__ import absolute_import, print_function, unicode_literals 17 | 18 | import argparse 19 | import sys 20 | from io import open 21 | 22 | from chardet import __version__ 23 | from chardet.universaldetector import UniversalDetector 24 | 25 | 26 | def description_of(lines, name='stdin'): 27 | """ 28 | Return a string describing the probable encoding of a file or 29 | list of strings. 30 | 31 | :param lines: The lines to get the encoding of. 32 | :type lines: Iterable of bytes 33 | :param name: Name of file or collection of lines 34 | :type name: str 35 | """ 36 | u = UniversalDetector() 37 | for line in lines: 38 | u.feed(line) 39 | u.close() 40 | result = u.result 41 | if result['encoding']: 42 | return '{0}: {1} with confidence {2}'.format(name, result['encoding'], 43 | result['confidence']) 44 | else: 45 | return '{0}: no result'.format(name) 46 | 47 | 48 | def main(argv=None): 49 | ''' 50 | Handles command line arguments and gets things started. 51 | 52 | :param argv: List of arguments, as if specified on the command-line. 53 | If None, ``sys.argv[1:]`` is used instead. 54 | :type argv: list of str 55 | ''' 56 | # Get command line arguments 57 | parser = argparse.ArgumentParser( 58 | description="Takes one or more file paths and reports their detected \ 59 | encodings", 60 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, 61 | conflict_handler='resolve') 62 | parser.add_argument('input', 63 | help='File whose encoding we would like to determine.', 64 | type=argparse.FileType('rb'), nargs='*', 65 | default=[sys.stdin]) 66 | parser.add_argument('--version', action='version', 67 | version='%(prog)s {0}'.format(__version__)) 68 | args = parser.parse_args(argv) 69 | 70 | for f in args.input: 71 | if f.isatty(): 72 | print("You are running chardetect interactively. Press " + 73 | "CTRL-D twice at the start of a blank line to signal the " + 74 | "end of your input. If you want help, run chardetect " + 75 | "--help\n", file=sys.stderr) 76 | print(description_of(f, f.name)) 77 | 78 | 79 | if __name__ == '__main__': 80 | main() 81 | -------------------------------------------------------------------------------- /src/lib/lxml-3.4.4-py2.7.egg-info/installed-files.txt: -------------------------------------------------------------------------------- 1 | ../lxml/__init__.py 2 | ../lxml/_elementpath.py 3 | ../lxml/builder.py 4 | ../lxml/cssselect.py 5 | ../lxml/doctestcompare.py 6 | ../lxml/ElementInclude.py 7 | ../lxml/pyclasslookup.py 8 | ../lxml/sax.py 9 | ../lxml/usedoctest.py 10 | ../lxml/includes/__init__.py 11 | ../lxml/html/__init__.py 12 | ../lxml/html/_diffcommand.py 13 | ../lxml/html/_html5builder.py 14 | ../lxml/html/_setmixin.py 15 | ../lxml/html/builder.py 16 | ../lxml/html/clean.py 17 | ../lxml/html/defs.py 18 | ../lxml/html/diff.py 19 | ../lxml/html/ElementSoup.py 20 | ../lxml/html/formfill.py 21 | ../lxml/html/html5parser.py 22 | ../lxml/html/soupparser.py 23 | ../lxml/html/usedoctest.py 24 | ../lxml/isoschematron/__init__.py 25 | ../lxml/lxml.etree.h 26 | ../lxml/lxml.etree_api.h 27 | ../lxml/includes/c14n.pxd 28 | ../lxml/includes/config.pxd 29 | ../lxml/includes/dtdvalid.pxd 30 | ../lxml/includes/etreepublic.pxd 31 | ../lxml/includes/htmlparser.pxd 32 | ../lxml/includes/relaxng.pxd 33 | ../lxml/includes/schematron.pxd 34 | ../lxml/includes/tree.pxd 35 | ../lxml/includes/uri.pxd 36 | ../lxml/includes/xinclude.pxd 37 | ../lxml/includes/xmlerror.pxd 38 | ../lxml/includes/xmlparser.pxd 39 | ../lxml/includes/xmlschema.pxd 40 | ../lxml/includes/xpath.pxd 41 | ../lxml/includes/xslt.pxd 42 | ../lxml/includes/etree_defs.h 43 | ../lxml/includes/lxml-version.h 44 | ../lxml/isoschematron/resources/rng/iso-schematron.rng 45 | ../lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl 46 | ../lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl 47 | ../lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl 48 | ../lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl 49 | ../lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl 50 | ../lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl 51 | ../lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl 52 | ../lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt 53 | ../lxml/__init__.pyc 54 | ../lxml/_elementpath.pyc 55 | ../lxml/builder.pyc 56 | ../lxml/cssselect.pyc 57 | ../lxml/doctestcompare.pyc 58 | ../lxml/ElementInclude.pyc 59 | ../lxml/pyclasslookup.pyc 60 | ../lxml/sax.pyc 61 | ../lxml/usedoctest.pyc 62 | ../lxml/includes/__init__.pyc 63 | ../lxml/html/__init__.pyc 64 | ../lxml/html/_diffcommand.pyc 65 | ../lxml/html/_html5builder.pyc 66 | ../lxml/html/_setmixin.pyc 67 | ../lxml/html/builder.pyc 68 | ../lxml/html/clean.pyc 69 | ../lxml/html/defs.pyc 70 | ../lxml/html/diff.pyc 71 | ../lxml/html/ElementSoup.pyc 72 | ../lxml/html/formfill.pyc 73 | ../lxml/html/html5parser.pyc 74 | ../lxml/html/soupparser.pyc 75 | ../lxml/html/usedoctest.pyc 76 | ../lxml/isoschematron/__init__.pyc 77 | ../lxml/etree.so 78 | ../lxml/objectify.so 79 | ./ 80 | dependency_links.txt 81 | not-zip-safe 82 | PKG-INFO 83 | requires.txt 84 | SOURCES.txt 85 | top_level.txt 86 | -------------------------------------------------------------------------------- /src/lib/lxml/includes/relaxng.pxd: -------------------------------------------------------------------------------- 1 | from lxml.includes.tree cimport xmlDoc 2 | from lxml.includes.xmlerror cimport xmlStructuredErrorFunc 3 | 4 | cdef extern from "libxml/relaxng.h": 5 | ctypedef struct xmlRelaxNG 6 | ctypedef struct xmlRelaxNGParserCtxt 7 | 8 | ctypedef struct xmlRelaxNGValidCtxt 9 | 10 | ctypedef enum xmlRelaxNGValidErr: 11 | XML_RELAXNG_OK = 0 12 | XML_RELAXNG_ERR_MEMORY = 1 13 | XML_RELAXNG_ERR_TYPE = 2 14 | XML_RELAXNG_ERR_TYPEVAL = 3 15 | XML_RELAXNG_ERR_DUPID = 4 16 | XML_RELAXNG_ERR_TYPECMP = 5 17 | XML_RELAXNG_ERR_NOSTATE = 6 18 | XML_RELAXNG_ERR_NODEFINE = 7 19 | XML_RELAXNG_ERR_LISTEXTRA = 8 20 | XML_RELAXNG_ERR_LISTEMPTY = 9 21 | XML_RELAXNG_ERR_INTERNODATA = 10 22 | XML_RELAXNG_ERR_INTERSEQ = 11 23 | XML_RELAXNG_ERR_INTEREXTRA = 12 24 | XML_RELAXNG_ERR_ELEMNAME = 13 25 | XML_RELAXNG_ERR_ATTRNAME = 14 26 | XML_RELAXNG_ERR_ELEMNONS = 15 27 | XML_RELAXNG_ERR_ATTRNONS = 16 28 | XML_RELAXNG_ERR_ELEMWRONGNS = 17 29 | XML_RELAXNG_ERR_ATTRWRONGNS = 18 30 | XML_RELAXNG_ERR_ELEMEXTRANS = 19 31 | XML_RELAXNG_ERR_ATTREXTRANS = 20 32 | XML_RELAXNG_ERR_ELEMNOTEMPTY = 21 33 | XML_RELAXNG_ERR_NOELEM = 22 34 | XML_RELAXNG_ERR_NOTELEM = 23 35 | XML_RELAXNG_ERR_ATTRVALID = 24 36 | XML_RELAXNG_ERR_CONTENTVALID = 25 37 | XML_RELAXNG_ERR_EXTRACONTENT = 26 38 | XML_RELAXNG_ERR_INVALIDATTR = 27 39 | XML_RELAXNG_ERR_DATAELEM = 28 40 | XML_RELAXNG_ERR_VALELEM = 29 41 | XML_RELAXNG_ERR_LISTELEM = 30 42 | XML_RELAXNG_ERR_DATATYPE = 31 43 | XML_RELAXNG_ERR_VALUE = 32 44 | XML_RELAXNG_ERR_LIST = 33 45 | XML_RELAXNG_ERR_NOGRAMMAR = 34 46 | XML_RELAXNG_ERR_EXTRADATA = 35 47 | XML_RELAXNG_ERR_LACKDATA = 36 48 | XML_RELAXNG_ERR_INTERNAL = 37 49 | XML_RELAXNG_ERR_ELEMWRONG = 38 50 | XML_RELAXNG_ERR_TEXTWRONG = 39 51 | 52 | cdef xmlRelaxNGValidCtxt* xmlRelaxNGNewValidCtxt(xmlRelaxNG* schema) nogil 53 | cdef int xmlRelaxNGValidateDoc(xmlRelaxNGValidCtxt* ctxt, xmlDoc* doc) nogil 54 | cdef xmlRelaxNG* xmlRelaxNGParse(xmlRelaxNGParserCtxt* ctxt) nogil 55 | cdef xmlRelaxNGParserCtxt* xmlRelaxNGNewParserCtxt(char* URL) nogil 56 | cdef xmlRelaxNGParserCtxt* xmlRelaxNGNewDocParserCtxt(xmlDoc* doc) nogil 57 | cdef void xmlRelaxNGFree(xmlRelaxNG* schema) nogil 58 | cdef void xmlRelaxNGFreeParserCtxt(xmlRelaxNGParserCtxt* ctxt) nogil 59 | cdef void xmlRelaxNGFreeValidCtxt(xmlRelaxNGValidCtxt* ctxt) nogil 60 | 61 | cdef void xmlRelaxNGSetValidStructuredErrors( 62 | xmlRelaxNGValidCtxt* ctxt, xmlStructuredErrorFunc serror, void *ctx) nogil 63 | cdef void xmlRelaxNGSetParserStructuredErrors( 64 | xmlRelaxNGParserCtxt* ctxt, xmlStructuredErrorFunc serror, void *ctx) nogil 65 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/utf8prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | from .charsetprober import CharSetProber 30 | from .codingstatemachine import CodingStateMachine 31 | from .mbcssm import UTF8SMModel 32 | 33 | ONE_CHAR_PROB = 0.5 34 | 35 | 36 | class UTF8Prober(CharSetProber): 37 | def __init__(self): 38 | CharSetProber.__init__(self) 39 | self._mCodingSM = CodingStateMachine(UTF8SMModel) 40 | self.reset() 41 | 42 | def reset(self): 43 | CharSetProber.reset(self) 44 | self._mCodingSM.reset() 45 | self._mNumOfMBChar = 0 46 | 47 | def get_charset_name(self): 48 | return "utf-8" 49 | 50 | def feed(self, aBuf): 51 | for c in aBuf: 52 | codingState = self._mCodingSM.next_state(c) 53 | if codingState == constants.eError: 54 | self._mState = constants.eNotMe 55 | break 56 | elif codingState == constants.eItsMe: 57 | self._mState = constants.eFoundIt 58 | break 59 | elif codingState == constants.eStart: 60 | if self._mCodingSM.get_current_charlen() >= 2: 61 | self._mNumOfMBChar += 1 62 | 63 | if self.get_state() == constants.eDetecting: 64 | if self.get_confidence() > constants.SHORTCUT_THRESHOLD: 65 | self._mState = constants.eFoundIt 66 | 67 | return self.get_state() 68 | 69 | def get_confidence(self): 70 | unlike = 0.99 71 | if self._mNumOfMBChar < 6: 72 | for i in range(0, self._mNumOfMBChar): 73 | unlike = unlike * ONE_CHAR_PROB 74 | return 1.0 - unlike 75 | else: 76 | return unlike 77 | -------------------------------------------------------------------------------- /src/lib/requests/exceptions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.exceptions 5 | ~~~~~~~~~~~~~~~~~~~ 6 | 7 | This module contains the set of Requests' exceptions. 8 | 9 | """ 10 | from .packages.urllib3.exceptions import HTTPError as BaseHTTPError 11 | 12 | 13 | class RequestException(IOError): 14 | """There was an ambiguous exception that occurred while handling your 15 | request.""" 16 | 17 | def __init__(self, *args, **kwargs): 18 | """ 19 | Initialize RequestException with `request` and `response` objects. 20 | """ 21 | response = kwargs.pop('response', None) 22 | self.response = response 23 | self.request = kwargs.pop('request', None) 24 | if (response is not None and not self.request and 25 | hasattr(response, 'request')): 26 | self.request = self.response.request 27 | super(RequestException, self).__init__(*args, **kwargs) 28 | 29 | 30 | class HTTPError(RequestException): 31 | """An HTTP error occurred.""" 32 | 33 | 34 | class ConnectionError(RequestException): 35 | """A Connection error occurred.""" 36 | 37 | 38 | class ProxyError(ConnectionError): 39 | """A proxy error occurred.""" 40 | 41 | 42 | class SSLError(ConnectionError): 43 | """An SSL error occurred.""" 44 | 45 | 46 | class Timeout(RequestException): 47 | """The request timed out. 48 | 49 | Catching this error will catch both 50 | :exc:`~requests.exceptions.ConnectTimeout` and 51 | :exc:`~requests.exceptions.ReadTimeout` errors. 52 | """ 53 | 54 | 55 | class ConnectTimeout(ConnectionError, Timeout): 56 | """The request timed out while trying to connect to the remote server. 57 | 58 | Requests that produced this error are safe to retry. 59 | """ 60 | 61 | 62 | class ReadTimeout(Timeout): 63 | """The server did not send any data in the allotted amount of time.""" 64 | 65 | 66 | class URLRequired(RequestException): 67 | """A valid URL is required to make a request.""" 68 | 69 | 70 | class TooManyRedirects(RequestException): 71 | """Too many redirects.""" 72 | 73 | 74 | class MissingSchema(RequestException, ValueError): 75 | """The URL schema (e.g. http or https) is missing.""" 76 | 77 | 78 | class InvalidSchema(RequestException, ValueError): 79 | """See defaults.py for valid schemas.""" 80 | 81 | 82 | class InvalidURL(RequestException, ValueError): 83 | """ The URL provided was somehow invalid. """ 84 | 85 | 86 | class ChunkedEncodingError(RequestException): 87 | """The server declared chunked encoding but sent an invalid chunk.""" 88 | 89 | 90 | class ContentDecodingError(RequestException, BaseHTTPError): 91 | """Failed to decode response content""" 92 | 93 | 94 | class StreamConsumedError(RequestException, TypeError): 95 | """The content for this response was already consumed""" 96 | 97 | 98 | class RetryError(RequestException): 99 | """Custom retries logic failed""" 100 | -------------------------------------------------------------------------------- /src/lib/lxml/includes/htmlparser.pxd: -------------------------------------------------------------------------------- 1 | from libc.string cimport const_char 2 | 3 | from lxml.includes.tree cimport xmlDoc 4 | from lxml.includes.tree cimport xmlInputReadCallback, xmlInputCloseCallback 5 | from lxml.includes.xmlparser cimport xmlParserCtxt, xmlSAXHandler, xmlSAXHandlerV1 6 | 7 | cdef extern from "libxml/HTMLparser.h": 8 | ctypedef enum htmlParserOption: 9 | HTML_PARSE_NOERROR # suppress error reports 10 | HTML_PARSE_NOWARNING # suppress warning reports 11 | HTML_PARSE_PEDANTIC # pedantic error reporting 12 | HTML_PARSE_NOBLANKS # remove blank nodes 13 | HTML_PARSE_NONET # Forbid network access 14 | # libxml2 2.6.21+ only: 15 | HTML_PARSE_RECOVER # Relaxed parsing 16 | HTML_PARSE_COMPACT # compact small text nodes 17 | # libxml2 2.7.7+ only: 18 | HTML_PARSE_NOIMPLIED # Do not add implied html/body... elements 19 | # libxml2 2.7.8+ only: 20 | HTML_PARSE_NODEFDTD # do not default a doctype if not found 21 | # libxml2 2.8.0+ only: 22 | XML_PARSE_IGNORE_ENC # ignore internal document encoding hint 23 | 24 | xmlSAXHandlerV1 htmlDefaultSAXHandler 25 | 26 | cdef xmlParserCtxt* htmlCreateMemoryParserCtxt( 27 | char* buffer, int size) nogil 28 | cdef xmlParserCtxt* htmlCreateFileParserCtxt( 29 | char* filename, char* encoding) nogil 30 | cdef xmlParserCtxt* htmlCreatePushParserCtxt(xmlSAXHandler* sax, 31 | void* user_data, 32 | char* chunk, int size, 33 | char* filename, int enc) nogil 34 | cdef void htmlFreeParserCtxt(xmlParserCtxt* ctxt) nogil 35 | cdef void htmlCtxtReset(xmlParserCtxt* ctxt) nogil 36 | cdef int htmlCtxtUseOptions(xmlParserCtxt* ctxt, int options) nogil 37 | cdef int htmlParseDocument(xmlParserCtxt* ctxt) nogil 38 | cdef int htmlParseChunk(xmlParserCtxt* ctxt, 39 | char* chunk, int size, int terminate) nogil 40 | 41 | cdef xmlDoc* htmlCtxtReadFile(xmlParserCtxt* ctxt, 42 | char* filename, const_char* encoding, 43 | int options) nogil 44 | cdef xmlDoc* htmlCtxtReadDoc(xmlParserCtxt* ctxt, 45 | char* buffer, char* URL, const_char* encoding, 46 | int options) nogil 47 | cdef xmlDoc* htmlCtxtReadIO(xmlParserCtxt* ctxt, 48 | xmlInputReadCallback ioread, 49 | xmlInputCloseCallback ioclose, 50 | void* ioctx, 51 | char* URL, const_char* encoding, 52 | int options) nogil 53 | cdef xmlDoc* htmlCtxtReadMemory(xmlParserCtxt* ctxt, 54 | char* buffer, int size, 55 | char* filename, const_char* encoding, 56 | int options) nogil 57 | -------------------------------------------------------------------------------- /src/lib/lxml/html/_setmixin.py: -------------------------------------------------------------------------------- 1 | class SetMixin(object): 2 | 3 | """ 4 | Mix-in for sets. You must define __iter__, add, remove 5 | """ 6 | 7 | def __len__(self): 8 | length = 0 9 | for item in self: 10 | length += 1 11 | return length 12 | 13 | def __contains__(self, item): 14 | for has_item in self: 15 | if item == has_item: 16 | return True 17 | return False 18 | 19 | def issubset(self, other): 20 | for item in other: 21 | if item not in self: 22 | return False 23 | return True 24 | 25 | __le__ = issubset 26 | 27 | def issuperset(self, other): 28 | for item in self: 29 | if item not in other: 30 | return False 31 | return True 32 | 33 | __ge__ = issuperset 34 | 35 | def union(self, other): 36 | return self | other 37 | 38 | def __or__(self, other): 39 | new = self.copy() 40 | new |= other 41 | return new 42 | 43 | def intersection(self, other): 44 | return self & other 45 | 46 | def __and__(self, other): 47 | new = self.copy() 48 | new &= other 49 | return new 50 | 51 | def difference(self, other): 52 | return self - other 53 | 54 | def __sub__(self, other): 55 | new = self.copy() 56 | new -= other 57 | return new 58 | 59 | def symmetric_difference(self, other): 60 | return self ^ other 61 | 62 | def __xor__(self, other): 63 | new = self.copy() 64 | new ^= other 65 | return new 66 | 67 | def copy(self): 68 | return set(self) 69 | 70 | def update(self, other): 71 | for item in other: 72 | self.add(item) 73 | 74 | def __ior__(self, other): 75 | self.update(other) 76 | return self 77 | 78 | def intersection_update(self, other): 79 | for item in self: 80 | if item not in other: 81 | self.remove(item) 82 | 83 | def __iand__(self, other): 84 | self.intersection_update(other) 85 | return self 86 | 87 | def difference_update(self, other): 88 | for item in other: 89 | if item in self: 90 | self.remove(item) 91 | 92 | def __isub__(self, other): 93 | self.difference_update(other) 94 | return self 95 | 96 | def symmetric_difference_update(self, other): 97 | for item in other: 98 | if item in self: 99 | self.remove(item) 100 | else: 101 | self.add(item) 102 | 103 | def __ixor__(self, other): 104 | self.symmetric_difference_update(other) 105 | return self 106 | 107 | def discard(self, item): 108 | try: 109 | self.remove(item) 110 | except KeyError: 111 | pass 112 | 113 | def clear(self): 114 | for item in list(self): 115 | self.remove(item) 116 | -------------------------------------------------------------------------------- /src/lib/lxml-3.4.4-py2.7.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.1 2 | Name: lxml 3 | Version: 3.4.4 4 | Summary: Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API. 5 | Home-page: http://lxml.de/ 6 | Author: lxml dev team 7 | Author-email: lxml-dev@lxml.de 8 | License: UNKNOWN 9 | Download-URL: http://pypi.python.org/packages/source/l/lxml/lxml-3.4.4.tar.gz 10 | Description: lxml is a Pythonic, mature binding for the libxml2 and libxslt libraries. It 11 | provides safe and convenient access to these libraries using the ElementTree 12 | API. 13 | 14 | It extends the ElementTree API significantly to offer support for XPath, 15 | RelaxNG, XML Schema, XSLT, C14N and much more. 16 | 17 | To contact the project, go to the `project home page 18 | `_ or see our bug tracker at 19 | https://launchpad.net/lxml 20 | 21 | In case you want to use the current in-development version of lxml, 22 | you can get it from the github repository at 23 | https://github.com/lxml/lxml . Note that this requires Cython to 24 | build the sources, see the build instructions on the project home 25 | page. To the same end, running ``easy_install lxml==dev`` will 26 | install lxml from 27 | https://github.com/lxml/lxml/tarball/master#egg=lxml-dev if you have 28 | an appropriate version of Cython installed. 29 | 30 | 31 | After an official release of a new stable series, bug fixes may become 32 | available at 33 | https://github.com/lxml/lxml/tree/lxml-3.4 . 34 | Running ``easy_install lxml==3.4bugfix`` will install 35 | the unreleased branch state from 36 | https://github.com/lxml/lxml/tarball/lxml-3.4#egg=lxml-3.4bugfix 37 | as soon as a maintenance branch has been established. Note that this 38 | requires Cython to be installed at an appropriate version for the build. 39 | 40 | 3.4.4 (2015-04-25) 41 | ================== 42 | 43 | Bugs fixed 44 | ---------- 45 | 46 | * An ElementTree compatibility test added in lxml 3.4.3 that failed in 47 | Python 3.4+ was removed again. 48 | 49 | 50 | 51 | Platform: UNKNOWN 52 | Classifier: Development Status :: 5 - Production/Stable 53 | Classifier: Intended Audience :: Developers 54 | Classifier: Intended Audience :: Information Technology 55 | Classifier: License :: OSI Approved :: BSD License 56 | Classifier: Programming Language :: Cython 57 | Classifier: Programming Language :: Python :: 2 58 | Classifier: Programming Language :: Python :: 2.6 59 | Classifier: Programming Language :: Python :: 2.7 60 | Classifier: Programming Language :: Python :: 3 61 | Classifier: Programming Language :: Python :: 3.2 62 | Classifier: Programming Language :: Python :: 3.3 63 | Classifier: Programming Language :: Python :: 3.4 64 | Classifier: Programming Language :: C 65 | Classifier: Operating System :: OS Independent 66 | Classifier: Topic :: Text Processing :: Markup :: HTML 67 | Classifier: Topic :: Text Processing :: Markup :: XML 68 | Classifier: Topic :: Software Development :: Libraries :: Python Modules 69 | -------------------------------------------------------------------------------- /src/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | stack_overflow 7 | category 8 | Productivity 9 | connections 10 | 11 | E58B4AFD-77EB-493A-BC02-7AC3F89BE458 12 | 13 | 14 | destinationuid 15 | 6828E838-68C9-438A-A707-832FE2513931 16 | modifiers 17 | 0 18 | modifiersubtext 19 | 20 | 21 | 22 | 23 | createdby 24 | Quentin Spencer-Harper 25 | description 26 | Searches google for "site:stackoverflow.com/questions {query}", and then posts the top answer from each result 27 | disabled 28 | 29 | name 30 | Stack Overflow 31 | objects 32 | 33 | 34 | config 35 | 36 | plusspaces 37 | 38 | url 39 | {query} 40 | utf8 41 | 42 | 43 | type 44 | alfred.workflow.action.openurl 45 | uid 46 | 6828E838-68C9-438A-A707-832FE2513931 47 | version 48 | 0 49 | 50 | 51 | config 52 | 53 | argumenttype 54 | 0 55 | escaping 56 | 102 57 | keyword 58 | so 59 | queuedelaycustom 60 | 3 61 | queuedelayimmediatelyinitially 62 | 63 | queuedelaymode 64 | 1 65 | queuemode 66 | 2 67 | runningsubtext 68 | Loading results... 69 | script 70 | python stackoverflow.py "{query}" 71 | subtext 72 | Tip: press CMD+L on a result to view, ENTER to open it, and TAB to view more answers 73 | title 74 | Stack Overflow 75 | type 76 | 0 77 | withspace 78 | 79 | 80 | type 81 | alfred.workflow.input.scriptfilter 82 | uid 83 | E58B4AFD-77EB-493A-BC02-7AC3F89BE458 84 | version 85 | 0 86 | 87 | 88 | readme 89 | 90 | uidata 91 | 92 | 6828E838-68C9-438A-A707-832FE2513931 93 | 94 | ypos 95 | 180 96 | 97 | E58B4AFD-77EB-493A-BC02-7AC3F89BE458 98 | 99 | ypos 100 | 180 101 | 102 | 103 | webaddress 104 | https://github.com/Que3216/alfred-stack-overflow 105 | 106 | 107 | -------------------------------------------------------------------------------- /src/lib/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/lib/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt: -------------------------------------------------------------------------------- 1 | ISO SCHEMATRON 2009 2 | 3 | XSLT implementation by Rick Jelliffe with assistance from members of Schematron-love-in maillist. 4 | 5 | 2009-03-18 6 | 7 | Two distributions are available. One is for XSLT1 engines. 8 | The other is for XSLT2 engines, such as SAXON 9. 9 | 10 | 11 | This version of Schematron splits the process into a pipeline of several different XSLT stages. 12 | 13 | 1) First, preprocess your Schematron schema with iso_dsdl_include.xsl. 14 | This is a macro processor to assemble the schema from various parts. 15 | If your schema is not in separate parts, you can skip this stage. 16 | 17 | 2) Second, preprocess the output from stage 1 with iso_abstract_expand.xsl. 18 | This is a macro processor to convert abstract patterns to real patterns. 19 | If your schema does not use abstract patterns, you can skip this 20 | stage. 21 | 22 | 3) Third, compile the Schematron schema into an XSLT script. 23 | This will typically use iso_svrl_for_xslt1.xsl or iso_svrl_for_xslt2.xsl 24 | (which in turn invoke iso_schematron_skeleton_for_xslt1.xsl or iso_schematron_skeleton_for_saxon.xsl) 25 | However, other "meta-styleseets" are also in common use; the principle of operation is the same. 26 | If your schema uses Schematron phases, supply these as command line/invocation parameters 27 | to this process. 28 | 29 | 4) Fourth, run the script generated by stage 3 against the document being validated. 30 | If you are using the SVRL script, then the output of validation will be an XML document. 31 | If your schema uses Schematron parameters, supply these as command line/invocation parameters 32 | to this process. 33 | 34 | 35 | The XSLT2 distribution also features several next generation features, 36 | such as validating multiple documents. See the source code for details. 37 | 38 | Schematron assertions can be written in any language, of course; the file 39 | sch-messages-en.xhtml contains the diagnostics messages from the XSLT2 skeleton 40 | in English, and this can be used as template to localize the skeleton's 41 | error messages. Note that typically programming errors in Schematron are XPath 42 | errors, which requires localized messages from the XSLT engine. 43 | 44 | ANT 45 | --- 46 | To give an example of how to process a document, here is a sample ANT task. 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/lib/requests/structures.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.structures 5 | ~~~~~~~~~~~~~~~~~~~ 6 | 7 | Data structures that power Requests. 8 | 9 | """ 10 | 11 | import collections 12 | 13 | 14 | class CaseInsensitiveDict(collections.MutableMapping): 15 | """ 16 | A case-insensitive ``dict``-like object. 17 | 18 | Implements all methods and operations of 19 | ``collections.MutableMapping`` as well as dict's ``copy``. Also 20 | provides ``lower_items``. 21 | 22 | All keys are expected to be strings. The structure remembers the 23 | case of the last key to be set, and ``iter(instance)``, 24 | ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()`` 25 | will contain case-sensitive keys. However, querying and contains 26 | testing is case insensitive:: 27 | 28 | cid = CaseInsensitiveDict() 29 | cid['Accept'] = 'application/json' 30 | cid['aCCEPT'] == 'application/json' # True 31 | list(cid) == ['Accept'] # True 32 | 33 | For example, ``headers['content-encoding']`` will return the 34 | value of a ``'Content-Encoding'`` response header, regardless 35 | of how the header name was originally stored. 36 | 37 | If the constructor, ``.update``, or equality comparison 38 | operations are given keys that have equal ``.lower()``s, the 39 | behavior is undefined. 40 | 41 | """ 42 | def __init__(self, data=None, **kwargs): 43 | self._store = dict() 44 | if data is None: 45 | data = {} 46 | self.update(data, **kwargs) 47 | 48 | def __setitem__(self, key, value): 49 | # Use the lowercased key for lookups, but store the actual 50 | # key alongside the value. 51 | self._store[key.lower()] = (key, value) 52 | 53 | def __getitem__(self, key): 54 | return self._store[key.lower()][1] 55 | 56 | def __delitem__(self, key): 57 | del self._store[key.lower()] 58 | 59 | def __iter__(self): 60 | return (casedkey for casedkey, mappedvalue in self._store.values()) 61 | 62 | def __len__(self): 63 | return len(self._store) 64 | 65 | def lower_items(self): 66 | """Like iteritems(), but with all lowercase keys.""" 67 | return ( 68 | (lowerkey, keyval[1]) 69 | for (lowerkey, keyval) 70 | in self._store.items() 71 | ) 72 | 73 | def __eq__(self, other): 74 | if isinstance(other, collections.Mapping): 75 | other = CaseInsensitiveDict(other) 76 | else: 77 | return NotImplemented 78 | # Compare insensitively 79 | return dict(self.lower_items()) == dict(other.lower_items()) 80 | 81 | # Copy is required 82 | def copy(self): 83 | return CaseInsensitiveDict(self._store.values()) 84 | 85 | def __repr__(self): 86 | return str(dict(self.items())) 87 | 88 | class LookupDict(dict): 89 | """Dictionary lookup object.""" 90 | 91 | def __init__(self, name=None): 92 | self.name = name 93 | super(LookupDict, self).__init__() 94 | 95 | def __repr__(self): 96 | return '' % (self.name) 97 | 98 | def __getitem__(self, key): 99 | # We allow fall-through here, so values default to None 100 | 101 | return self.__dict__.get(key, None) 102 | 103 | def get(self, key, default=None): 104 | return self.__dict__.get(key, default) 105 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/escprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel, 30 | ISO2022KRSMModel) 31 | from .charsetprober import CharSetProber 32 | from .codingstatemachine import CodingStateMachine 33 | from .compat import wrap_ord 34 | 35 | 36 | class EscCharSetProber(CharSetProber): 37 | def __init__(self): 38 | CharSetProber.__init__(self) 39 | self._mCodingSM = [ 40 | CodingStateMachine(HZSMModel), 41 | CodingStateMachine(ISO2022CNSMModel), 42 | CodingStateMachine(ISO2022JPSMModel), 43 | CodingStateMachine(ISO2022KRSMModel) 44 | ] 45 | self.reset() 46 | 47 | def reset(self): 48 | CharSetProber.reset(self) 49 | for codingSM in self._mCodingSM: 50 | if not codingSM: 51 | continue 52 | codingSM.active = True 53 | codingSM.reset() 54 | self._mActiveSM = len(self._mCodingSM) 55 | self._mDetectedCharset = None 56 | 57 | def get_charset_name(self): 58 | return self._mDetectedCharset 59 | 60 | def get_confidence(self): 61 | if self._mDetectedCharset: 62 | return 0.99 63 | else: 64 | return 0.00 65 | 66 | def feed(self, aBuf): 67 | for c in aBuf: 68 | # PY3K: aBuf is a byte array, so c is an int, not a byte 69 | for codingSM in self._mCodingSM: 70 | if not codingSM: 71 | continue 72 | if not codingSM.active: 73 | continue 74 | codingState = codingSM.next_state(wrap_ord(c)) 75 | if codingState == constants.eError: 76 | codingSM.active = False 77 | self._mActiveSM -= 1 78 | if self._mActiveSM <= 0: 79 | self._mState = constants.eNotMe 80 | return self.get_state() 81 | elif codingState == constants.eItsMe: 82 | self._mState = constants.eFoundIt 83 | self._mDetectedCharset = codingSM.get_coding_state_machine() # nopep8 84 | return self.get_state() 85 | 86 | return self.get_state() 87 | -------------------------------------------------------------------------------- /src/lib/requests/status_codes.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .structures import LookupDict 4 | 5 | _codes = { 6 | 7 | # Informational. 8 | 100: ('continue',), 9 | 101: ('switching_protocols',), 10 | 102: ('processing',), 11 | 103: ('checkpoint',), 12 | 122: ('uri_too_long', 'request_uri_too_long'), 13 | 200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/', '✓'), 14 | 201: ('created',), 15 | 202: ('accepted',), 16 | 203: ('non_authoritative_info', 'non_authoritative_information'), 17 | 204: ('no_content',), 18 | 205: ('reset_content', 'reset'), 19 | 206: ('partial_content', 'partial'), 20 | 207: ('multi_status', 'multiple_status', 'multi_stati', 'multiple_stati'), 21 | 208: ('already_reported',), 22 | 226: ('im_used',), 23 | 24 | # Redirection. 25 | 300: ('multiple_choices',), 26 | 301: ('moved_permanently', 'moved', '\\o-'), 27 | 302: ('found',), 28 | 303: ('see_other', 'other'), 29 | 304: ('not_modified',), 30 | 305: ('use_proxy',), 31 | 306: ('switch_proxy',), 32 | 307: ('temporary_redirect', 'temporary_moved', 'temporary'), 33 | 308: ('permanent_redirect', 34 | 'resume_incomplete', 'resume',), # These 2 to be removed in 3.0 35 | 36 | # Client Error. 37 | 400: ('bad_request', 'bad'), 38 | 401: ('unauthorized',), 39 | 402: ('payment_required', 'payment'), 40 | 403: ('forbidden',), 41 | 404: ('not_found', '-o-'), 42 | 405: ('method_not_allowed', 'not_allowed'), 43 | 406: ('not_acceptable',), 44 | 407: ('proxy_authentication_required', 'proxy_auth', 'proxy_authentication'), 45 | 408: ('request_timeout', 'timeout'), 46 | 409: ('conflict',), 47 | 410: ('gone',), 48 | 411: ('length_required',), 49 | 412: ('precondition_failed', 'precondition'), 50 | 413: ('request_entity_too_large',), 51 | 414: ('request_uri_too_large',), 52 | 415: ('unsupported_media_type', 'unsupported_media', 'media_type'), 53 | 416: ('requested_range_not_satisfiable', 'requested_range', 'range_not_satisfiable'), 54 | 417: ('expectation_failed',), 55 | 418: ('im_a_teapot', 'teapot', 'i_am_a_teapot'), 56 | 422: ('unprocessable_entity', 'unprocessable'), 57 | 423: ('locked',), 58 | 424: ('failed_dependency', 'dependency'), 59 | 425: ('unordered_collection', 'unordered'), 60 | 426: ('upgrade_required', 'upgrade'), 61 | 428: ('precondition_required', 'precondition'), 62 | 429: ('too_many_requests', 'too_many'), 63 | 431: ('header_fields_too_large', 'fields_too_large'), 64 | 444: ('no_response', 'none'), 65 | 449: ('retry_with', 'retry'), 66 | 450: ('blocked_by_windows_parental_controls', 'parental_controls'), 67 | 451: ('unavailable_for_legal_reasons', 'legal_reasons'), 68 | 499: ('client_closed_request',), 69 | 70 | # Server Error. 71 | 500: ('internal_server_error', 'server_error', '/o\\', '✗'), 72 | 501: ('not_implemented',), 73 | 502: ('bad_gateway',), 74 | 503: ('service_unavailable', 'unavailable'), 75 | 504: ('gateway_timeout',), 76 | 505: ('http_version_not_supported', 'http_version'), 77 | 506: ('variant_also_negotiates',), 78 | 507: ('insufficient_storage',), 79 | 509: ('bandwidth_limit_exceeded', 'bandwidth'), 80 | 510: ('not_extended',), 81 | } 82 | 83 | codes = LookupDict(name='status_codes') 84 | 85 | for (code, titles) in list(_codes.items()): 86 | for title in titles: 87 | setattr(codes, title, code) 88 | if not title.startswith('\\'): 89 | setattr(codes, title.upper(), code) 90 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/sbcsgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | from .charsetgroupprober import CharSetGroupProber 30 | from .sbcharsetprober import SingleByteCharSetProber 31 | from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel, 32 | Latin5CyrillicModel, MacCyrillicModel, 33 | Ibm866Model, Ibm855Model) 34 | from .langgreekmodel import Latin7GreekModel, Win1253GreekModel 35 | from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel 36 | from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel 37 | from .langthaimodel import TIS620ThaiModel 38 | from .langhebrewmodel import Win1255HebrewModel 39 | from .hebrewprober import HebrewProber 40 | 41 | 42 | class SBCSGroupProber(CharSetGroupProber): 43 | def __init__(self): 44 | CharSetGroupProber.__init__(self) 45 | self._mProbers = [ 46 | SingleByteCharSetProber(Win1251CyrillicModel), 47 | SingleByteCharSetProber(Koi8rModel), 48 | SingleByteCharSetProber(Latin5CyrillicModel), 49 | SingleByteCharSetProber(MacCyrillicModel), 50 | SingleByteCharSetProber(Ibm866Model), 51 | SingleByteCharSetProber(Ibm855Model), 52 | SingleByteCharSetProber(Latin7GreekModel), 53 | SingleByteCharSetProber(Win1253GreekModel), 54 | SingleByteCharSetProber(Latin5BulgarianModel), 55 | SingleByteCharSetProber(Win1251BulgarianModel), 56 | SingleByteCharSetProber(Latin2HungarianModel), 57 | SingleByteCharSetProber(Win1250HungarianModel), 58 | SingleByteCharSetProber(TIS620ThaiModel), 59 | ] 60 | hebrewProber = HebrewProber() 61 | logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, 62 | False, hebrewProber) 63 | visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True, 64 | hebrewProber) 65 | hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber) 66 | self._mProbers.extend([hebrewProber, logicalHebrewProber, 67 | visualHebrewProber]) 68 | 69 | self.reset() 70 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/mbcharsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # Proofpoint, Inc. 13 | # 14 | # This library is free software; you can redistribute it and/or 15 | # modify it under the terms of the GNU Lesser General Public 16 | # License as published by the Free Software Foundation; either 17 | # version 2.1 of the License, or (at your option) any later version. 18 | # 19 | # This library is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | # Lesser General Public License for more details. 23 | # 24 | # You should have received a copy of the GNU Lesser General Public 25 | # License along with this library; if not, write to the Free Software 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 27 | # 02110-1301 USA 28 | ######################### END LICENSE BLOCK ######################### 29 | 30 | import sys 31 | from . import constants 32 | from .charsetprober import CharSetProber 33 | 34 | 35 | class MultiByteCharSetProber(CharSetProber): 36 | def __init__(self): 37 | CharSetProber.__init__(self) 38 | self._mDistributionAnalyzer = None 39 | self._mCodingSM = None 40 | self._mLastChar = [0, 0] 41 | 42 | def reset(self): 43 | CharSetProber.reset(self) 44 | if self._mCodingSM: 45 | self._mCodingSM.reset() 46 | if self._mDistributionAnalyzer: 47 | self._mDistributionAnalyzer.reset() 48 | self._mLastChar = [0, 0] 49 | 50 | def get_charset_name(self): 51 | pass 52 | 53 | def feed(self, aBuf): 54 | aLen = len(aBuf) 55 | for i in range(0, aLen): 56 | codingState = self._mCodingSM.next_state(aBuf[i]) 57 | if codingState == constants.eError: 58 | if constants._debug: 59 | sys.stderr.write(self.get_charset_name() 60 | + ' prober hit error at byte ' + str(i) 61 | + '\n') 62 | self._mState = constants.eNotMe 63 | break 64 | elif codingState == constants.eItsMe: 65 | self._mState = constants.eFoundIt 66 | break 67 | elif codingState == constants.eStart: 68 | charLen = self._mCodingSM.get_current_charlen() 69 | if i == 0: 70 | self._mLastChar[1] = aBuf[0] 71 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 72 | else: 73 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1], 74 | charLen) 75 | 76 | self._mLastChar[0] = aBuf[aLen - 1] 77 | 78 | if self.get_state() == constants.eDetecting: 79 | if (self._mDistributionAnalyzer.got_enough_data() and 80 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)): 81 | self._mState = constants.eFoundIt 82 | 83 | return self.get_state() 84 | 85 | def get_confidence(self): 86 | return self._mDistributionAnalyzer.get_confidence() 87 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/util/connection.py: -------------------------------------------------------------------------------- 1 | import socket 2 | try: 3 | from select import poll, POLLIN 4 | except ImportError: # `poll` doesn't exist on OSX and other platforms 5 | poll = False 6 | try: 7 | from select import select 8 | except ImportError: # `select` doesn't exist on AppEngine. 9 | select = False 10 | 11 | 12 | def is_connection_dropped(conn): # Platform-specific 13 | """ 14 | Returns True if the connection is dropped and should be closed. 15 | 16 | :param conn: 17 | :class:`httplib.HTTPConnection` object. 18 | 19 | Note: For platforms like AppEngine, this will always return ``False`` to 20 | let the platform handle connection recycling transparently for us. 21 | """ 22 | sock = getattr(conn, 'sock', False) 23 | if sock is False: # Platform-specific: AppEngine 24 | return False 25 | if sock is None: # Connection already closed (such as by httplib). 26 | return True 27 | 28 | if not poll: 29 | if not select: # Platform-specific: AppEngine 30 | return False 31 | 32 | try: 33 | return select([sock], [], [], 0.0)[0] 34 | except socket.error: 35 | return True 36 | 37 | # This version is better on platforms that support it. 38 | p = poll() 39 | p.register(sock, POLLIN) 40 | for (fno, ev) in p.poll(0.0): 41 | if fno == sock.fileno(): 42 | # Either data is buffered (bad), or the connection is dropped. 43 | return True 44 | 45 | 46 | # This function is copied from socket.py in the Python 2.7 standard 47 | # library test suite. Added to its signature is only `socket_options`. 48 | def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 49 | source_address=None, socket_options=None): 50 | """Connect to *address* and return the socket object. 51 | 52 | Convenience function. Connect to *address* (a 2-tuple ``(host, 53 | port)``) and return the socket object. Passing the optional 54 | *timeout* parameter will set the timeout on the socket instance 55 | before attempting to connect. If no *timeout* is supplied, the 56 | global default timeout setting returned by :func:`getdefaulttimeout` 57 | is used. If *source_address* is set it must be a tuple of (host, port) 58 | for the socket to bind as a source address before making the connection. 59 | An host of '' or port 0 tells the OS to use the default. 60 | """ 61 | 62 | host, port = address 63 | err = None 64 | for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): 65 | af, socktype, proto, canonname, sa = res 66 | sock = None 67 | try: 68 | sock = socket.socket(af, socktype, proto) 69 | 70 | # If provided, set socket level options before connecting. 71 | # This is the only addition urllib3 makes to this function. 72 | _set_socket_options(sock, socket_options) 73 | 74 | if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT: 75 | sock.settimeout(timeout) 76 | if source_address: 77 | sock.bind(source_address) 78 | sock.connect(sa) 79 | return sock 80 | 81 | except socket.error as _: 82 | err = _ 83 | if sock is not None: 84 | sock.close() 85 | sock = None 86 | 87 | if err is not None: 88 | raise err 89 | else: 90 | raise socket.error("getaddrinfo returns an empty list") 91 | 92 | 93 | def _set_socket_options(sock, options): 94 | if options is None: 95 | return 96 | 97 | for opt in options: 98 | sock.setsockopt(*opt) 99 | -------------------------------------------------------------------------------- /src/lib/lxml/html/_html5builder.py: -------------------------------------------------------------------------------- 1 | """ 2 | Legacy module - don't use in new code! 3 | 4 | html5lib now has its own proper implementation. 5 | 6 | This module implements a tree builder for html5lib that generates lxml 7 | html element trees. This module uses camelCase as it follows the 8 | html5lib style guide. 9 | """ 10 | 11 | from html5lib.treebuilders import _base, etree as etree_builders 12 | from lxml import html, etree 13 | 14 | 15 | class DocumentType(object): 16 | 17 | def __init__(self, name, publicId, systemId): 18 | self.name = name 19 | self.publicId = publicId 20 | self.systemId = systemId 21 | 22 | class Document(object): 23 | 24 | def __init__(self): 25 | self._elementTree = None 26 | self.childNodes = [] 27 | 28 | def appendChild(self, element): 29 | self._elementTree.getroot().addnext(element._element) 30 | 31 | 32 | class TreeBuilder(_base.TreeBuilder): 33 | documentClass = Document 34 | doctypeClass = DocumentType 35 | elementClass = None 36 | commentClass = None 37 | fragmentClass = Document 38 | 39 | def __init__(self, *args, **kwargs): 40 | html_builder = etree_builders.getETreeModule(html, fullTree=False) 41 | etree_builder = etree_builders.getETreeModule(etree, fullTree=False) 42 | self.elementClass = html_builder.Element 43 | self.commentClass = etree_builder.Comment 44 | _base.TreeBuilder.__init__(self, *args, **kwargs) 45 | 46 | def reset(self): 47 | _base.TreeBuilder.reset(self) 48 | self.rootInserted = False 49 | self.initialComments = [] 50 | self.doctype = None 51 | 52 | def getDocument(self): 53 | return self.document._elementTree 54 | 55 | def getFragment(self): 56 | fragment = [] 57 | element = self.openElements[0]._element 58 | if element.text: 59 | fragment.append(element.text) 60 | fragment.extend(element.getchildren()) 61 | if element.tail: 62 | fragment.append(element.tail) 63 | return fragment 64 | 65 | def insertDoctype(self, name, publicId, systemId): 66 | doctype = self.doctypeClass(name, publicId, systemId) 67 | self.doctype = doctype 68 | 69 | def insertComment(self, data, parent=None): 70 | if not self.rootInserted: 71 | self.initialComments.append(data) 72 | else: 73 | _base.TreeBuilder.insertComment(self, data, parent) 74 | 75 | def insertRoot(self, name): 76 | buf = [] 77 | if self.doctype and self.doctype.name: 78 | buf.append('') 83 | buf.append('') 84 | root = html.fromstring(''.join(buf)) 85 | 86 | # Append the initial comments: 87 | for comment in self.initialComments: 88 | root.addprevious(etree.Comment(comment)) 89 | 90 | # Create the root document and add the ElementTree to it 91 | self.document = self.documentClass() 92 | self.document._elementTree = root.getroottree() 93 | 94 | # Add the root element to the internal child/open data structures 95 | root_element = self.elementClass(name) 96 | root_element._element = root 97 | self.document.childNodes.append(root_element) 98 | self.openElements.append(root_element) 99 | 100 | self.rootInserted = True 101 | -------------------------------------------------------------------------------- /src/lib/lxml/cssselect.py: -------------------------------------------------------------------------------- 1 | """CSS Selectors based on XPath. 2 | 3 | This module supports selecting XML/HTML tags based on CSS selectors. 4 | See the `CSSSelector` class for details. 5 | 6 | This is a thin wrapper around cssselect 0.7 or later. 7 | """ 8 | 9 | import sys 10 | from lxml import etree 11 | 12 | ## Work-around the lack of absolute import in Python 2.4 13 | #from __future__ import absolute_import 14 | #from cssselect import ... 15 | try: 16 | external_cssselect = __import__('cssselect') 17 | except ImportError: 18 | raise ImportError('cssselect seems not to be installed. ' 19 | 'See http://packages.python.org/cssselect/') 20 | 21 | SelectorSyntaxError = external_cssselect.SelectorSyntaxError 22 | ExpressionError = external_cssselect.ExpressionError 23 | SelectorError = external_cssselect.SelectorError 24 | 25 | 26 | __all__ = ['SelectorSyntaxError', 'ExpressionError', 'SelectorError', 27 | 'CSSSelector'] 28 | 29 | 30 | class LxmlTranslator(external_cssselect.GenericTranslator): 31 | """ 32 | A custom CSS selector to XPath translator with lxml-specific extensions. 33 | """ 34 | def xpath_contains_function(self, xpath, function): 35 | # Defined there, removed in later drafts: 36 | # http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#content-selectors 37 | if function.argument_types() not in (['STRING'], ['IDENT']): 38 | raise ExpressionError( 39 | "Expected a single string or ident for :contains(), got %r" 40 | % function.arguments) 41 | value = function.arguments[0].value 42 | return xpath.add_condition( 43 | 'contains(__lxml_internal_css:lower-case(string(.)), %s)' 44 | % self.xpath_literal(value.lower())) 45 | 46 | 47 | class LxmlHTMLTranslator(LxmlTranslator, external_cssselect.HTMLTranslator): 48 | """ 49 | lxml extensions + HTML support. 50 | """ 51 | 52 | 53 | def _make_lower_case(context, s): 54 | return s.lower() 55 | 56 | ns = etree.FunctionNamespace('http://codespeak.net/lxml/css/') 57 | ns.prefix = '__lxml_internal_css' 58 | ns['lower-case'] = _make_lower_case 59 | 60 | 61 | class CSSSelector(etree.XPath): 62 | """A CSS selector. 63 | 64 | Usage:: 65 | 66 | >>> from lxml import etree, cssselect 67 | >>> select = cssselect.CSSSelector("a tag > child") 68 | 69 | >>> root = etree.XML("TEXT") 70 | >>> [ el.tag for el in select(root) ] 71 | ['child'] 72 | 73 | To use CSS namespaces, you need to pass a prefix-to-namespace 74 | mapping as ``namespaces`` keyword argument:: 75 | 76 | >>> rdfns = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' 77 | >>> select_ns = cssselect.CSSSelector('root > rdf|Description', 78 | ... namespaces={'rdf': rdfns}) 79 | 80 | >>> rdf = etree.XML(( 81 | ... '' 82 | ... 'blah' 83 | ... '') % rdfns) 84 | >>> [(el.tag, el.text) for el in select_ns(rdf)] 85 | [('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description', 'blah')] 86 | 87 | """ 88 | def __init__(self, css, namespaces=None, translator='xml'): 89 | if translator == 'xml': 90 | translator = LxmlTranslator() 91 | elif translator == 'html': 92 | translator = LxmlHTMLTranslator() 93 | elif translator == 'xhtml': 94 | translator = LxmlHTMLTranslator(xhtml=True) 95 | path = translator.css_to_xpath(css) 96 | etree.XPath.__init__(self, path, namespaces=namespaces) 97 | self.css = css 98 | 99 | def __repr__(self): 100 | return '<%s %s for %r>' % ( 101 | self.__class__.__name__, 102 | hex(abs(id(self)))[2:], 103 | self.css) 104 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/eucjpprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | import sys 29 | from . import constants 30 | from .mbcharsetprober import MultiByteCharSetProber 31 | from .codingstatemachine import CodingStateMachine 32 | from .chardistribution import EUCJPDistributionAnalysis 33 | from .jpcntx import EUCJPContextAnalysis 34 | from .mbcssm import EUCJPSMModel 35 | 36 | 37 | class EUCJPProber(MultiByteCharSetProber): 38 | def __init__(self): 39 | MultiByteCharSetProber.__init__(self) 40 | self._mCodingSM = CodingStateMachine(EUCJPSMModel) 41 | self._mDistributionAnalyzer = EUCJPDistributionAnalysis() 42 | self._mContextAnalyzer = EUCJPContextAnalysis() 43 | self.reset() 44 | 45 | def reset(self): 46 | MultiByteCharSetProber.reset(self) 47 | self._mContextAnalyzer.reset() 48 | 49 | def get_charset_name(self): 50 | return "EUC-JP" 51 | 52 | def feed(self, aBuf): 53 | aLen = len(aBuf) 54 | for i in range(0, aLen): 55 | # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte 56 | codingState = self._mCodingSM.next_state(aBuf[i]) 57 | if codingState == constants.eError: 58 | if constants._debug: 59 | sys.stderr.write(self.get_charset_name() 60 | + ' prober hit error at byte ' + str(i) 61 | + '\n') 62 | self._mState = constants.eNotMe 63 | break 64 | elif codingState == constants.eItsMe: 65 | self._mState = constants.eFoundIt 66 | break 67 | elif codingState == constants.eStart: 68 | charLen = self._mCodingSM.get_current_charlen() 69 | if i == 0: 70 | self._mLastChar[1] = aBuf[0] 71 | self._mContextAnalyzer.feed(self._mLastChar, charLen) 72 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 73 | else: 74 | self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen) 75 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1], 76 | charLen) 77 | 78 | self._mLastChar[0] = aBuf[aLen - 1] 79 | 80 | if self.get_state() == constants.eDetecting: 81 | if (self._mContextAnalyzer.got_enough_data() and 82 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)): 83 | self._mState = constants.eFoundIt 84 | 85 | return self.get_state() 86 | 87 | def get_confidence(self): 88 | contxtCf = self._mContextAnalyzer.get_confidence() 89 | distribCf = self._mDistributionAnalyzer.get_confidence() 90 | return max(contxtCf, distribCf) 91 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/sjisprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | import sys 29 | from .mbcharsetprober import MultiByteCharSetProber 30 | from .codingstatemachine import CodingStateMachine 31 | from .chardistribution import SJISDistributionAnalysis 32 | from .jpcntx import SJISContextAnalysis 33 | from .mbcssm import SJISSMModel 34 | from . import constants 35 | 36 | 37 | class SJISProber(MultiByteCharSetProber): 38 | def __init__(self): 39 | MultiByteCharSetProber.__init__(self) 40 | self._mCodingSM = CodingStateMachine(SJISSMModel) 41 | self._mDistributionAnalyzer = SJISDistributionAnalysis() 42 | self._mContextAnalyzer = SJISContextAnalysis() 43 | self.reset() 44 | 45 | def reset(self): 46 | MultiByteCharSetProber.reset(self) 47 | self._mContextAnalyzer.reset() 48 | 49 | def get_charset_name(self): 50 | return self._mContextAnalyzer.get_charset_name() 51 | 52 | def feed(self, aBuf): 53 | aLen = len(aBuf) 54 | for i in range(0, aLen): 55 | codingState = self._mCodingSM.next_state(aBuf[i]) 56 | if codingState == constants.eError: 57 | if constants._debug: 58 | sys.stderr.write(self.get_charset_name() 59 | + ' prober hit error at byte ' + str(i) 60 | + '\n') 61 | self._mState = constants.eNotMe 62 | break 63 | elif codingState == constants.eItsMe: 64 | self._mState = constants.eFoundIt 65 | break 66 | elif codingState == constants.eStart: 67 | charLen = self._mCodingSM.get_current_charlen() 68 | if i == 0: 69 | self._mLastChar[1] = aBuf[0] 70 | self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:], 71 | charLen) 72 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 73 | else: 74 | self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3 75 | - charLen], charLen) 76 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1], 77 | charLen) 78 | 79 | self._mLastChar[0] = aBuf[aLen - 1] 80 | 81 | if self.get_state() == constants.eDetecting: 82 | if (self._mContextAnalyzer.got_enough_data() and 83 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)): 84 | self._mState = constants.eFoundIt 85 | 86 | return self.get_state() 87 | 88 | def get_confidence(self): 89 | contxtCf = self._mContextAnalyzer.get_confidence() 90 | distribCf = self._mDistributionAnalyzer.get_confidence() 91 | return max(contxtCf, distribCf) 92 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/charsetgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Communicator client code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | import sys 30 | from .charsetprober import CharSetProber 31 | 32 | 33 | class CharSetGroupProber(CharSetProber): 34 | def __init__(self): 35 | CharSetProber.__init__(self) 36 | self._mActiveNum = 0 37 | self._mProbers = [] 38 | self._mBestGuessProber = None 39 | 40 | def reset(self): 41 | CharSetProber.reset(self) 42 | self._mActiveNum = 0 43 | for prober in self._mProbers: 44 | if prober: 45 | prober.reset() 46 | prober.active = True 47 | self._mActiveNum += 1 48 | self._mBestGuessProber = None 49 | 50 | def get_charset_name(self): 51 | if not self._mBestGuessProber: 52 | self.get_confidence() 53 | if not self._mBestGuessProber: 54 | return None 55 | # self._mBestGuessProber = self._mProbers[0] 56 | return self._mBestGuessProber.get_charset_name() 57 | 58 | def feed(self, aBuf): 59 | for prober in self._mProbers: 60 | if not prober: 61 | continue 62 | if not prober.active: 63 | continue 64 | st = prober.feed(aBuf) 65 | if not st: 66 | continue 67 | if st == constants.eFoundIt: 68 | self._mBestGuessProber = prober 69 | return self.get_state() 70 | elif st == constants.eNotMe: 71 | prober.active = False 72 | self._mActiveNum -= 1 73 | if self._mActiveNum <= 0: 74 | self._mState = constants.eNotMe 75 | return self.get_state() 76 | return self.get_state() 77 | 78 | def get_confidence(self): 79 | st = self.get_state() 80 | if st == constants.eFoundIt: 81 | return 0.99 82 | elif st == constants.eNotMe: 83 | return 0.01 84 | bestConf = 0.0 85 | self._mBestGuessProber = None 86 | for prober in self._mProbers: 87 | if not prober: 88 | continue 89 | if not prober.active: 90 | if constants._debug: 91 | sys.stderr.write(prober.get_charset_name() 92 | + ' not active\n') 93 | continue 94 | cf = prober.get_confidence() 95 | if constants._debug: 96 | sys.stderr.write('%s confidence = %s\n' % 97 | (prober.get_charset_name(), cf)) 98 | if bestConf < cf: 99 | bestConf = cf 100 | self._mBestGuessProber = prober 101 | if not self._mBestGuessProber: 102 | return 0.0 103 | return bestConf 104 | # else: 105 | # self._mBestGuessProber = self._mProbers[0] 106 | # return self._mBestGuessProber.get_confidence() 107 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py: -------------------------------------------------------------------------------- 1 | """The match_hostname() function from Python 3.3.3, essential when using SSL.""" 2 | 3 | # Note: This file is under the PSF license as the code comes from the python 4 | # stdlib. http://docs.python.org/3/license.html 5 | 6 | import re 7 | 8 | __version__ = '3.4.0.2' 9 | 10 | class CertificateError(ValueError): 11 | pass 12 | 13 | 14 | def _dnsname_match(dn, hostname, max_wildcards=1): 15 | """Matching according to RFC 6125, section 6.4.3 16 | 17 | http://tools.ietf.org/html/rfc6125#section-6.4.3 18 | """ 19 | pats = [] 20 | if not dn: 21 | return False 22 | 23 | # Ported from python3-syntax: 24 | # leftmost, *remainder = dn.split(r'.') 25 | parts = dn.split(r'.') 26 | leftmost = parts[0] 27 | remainder = parts[1:] 28 | 29 | wildcards = leftmost.count('*') 30 | if wildcards > max_wildcards: 31 | # Issue #17980: avoid denials of service by refusing more 32 | # than one wildcard per fragment. A survey of established 33 | # policy among SSL implementations showed it to be a 34 | # reasonable choice. 35 | raise CertificateError( 36 | "too many wildcards in certificate DNS name: " + repr(dn)) 37 | 38 | # speed up common case w/o wildcards 39 | if not wildcards: 40 | return dn.lower() == hostname.lower() 41 | 42 | # RFC 6125, section 6.4.3, subitem 1. 43 | # The client SHOULD NOT attempt to match a presented identifier in which 44 | # the wildcard character comprises a label other than the left-most label. 45 | if leftmost == '*': 46 | # When '*' is a fragment by itself, it matches a non-empty dotless 47 | # fragment. 48 | pats.append('[^.]+') 49 | elif leftmost.startswith('xn--') or hostname.startswith('xn--'): 50 | # RFC 6125, section 6.4.3, subitem 3. 51 | # The client SHOULD NOT attempt to match a presented identifier 52 | # where the wildcard character is embedded within an A-label or 53 | # U-label of an internationalized domain name. 54 | pats.append(re.escape(leftmost)) 55 | else: 56 | # Otherwise, '*' matches any dotless string, e.g. www* 57 | pats.append(re.escape(leftmost).replace(r'\*', '[^.]*')) 58 | 59 | # add the remaining fragments, ignore any wildcards 60 | for frag in remainder: 61 | pats.append(re.escape(frag)) 62 | 63 | pat = re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE) 64 | return pat.match(hostname) 65 | 66 | 67 | def match_hostname(cert, hostname): 68 | """Verify that *cert* (in decoded format as returned by 69 | SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 70 | rules are followed, but IP addresses are not accepted for *hostname*. 71 | 72 | CertificateError is raised on failure. On success, the function 73 | returns nothing. 74 | """ 75 | if not cert: 76 | raise ValueError("empty or no certificate") 77 | dnsnames = [] 78 | san = cert.get('subjectAltName', ()) 79 | for key, value in san: 80 | if key == 'DNS': 81 | if _dnsname_match(value, hostname): 82 | return 83 | dnsnames.append(value) 84 | if not dnsnames: 85 | # The subject is only checked when there is no dNSName entry 86 | # in subjectAltName 87 | for sub in cert.get('subject', ()): 88 | for key, value in sub: 89 | # XXX according to RFC 2818, the most specific Common Name 90 | # must be used. 91 | if key == 'commonName': 92 | if _dnsname_match(value, hostname): 93 | return 94 | dnsnames.append(value) 95 | if len(dnsnames) > 1: 96 | raise CertificateError("hostname %r " 97 | "doesn't match either of %s" 98 | % (hostname, ', '.join(map(repr, dnsnames)))) 99 | elif len(dnsnames) == 1: 100 | raise CertificateError("hostname %r " 101 | "doesn't match %r" 102 | % (hostname, dnsnames[0])) 103 | else: 104 | raise CertificateError("no appropriate commonName or " 105 | "subjectAltName fields were found") 106 | -------------------------------------------------------------------------------- /src/lib/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/lib/lxml/html/defs.py: -------------------------------------------------------------------------------- 1 | # FIXME: this should all be confirmed against what a DTD says 2 | # (probably in a test; this may not match the DTD exactly, but we 3 | # should document just how it differs). 4 | 5 | # Data taken from http://www.w3.org/TR/html401/index/elements.html 6 | # and http://www.w3.org/community/webed/wiki/HTML/New_HTML5_Elements 7 | # for html5_tags. 8 | 9 | try: 10 | frozenset 11 | except NameError: 12 | from sets import Set as frozenset 13 | 14 | 15 | empty_tags = frozenset([ 16 | 'area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 17 | 'img', 'input', 'isindex', 'link', 'meta', 'param']) 18 | 19 | deprecated_tags = frozenset([ 20 | 'applet', 'basefont', 'center', 'dir', 'font', 'isindex', 21 | 'menu', 's', 'strike', 'u']) 22 | 23 | # archive actually takes a space-separated list of URIs 24 | link_attrs = frozenset([ 25 | 'action', 'archive', 'background', 'cite', 'classid', 26 | 'codebase', 'data', 'href', 'longdesc', 'profile', 'src', 27 | 'usemap', 28 | # Not standard: 29 | 'dynsrc', 'lowsrc', 30 | ]) 31 | 32 | # Not in the HTML 4 spec: 33 | # onerror, onresize 34 | event_attrs = frozenset([ 35 | 'onblur', 'onchange', 'onclick', 'ondblclick', 'onerror', 36 | 'onfocus', 'onkeydown', 'onkeypress', 'onkeyup', 'onload', 37 | 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 38 | 'onmouseup', 'onreset', 'onresize', 'onselect', 'onsubmit', 39 | 'onunload', 40 | ]) 41 | 42 | safe_attrs = frozenset([ 43 | 'abbr', 'accept', 'accept-charset', 'accesskey', 'action', 'align', 44 | 'alt', 'axis', 'border', 'cellpadding', 'cellspacing', 'char', 'charoff', 45 | 'charset', 'checked', 'cite', 'class', 'clear', 'cols', 'colspan', 46 | 'color', 'compact', 'coords', 'datetime', 'dir', 'disabled', 'enctype', 47 | 'for', 'frame', 'headers', 'height', 'href', 'hreflang', 'hspace', 'id', 48 | 'ismap', 'label', 'lang', 'longdesc', 'maxlength', 'media', 'method', 49 | 'multiple', 'name', 'nohref', 'noshade', 'nowrap', 'prompt', 'readonly', 50 | 'rel', 'rev', 'rows', 'rowspan', 'rules', 'scope', 'selected', 'shape', 51 | 'size', 'span', 'src', 'start', 'summary', 'tabindex', 'target', 'title', 52 | 'type', 'usemap', 'valign', 'value', 'vspace', 'width']) 53 | 54 | # From http://htmlhelp.com/reference/html40/olist.html 55 | top_level_tags = frozenset([ 56 | 'html', 'head', 'body', 'frameset', 57 | ]) 58 | 59 | head_tags = frozenset([ 60 | 'base', 'isindex', 'link', 'meta', 'script', 'style', 'title', 61 | ]) 62 | 63 | general_block_tags = frozenset([ 64 | 'address', 65 | 'blockquote', 66 | 'center', 67 | 'del', 68 | 'div', 69 | 'h1', 70 | 'h2', 71 | 'h3', 72 | 'h4', 73 | 'h5', 74 | 'h6', 75 | 'hr', 76 | 'ins', 77 | 'isindex', 78 | 'noscript', 79 | 'p', 80 | 'pre', 81 | ]) 82 | 83 | list_tags = frozenset([ 84 | 'dir', 'dl', 'dt', 'dd', 'li', 'menu', 'ol', 'ul', 85 | ]) 86 | 87 | table_tags = frozenset([ 88 | 'table', 'caption', 'colgroup', 'col', 89 | 'thead', 'tfoot', 'tbody', 'tr', 'td', 'th', 90 | ]) 91 | 92 | # just this one from 93 | # http://www.georgehernandez.com/h/XComputers/HTML/2BlockLevel.htm 94 | block_tags = general_block_tags | list_tags | table_tags | frozenset([ 95 | # Partial form tags 96 | 'fieldset', 'form', 'legend', 'optgroup', 'option', 97 | ]) 98 | 99 | form_tags = frozenset([ 100 | 'form', 'button', 'fieldset', 'legend', 'input', 'label', 101 | 'select', 'optgroup', 'option', 'textarea', 102 | ]) 103 | 104 | special_inline_tags = frozenset([ 105 | 'a', 'applet', 'basefont', 'bdo', 'br', 'embed', 'font', 'iframe', 106 | 'img', 'map', 'area', 'object', 'param', 'q', 'script', 107 | 'span', 'sub', 'sup', 108 | ]) 109 | 110 | phrase_tags = frozenset([ 111 | 'abbr', 'acronym', 'cite', 'code', 'del', 'dfn', 'em', 112 | 'ins', 'kbd', 'samp', 'strong', 'var', 113 | ]) 114 | 115 | font_style_tags = frozenset([ 116 | 'b', 'big', 'i', 's', 'small', 'strike', 'tt', 'u', 117 | ]) 118 | 119 | frame_tags = frozenset([ 120 | 'frameset', 'frame', 'noframes', 121 | ]) 122 | 123 | html5_tags = frozenset([ 124 | 'article', 'aside', 'audio', 'canvas', 'command', 'datalist', 125 | 'details', 'embed', 'figcaption', 'figure', 'footer', 'header', 126 | 'hgroup', 'keygen', 'mark', 'math', 'meter', 'nav', 'output', 127 | 'progress', 'rp', 'rt', 'ruby', 'section', 'source', 'summary', 128 | 'svg', 'time', 'track', 'video', 'wbr' 129 | ]) 130 | 131 | # These tags aren't standard 132 | nonstandard_tags = frozenset(['blink', 'marquee']) 133 | 134 | 135 | tags = (top_level_tags | head_tags | general_block_tags | list_tags 136 | | table_tags | form_tags | special_inline_tags | phrase_tags 137 | | font_style_tags | nonstandard_tags | html5_tags) 138 | -------------------------------------------------------------------------------- /src/lib/lxml/html/builder.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------- 2 | # The ElementTree toolkit is 3 | # Copyright (c) 1999-2004 by Fredrik Lundh 4 | # -------------------------------------------------------------------- 5 | 6 | """ 7 | A set of HTML generator tags for building HTML documents. 8 | 9 | Usage:: 10 | 11 | >>> from lxml.html.builder import * 12 | >>> html = HTML( 13 | ... HEAD( TITLE("Hello World") ), 14 | ... BODY( CLASS("main"), 15 | ... H1("Hello World !") 16 | ... ) 17 | ... ) 18 | 19 | >>> import lxml.etree 20 | >>> print lxml.etree.tostring(html, pretty_print=True) 21 | 22 | 23 | Hello World 24 | 25 | 26 |

Hello World !

27 | 28 | 29 | 30 | """ 31 | 32 | from lxml.builder import ElementMaker 33 | from lxml.html import html_parser 34 | 35 | E = ElementMaker(makeelement=html_parser.makeelement) 36 | 37 | # elements 38 | A = E.a # anchor 39 | ABBR = E.abbr # abbreviated form (e.g., WWW, HTTP, etc.) 40 | ACRONYM = E.acronym # 41 | ADDRESS = E.address # information on author 42 | APPLET = E.applet # Java applet (DEPRECATED) 43 | AREA = E.area # client-side image map area 44 | B = E.b # bold text style 45 | BASE = E.base # document base URI 46 | BASEFONT = E.basefont # base font size (DEPRECATED) 47 | BDO = E.bdo # I18N BiDi over-ride 48 | BIG = E.big # large text style 49 | BLOCKQUOTE = E.blockquote # long quotation 50 | BODY = E.body # document body 51 | BR = E.br # forced line break 52 | BUTTON = E.button # push button 53 | CAPTION = E.caption # table caption 54 | CENTER = E.center # shorthand for DIV align=center (DEPRECATED) 55 | CITE = E.cite # citation 56 | CODE = E.code # computer code fragment 57 | COL = E.col # table column 58 | COLGROUP = E.colgroup # table column group 59 | DD = E.dd # definition description 60 | DEL = getattr(E, 'del') # deleted text 61 | DFN = E.dfn # instance definition 62 | DIR = E.dir # directory list (DEPRECATED) 63 | DIV = E.div # generic language/style container 64 | DL = E.dl # definition list 65 | DT = E.dt # definition term 66 | EM = E.em # emphasis 67 | FIELDSET = E.fieldset # form control group 68 | FONT = E.font # local change to font (DEPRECATED) 69 | FORM = E.form # interactive form 70 | FRAME = E.frame # subwindow 71 | FRAMESET = E.frameset # window subdivision 72 | H1 = E.h1 # heading 73 | H2 = E.h2 # heading 74 | H3 = E.h3 # heading 75 | H4 = E.h4 # heading 76 | H5 = E.h5 # heading 77 | H6 = E.h6 # heading 78 | HEAD = E.head # document head 79 | HR = E.hr # horizontal rule 80 | HTML = E.html # document root element 81 | I = E.i # italic text style 82 | IFRAME = E.iframe # inline subwindow 83 | IMG = E.img # Embedded image 84 | INPUT = E.input # form control 85 | INS = E.ins # inserted text 86 | ISINDEX = E.isindex # single line prompt (DEPRECATED) 87 | KBD = E.kbd # text to be entered by the user 88 | LABEL = E.label # form field label text 89 | LEGEND = E.legend # fieldset legend 90 | LI = E.li # list item 91 | LINK = E.link # a media-independent link 92 | MAP = E.map # client-side image map 93 | MENU = E.menu # menu list (DEPRECATED) 94 | META = E.meta # generic metainformation 95 | NOFRAMES = E.noframes # alternate content container for non frame-based rendering 96 | NOSCRIPT = E.noscript # alternate content container for non script-based rendering 97 | OBJECT = E.object # generic embedded object 98 | OL = E.ol # ordered list 99 | OPTGROUP = E.optgroup # option group 100 | OPTION = E.option # selectable choice 101 | P = E.p # paragraph 102 | PARAM = E.param # named property value 103 | PRE = E.pre # preformatted text 104 | Q = E.q # short inline quotation 105 | S = E.s # strike-through text style (DEPRECATED) 106 | SAMP = E.samp # sample program output, scripts, etc. 107 | SCRIPT = E.script # script statements 108 | SELECT = E.select # option selector 109 | SMALL = E.small # small text style 110 | SPAN = E.span # generic language/style container 111 | STRIKE = E.strike # strike-through text (DEPRECATED) 112 | STRONG = E.strong # strong emphasis 113 | STYLE = E.style # style info 114 | SUB = E.sub # subscript 115 | SUP = E.sup # superscript 116 | TABLE = E.table # 117 | TBODY = E.tbody # table body 118 | TD = E.td # table data cell 119 | TEXTAREA = E.textarea # multi-line text field 120 | TFOOT = E.tfoot # table footer 121 | TH = E.th # table header cell 122 | THEAD = E.thead # table header 123 | TITLE = E.title # document title 124 | TR = E.tr # table row 125 | TT = E.tt # teletype or monospaced text style 126 | U = E.u # underlined text style (DEPRECATED) 127 | UL = E.ul # unordered list 128 | VAR = E.var # instance of a variable or program argument 129 | 130 | # attributes (only reserved words are included here) 131 | ATTR = dict 132 | def CLASS(v): return {'class': v} 133 | def FOR(v): return {'for': v} 134 | -------------------------------------------------------------------------------- /src/lib/lxml/html/soupparser.py: -------------------------------------------------------------------------------- 1 | __doc__ = """External interface to the BeautifulSoup HTML parser. 2 | """ 3 | 4 | __all__ = ["fromstring", "parse", "convert_tree"] 5 | 6 | from lxml import etree, html 7 | from BeautifulSoup import \ 8 | BeautifulSoup, Tag, Comment, ProcessingInstruction, NavigableString 9 | 10 | 11 | def fromstring(data, beautifulsoup=None, makeelement=None, **bsargs): 12 | """Parse a string of HTML data into an Element tree using the 13 | BeautifulSoup parser. 14 | 15 | Returns the root ```` Element of the tree. 16 | 17 | You can pass a different BeautifulSoup parser through the 18 | `beautifulsoup` keyword, and a diffent Element factory function 19 | through the `makeelement` keyword. By default, the standard 20 | ``BeautifulSoup`` class and the default factory of `lxml.html` are 21 | used. 22 | """ 23 | return _parse(data, beautifulsoup, makeelement, **bsargs) 24 | 25 | def parse(file, beautifulsoup=None, makeelement=None, **bsargs): 26 | """Parse a file into an ElemenTree using the BeautifulSoup parser. 27 | 28 | You can pass a different BeautifulSoup parser through the 29 | `beautifulsoup` keyword, and a diffent Element factory function 30 | through the `makeelement` keyword. By default, the standard 31 | ``BeautifulSoup`` class and the default factory of `lxml.html` are 32 | used. 33 | """ 34 | if not hasattr(file, 'read'): 35 | file = open(file) 36 | root = _parse(file, beautifulsoup, makeelement, **bsargs) 37 | return etree.ElementTree(root) 38 | 39 | def convert_tree(beautiful_soup_tree, makeelement=None): 40 | """Convert a BeautifulSoup tree to a list of Element trees. 41 | 42 | Returns a list instead of a single root Element to support 43 | HTML-like soup with more than one root element. 44 | 45 | You can pass a different Element factory through the `makeelement` 46 | keyword. 47 | """ 48 | if makeelement is None: 49 | makeelement = html.html_parser.makeelement 50 | root = _convert_tree(beautiful_soup_tree, makeelement) 51 | children = root.getchildren() 52 | for child in children: 53 | root.remove(child) 54 | return children 55 | 56 | 57 | # helpers 58 | 59 | def _parse(source, beautifulsoup, makeelement, **bsargs): 60 | if beautifulsoup is None: 61 | beautifulsoup = BeautifulSoup 62 | if makeelement is None: 63 | makeelement = html.html_parser.makeelement 64 | if 'convertEntities' not in bsargs: 65 | bsargs['convertEntities'] = 'html' 66 | tree = beautifulsoup(source, **bsargs) 67 | root = _convert_tree(tree, makeelement) 68 | # from ET: wrap the document in a html root element, if necessary 69 | if len(root) == 1 and root[0].tag == "html": 70 | return root[0] 71 | root.tag = "html" 72 | return root 73 | 74 | def _convert_tree(beautiful_soup_tree, makeelement): 75 | root = makeelement(beautiful_soup_tree.name, 76 | attrib=dict(beautiful_soup_tree.attrs)) 77 | _convert_children(root, beautiful_soup_tree, makeelement) 78 | return root 79 | 80 | def _convert_children(parent, beautiful_soup_tree, makeelement): 81 | SubElement = etree.SubElement 82 | et_child = None 83 | for child in beautiful_soup_tree: 84 | if isinstance(child, Tag): 85 | et_child = SubElement(parent, child.name, attrib=dict( 86 | [(k, unescape(v)) for (k,v) in child.attrs])) 87 | _convert_children(et_child, child, makeelement) 88 | elif type(child) is NavigableString: 89 | _append_text(parent, et_child, unescape(child)) 90 | else: 91 | if isinstance(child, Comment): 92 | parent.append(etree.Comment(child)) 93 | elif isinstance(child, ProcessingInstruction): 94 | parent.append(etree.ProcessingInstruction( 95 | *child.split(' ', 1))) 96 | else: # CData 97 | _append_text(parent, et_child, unescape(child)) 98 | 99 | def _append_text(parent, element, text): 100 | if element is None: 101 | parent.text = (parent.text or '') + text 102 | else: 103 | element.tail = (element.tail or '') + text 104 | 105 | 106 | # copied from ET's ElementSoup 107 | 108 | try: 109 | from html.entities import name2codepoint # Python 3 110 | except ImportError: 111 | from htmlentitydefs import name2codepoint 112 | import re 113 | 114 | handle_entities = re.compile("&(\w+);").sub 115 | 116 | def unescape(string): 117 | if not string: 118 | return '' 119 | # work around oddities in BeautifulSoup's entity handling 120 | def unescape_entity(m): 121 | try: 122 | return unichr(name2codepoint[m.group(1)]) 123 | except KeyError: 124 | return m.group(0) # use as is 125 | return handle_entities(unescape_entity, string) 126 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/contrib/ntlmpool.py: -------------------------------------------------------------------------------- 1 | """ 2 | NTLM authenticating pool, contributed by erikcederstran 3 | 4 | Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10 5 | """ 6 | 7 | try: 8 | from http.client import HTTPSConnection 9 | except ImportError: 10 | from httplib import HTTPSConnection 11 | from logging import getLogger 12 | from ntlm import ntlm 13 | 14 | from urllib3 import HTTPSConnectionPool 15 | 16 | 17 | log = getLogger(__name__) 18 | 19 | 20 | class NTLMConnectionPool(HTTPSConnectionPool): 21 | """ 22 | Implements an NTLM authentication version of an urllib3 connection pool 23 | """ 24 | 25 | scheme = 'https' 26 | 27 | def __init__(self, user, pw, authurl, *args, **kwargs): 28 | """ 29 | authurl is a random URL on the server that is protected by NTLM. 30 | user is the Windows user, probably in the DOMAIN\\username format. 31 | pw is the password for the user. 32 | """ 33 | super(NTLMConnectionPool, self).__init__(*args, **kwargs) 34 | self.authurl = authurl 35 | self.rawuser = user 36 | user_parts = user.split('\\', 1) 37 | self.domain = user_parts[0].upper() 38 | self.user = user_parts[1] 39 | self.pw = pw 40 | 41 | def _new_conn(self): 42 | # Performs the NTLM handshake that secures the connection. The socket 43 | # must be kept open while requests are performed. 44 | self.num_connections += 1 45 | log.debug('Starting NTLM HTTPS connection no. %d: https://%s%s' % 46 | (self.num_connections, self.host, self.authurl)) 47 | 48 | headers = {} 49 | headers['Connection'] = 'Keep-Alive' 50 | req_header = 'Authorization' 51 | resp_header = 'www-authenticate' 52 | 53 | conn = HTTPSConnection(host=self.host, port=self.port) 54 | 55 | # Send negotiation message 56 | headers[req_header] = ( 57 | 'NTLM %s' % ntlm.create_NTLM_NEGOTIATE_MESSAGE(self.rawuser)) 58 | log.debug('Request headers: %s' % headers) 59 | conn.request('GET', self.authurl, None, headers) 60 | res = conn.getresponse() 61 | reshdr = dict(res.getheaders()) 62 | log.debug('Response status: %s %s' % (res.status, res.reason)) 63 | log.debug('Response headers: %s' % reshdr) 64 | log.debug('Response data: %s [...]' % res.read(100)) 65 | 66 | # Remove the reference to the socket, so that it can not be closed by 67 | # the response object (we want to keep the socket open) 68 | res.fp = None 69 | 70 | # Server should respond with a challenge message 71 | auth_header_values = reshdr[resp_header].split(', ') 72 | auth_header_value = None 73 | for s in auth_header_values: 74 | if s[:5] == 'NTLM ': 75 | auth_header_value = s[5:] 76 | if auth_header_value is None: 77 | raise Exception('Unexpected %s response header: %s' % 78 | (resp_header, reshdr[resp_header])) 79 | 80 | # Send authentication message 81 | ServerChallenge, NegotiateFlags = \ 82 | ntlm.parse_NTLM_CHALLENGE_MESSAGE(auth_header_value) 83 | auth_msg = ntlm.create_NTLM_AUTHENTICATE_MESSAGE(ServerChallenge, 84 | self.user, 85 | self.domain, 86 | self.pw, 87 | NegotiateFlags) 88 | headers[req_header] = 'NTLM %s' % auth_msg 89 | log.debug('Request headers: %s' % headers) 90 | conn.request('GET', self.authurl, None, headers) 91 | res = conn.getresponse() 92 | log.debug('Response status: %s %s' % (res.status, res.reason)) 93 | log.debug('Response headers: %s' % dict(res.getheaders())) 94 | log.debug('Response data: %s [...]' % res.read()[:100]) 95 | if res.status != 200: 96 | if res.status == 401: 97 | raise Exception('Server rejected request: wrong ' 98 | 'username or password') 99 | raise Exception('Wrong server response: %s %s' % 100 | (res.status, res.reason)) 101 | 102 | res.fp = None 103 | log.debug('Connection established') 104 | return conn 105 | 106 | def urlopen(self, method, url, body=None, headers=None, retries=3, 107 | redirect=True, assert_same_host=True): 108 | if headers is None: 109 | headers = {} 110 | headers['Connection'] = 'Keep-Alive' 111 | return super(NTLMConnectionPool, self).urlopen(method, url, body, 112 | headers, retries, 113 | redirect, 114 | assert_same_host) 115 | -------------------------------------------------------------------------------- /src/lib/requests/packages/urllib3/exceptions.py: -------------------------------------------------------------------------------- 1 | 2 | ## Base Exceptions 3 | 4 | class HTTPError(Exception): 5 | "Base exception used by this module." 6 | pass 7 | 8 | class HTTPWarning(Warning): 9 | "Base warning used by this module." 10 | pass 11 | 12 | 13 | 14 | class PoolError(HTTPError): 15 | "Base exception for errors caused within a pool." 16 | def __init__(self, pool, message): 17 | self.pool = pool 18 | HTTPError.__init__(self, "%s: %s" % (pool, message)) 19 | 20 | def __reduce__(self): 21 | # For pickling purposes. 22 | return self.__class__, (None, None) 23 | 24 | 25 | class RequestError(PoolError): 26 | "Base exception for PoolErrors that have associated URLs." 27 | def __init__(self, pool, url, message): 28 | self.url = url 29 | PoolError.__init__(self, pool, message) 30 | 31 | def __reduce__(self): 32 | # For pickling purposes. 33 | return self.__class__, (None, self.url, None) 34 | 35 | 36 | class SSLError(HTTPError): 37 | "Raised when SSL certificate fails in an HTTPS connection." 38 | pass 39 | 40 | 41 | class ProxyError(HTTPError): 42 | "Raised when the connection to a proxy fails." 43 | pass 44 | 45 | 46 | class DecodeError(HTTPError): 47 | "Raised when automatic decoding based on Content-Type fails." 48 | pass 49 | 50 | 51 | class ProtocolError(HTTPError): 52 | "Raised when something unexpected happens mid-request/response." 53 | pass 54 | 55 | 56 | #: Renamed to ProtocolError but aliased for backwards compatibility. 57 | ConnectionError = ProtocolError 58 | 59 | 60 | ## Leaf Exceptions 61 | 62 | class MaxRetryError(RequestError): 63 | """Raised when the maximum number of retries is exceeded. 64 | 65 | :param pool: The connection pool 66 | :type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool` 67 | :param string url: The requested Url 68 | :param exceptions.Exception reason: The underlying error 69 | 70 | """ 71 | 72 | def __init__(self, pool, url, reason=None): 73 | self.reason = reason 74 | 75 | message = "Max retries exceeded with url: %s (Caused by %r)" % ( 76 | url, reason) 77 | 78 | RequestError.__init__(self, pool, url, message) 79 | 80 | 81 | class HostChangedError(RequestError): 82 | "Raised when an existing pool gets a request for a foreign host." 83 | 84 | def __init__(self, pool, url, retries=3): 85 | message = "Tried to open a foreign host with url: %s" % url 86 | RequestError.__init__(self, pool, url, message) 87 | self.retries = retries 88 | 89 | 90 | class TimeoutStateError(HTTPError): 91 | """ Raised when passing an invalid state to a timeout """ 92 | pass 93 | 94 | 95 | class TimeoutError(HTTPError): 96 | """ Raised when a socket timeout error occurs. 97 | 98 | Catching this error will catch both :exc:`ReadTimeoutErrors 99 | ` and :exc:`ConnectTimeoutErrors `. 100 | """ 101 | pass 102 | 103 | 104 | class ReadTimeoutError(TimeoutError, RequestError): 105 | "Raised when a socket timeout occurs while receiving data from a server" 106 | pass 107 | 108 | 109 | # This timeout error does not have a URL attached and needs to inherit from the 110 | # base HTTPError 111 | class ConnectTimeoutError(TimeoutError): 112 | "Raised when a socket timeout occurs while connecting to a server" 113 | pass 114 | 115 | 116 | class EmptyPoolError(PoolError): 117 | "Raised when a pool runs out of connections and no more are allowed." 118 | pass 119 | 120 | 121 | class ClosedPoolError(PoolError): 122 | "Raised when a request enters a pool after the pool has been closed." 123 | pass 124 | 125 | 126 | class LocationValueError(ValueError, HTTPError): 127 | "Raised when there is something wrong with a given URL input." 128 | pass 129 | 130 | 131 | class LocationParseError(LocationValueError): 132 | "Raised when get_host or similar fails to parse the URL input." 133 | 134 | def __init__(self, location): 135 | message = "Failed to parse: %s" % location 136 | HTTPError.__init__(self, message) 137 | 138 | self.location = location 139 | 140 | 141 | class ResponseError(HTTPError): 142 | "Used as a container for an error reason supplied in a MaxRetryError." 143 | GENERIC_ERROR = 'too many error responses' 144 | SPECIFIC_ERROR = 'too many {status_code} error responses' 145 | 146 | 147 | class SecurityWarning(HTTPWarning): 148 | "Warned when perfoming security reducing actions" 149 | pass 150 | 151 | 152 | class InsecureRequestWarning(SecurityWarning): 153 | "Warned when making an unverified HTTPS request." 154 | pass 155 | 156 | 157 | class SystemTimeWarning(SecurityWarning): 158 | "Warned when system time is suspected to be wrong" 159 | pass 160 | 161 | 162 | class InsecurePlatformWarning(SecurityWarning): 163 | "Warned when certain SSL configuration is not available on a platform." 164 | pass 165 | 166 | 167 | class ResponseNotChunked(ProtocolError, ValueError): 168 | "Response needs to be chunked in order to read it as chunks." 169 | pass 170 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/sbcharsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | import sys 30 | from . import constants 31 | from .charsetprober import CharSetProber 32 | from .compat import wrap_ord 33 | 34 | SAMPLE_SIZE = 64 35 | SB_ENOUGH_REL_THRESHOLD = 1024 36 | POSITIVE_SHORTCUT_THRESHOLD = 0.95 37 | NEGATIVE_SHORTCUT_THRESHOLD = 0.05 38 | SYMBOL_CAT_ORDER = 250 39 | NUMBER_OF_SEQ_CAT = 4 40 | POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 1 41 | #NEGATIVE_CAT = 0 42 | 43 | 44 | class SingleByteCharSetProber(CharSetProber): 45 | def __init__(self, model, reversed=False, nameProber=None): 46 | CharSetProber.__init__(self) 47 | self._mModel = model 48 | # TRUE if we need to reverse every pair in the model lookup 49 | self._mReversed = reversed 50 | # Optional auxiliary prober for name decision 51 | self._mNameProber = nameProber 52 | self.reset() 53 | 54 | def reset(self): 55 | CharSetProber.reset(self) 56 | # char order of last character 57 | self._mLastOrder = 255 58 | self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT 59 | self._mTotalSeqs = 0 60 | self._mTotalChar = 0 61 | # characters that fall in our sampling range 62 | self._mFreqChar = 0 63 | 64 | def get_charset_name(self): 65 | if self._mNameProber: 66 | return self._mNameProber.get_charset_name() 67 | else: 68 | return self._mModel['charsetName'] 69 | 70 | def feed(self, aBuf): 71 | if not self._mModel['keepEnglishLetter']: 72 | aBuf = self.filter_without_english_letters(aBuf) 73 | aLen = len(aBuf) 74 | if not aLen: 75 | return self.get_state() 76 | for c in aBuf: 77 | order = self._mModel['charToOrderMap'][wrap_ord(c)] 78 | if order < SYMBOL_CAT_ORDER: 79 | self._mTotalChar += 1 80 | if order < SAMPLE_SIZE: 81 | self._mFreqChar += 1 82 | if self._mLastOrder < SAMPLE_SIZE: 83 | self._mTotalSeqs += 1 84 | if not self._mReversed: 85 | i = (self._mLastOrder * SAMPLE_SIZE) + order 86 | model = self._mModel['precedenceMatrix'][i] 87 | else: # reverse the order of the letters in the lookup 88 | i = (order * SAMPLE_SIZE) + self._mLastOrder 89 | model = self._mModel['precedenceMatrix'][i] 90 | self._mSeqCounters[model] += 1 91 | self._mLastOrder = order 92 | 93 | if self.get_state() == constants.eDetecting: 94 | if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD: 95 | cf = self.get_confidence() 96 | if cf > POSITIVE_SHORTCUT_THRESHOLD: 97 | if constants._debug: 98 | sys.stderr.write('%s confidence = %s, we have a' 99 | 'winner\n' % 100 | (self._mModel['charsetName'], cf)) 101 | self._mState = constants.eFoundIt 102 | elif cf < NEGATIVE_SHORTCUT_THRESHOLD: 103 | if constants._debug: 104 | sys.stderr.write('%s confidence = %s, below negative' 105 | 'shortcut threshhold %s\n' % 106 | (self._mModel['charsetName'], cf, 107 | NEGATIVE_SHORTCUT_THRESHOLD)) 108 | self._mState = constants.eNotMe 109 | 110 | return self.get_state() 111 | 112 | def get_confidence(self): 113 | r = 0.01 114 | if self._mTotalSeqs > 0: 115 | r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs 116 | / self._mModel['mTypicalPositiveRatio']) 117 | r = r * self._mFreqChar / self._mTotalChar 118 | if r >= 1.0: 119 | r = 0.99 120 | return r 121 | -------------------------------------------------------------------------------- /src/stackoverflow.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # encoding: utf-8 3 | 4 | import sys 5 | 6 | from workflow import Workflow, ICON_ERROR, ICON_INFO 7 | 8 | __version__ = '1.2' 9 | 10 | def main(wf): 11 | from lxml import html 12 | import requests 13 | import json 14 | import urllib 15 | import re 16 | 17 | def search(query): 18 | if wf.update_available: 19 | wf.add_item('New version available', 20 | 'Press enter install the update', 21 | autocomplete='workflow:update', 22 | icon=ICON_INFO) 23 | 24 | if query.startswith("answer:"): 25 | show_answers_for_question(query.replace("answer:", "")) 26 | return 27 | 28 | searchTerm = ' '.join(['site:stackoverflow.com/questions'] + [query]) 29 | searchUrl = 'google.com/search?' + urllib.urlencode({'q': searchTerm}) 30 | 31 | searchResults = search_google(searchTerm) 32 | 33 | numResults = 0 34 | 35 | for result in searchResults: 36 | url = result['url'] 37 | if numResults is 0: 38 | stackoverflowResponse = requests.get(url) 39 | answers = get_stack_overflow_answers(stackoverflowResponse) 40 | if len(answers) > 0: 41 | numResults = numResults + 1 42 | question = get_question_title(stackoverflowResponse) 43 | output_answer(url, question, answers[0], "Best answer for: ") 44 | wf.add_item("Other Questions:", "(press TAB or ENTER to view answers)") 45 | else: 46 | wf.add_item( 47 | re.search("/([^/]*)$", url).group(1).replace("-", " "), 48 | "", 49 | copytext = url, 50 | autocomplete = "answer:" + url, 51 | arg = url, 52 | valid = True, 53 | icon = "appbar.question.png") 54 | 55 | if numResults is 0: 56 | wf.add_item( 57 | 'No results found', 58 | 'Select to view google search', 59 | arg = 'http://www.' + searchUrl, 60 | valid = True) 61 | 62 | # Send output to Alfred 63 | wf.send_feedback() 64 | 65 | def show_answers_for_question(url): 66 | stackoverflowResponse = requests.get(url) 67 | answers = get_stack_overflow_answers(stackoverflowResponse) 68 | question = get_question_title(stackoverflowResponse) 69 | for answer in answers: 70 | output_answer(url, question, answer) 71 | 72 | if len(answers) is 0: 73 | wf.add_item( 74 | 'No answers found', 75 | 'Select to view stack overflow question', 76 | arg = url, 77 | valid = True) 78 | wf.send_feedback() 79 | 80 | def output_answer(question_url, question_title, answer, subtitlePrefix = ""): 81 | answer_lines = answer_lines_by_priority(answer.find('.//div[@class="post-text"]')) 82 | wf.add_item( 83 | get_line(answer_lines, 0), 84 | subtitlePrefix + question_title, 85 | copytext = get_line(answer_lines, 0), 86 | largetext = answer.find('.//div[@class="post-text"]').text_content(), 87 | autocomplete = "answer:" + question_url, 88 | arg = question_url + "#" + answer.attrib["id"], 89 | valid = True, 90 | icon = "appbar.check.png") 91 | 92 | def search_google_api(query): 93 | response = requests.get('http://ajax.googleapis.com/ajax/services/search/web?v=1.0', params={'q': query}) 94 | 95 | parsedResponse = json.loads(response.content) 96 | 97 | if parsedResponse['responseDetails'] != None: 98 | wf.add_item( 99 | 'Google API limit has been hit: press enter to open google search', 100 | parsedResponse['responseDetails'], 101 | arg = 'http://www.google.com/search?' + urllib.urlencode({'q': query}), 102 | valid = True, 103 | icon = ICON_ERROR) 104 | 105 | if parsedResponse['responseData'] is None: 106 | return [] 107 | 108 | return parsedResponse['responseData']['results'] 109 | 110 | def search_google(query): 111 | response = requests.get('http://www.google.com/search', params={'q': query}) 112 | tree = html.fromstring(response.text) 113 | 114 | return map(lambda a: {"url": get_google_link_url(a.attrib["href"])}, tree.xpath('//h3[@class="r"]//a')) 115 | 116 | def get_google_link_url(url): 117 | if url.startswith("/url?"): 118 | return re.search("url\?q=([^&]*)", url).group(1) 119 | else: 120 | return url 121 | 122 | def get_stack_overflow_answers(resp): 123 | tree = html.fromstring(resp.text) 124 | return tree.xpath('//div[@id="answers"]//div[@itemtype="http://schema.org/Answer"]') 125 | 126 | def get_question_title(resp): 127 | tree = html.fromstring(resp.text) 128 | return tree.xpath('//div[@id="question-header"]//h1//a')[0].text_content() 129 | 130 | def answer_lines_by_priority(element): 131 | lines = [] 132 | 133 | for child in element: 134 | if child.tag == 'pre': 135 | lines.append(child.text_content()) 136 | 137 | for child in element: 138 | if child.tag != 'pre': 139 | lines.append(child.text_content()) 140 | 141 | return map(lambda l: l.replace('\n', ' '), lines) 142 | 143 | def get_line(lines, num): 144 | if len(lines) <= num: 145 | return 'No text found' 146 | else: 147 | return lines[num] 148 | 149 | search(wf.args[0]) 150 | 151 | if __name__ == '__main__': 152 | wf = Workflow(libraries=['./lib'], update_settings={ 153 | 'github_slug': 'Que3216/alfred-stack-overflow', 154 | 'version': __version__, 155 | # Optional number of days between checks for updates 156 | 'frequency': 1 157 | }) 158 | sys.exit(wf.run(main)) 159 | -------------------------------------------------------------------------------- /src/lib/requests/packages/chardet/latin1prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | from .charsetprober import CharSetProber 30 | from .constants import eNotMe 31 | from .compat import wrap_ord 32 | 33 | FREQ_CAT_NUM = 4 34 | 35 | UDF = 0 # undefined 36 | OTH = 1 # other 37 | ASC = 2 # ascii capital letter 38 | ASS = 3 # ascii small letter 39 | ACV = 4 # accent capital vowel 40 | ACO = 5 # accent capital other 41 | ASV = 6 # accent small vowel 42 | ASO = 7 # accent small other 43 | CLASS_NUM = 8 # total classes 44 | 45 | Latin1_CharToClass = ( 46 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 07 47 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F 48 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 17 49 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F 50 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 27 51 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F 52 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 37 53 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F 54 | OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 47 55 | ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F 56 | ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 57 57 | ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F 58 | OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 67 59 | ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F 60 | ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 77 61 | ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F 62 | OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 87 63 | OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F 64 | UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 97 65 | OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F 66 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A7 67 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF 68 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B7 69 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF 70 | ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C7 71 | ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF 72 | ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D7 73 | ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF 74 | ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E7 75 | ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF 76 | ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F7 77 | ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF 78 | ) 79 | 80 | # 0 : illegal 81 | # 1 : very unlikely 82 | # 2 : normal 83 | # 3 : very likely 84 | Latin1ClassModel = ( 85 | # UDF OTH ASC ASS ACV ACO ASV ASO 86 | 0, 0, 0, 0, 0, 0, 0, 0, # UDF 87 | 0, 3, 3, 3, 3, 3, 3, 3, # OTH 88 | 0, 3, 3, 3, 3, 3, 3, 3, # ASC 89 | 0, 3, 3, 3, 1, 1, 3, 3, # ASS 90 | 0, 3, 3, 3, 1, 2, 1, 2, # ACV 91 | 0, 3, 3, 3, 3, 3, 3, 3, # ACO 92 | 0, 3, 1, 3, 1, 1, 1, 3, # ASV 93 | 0, 3, 1, 3, 1, 1, 3, 3, # ASO 94 | ) 95 | 96 | 97 | class Latin1Prober(CharSetProber): 98 | def __init__(self): 99 | CharSetProber.__init__(self) 100 | self.reset() 101 | 102 | def reset(self): 103 | self._mLastCharClass = OTH 104 | self._mFreqCounter = [0] * FREQ_CAT_NUM 105 | CharSetProber.reset(self) 106 | 107 | def get_charset_name(self): 108 | return "windows-1252" 109 | 110 | def feed(self, aBuf): 111 | aBuf = self.filter_with_english_letters(aBuf) 112 | for c in aBuf: 113 | charClass = Latin1_CharToClass[wrap_ord(c)] 114 | freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM) 115 | + charClass] 116 | if freq == 0: 117 | self._mState = eNotMe 118 | break 119 | self._mFreqCounter[freq] += 1 120 | self._mLastCharClass = charClass 121 | 122 | return self.get_state() 123 | 124 | def get_confidence(self): 125 | if self.get_state() == eNotMe: 126 | return 0.01 127 | 128 | total = sum(self._mFreqCounter) 129 | if total < 0.01: 130 | confidence = 0.0 131 | else: 132 | confidence = ((self._mFreqCounter[3] - self._mFreqCounter[1] * 20.0) 133 | / total) 134 | if confidence < 0.0: 135 | confidence = 0.0 136 | # lower the confidence of latin1 so that other more accurate 137 | # detector can take priority. 138 | confidence = confidence * 0.73 139 | return confidence 140 | -------------------------------------------------------------------------------- /src/lib/requests/api.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.api 5 | ~~~~~~~~~~~~ 6 | 7 | This module implements the Requests API. 8 | 9 | :copyright: (c) 2012 by Kenneth Reitz. 10 | :license: Apache2, see LICENSE for more details. 11 | 12 | """ 13 | 14 | from . import sessions 15 | 16 | 17 | def request(method, url, **kwargs): 18 | """Constructs and sends a :class:`Request `. 19 | 20 | :param method: method for the new :class:`Request` object. 21 | :param url: URL for the new :class:`Request` object. 22 | :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. 23 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. 24 | :param json: (optional) json data to send in the body of the :class:`Request`. 25 | :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`. 26 | :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`. 27 | :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': ('filename', fileobj)}``) for multipart encoding upload. 28 | :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth. 29 | :param timeout: (optional) How long to wait for the server to send data 30 | before giving up, as a float, or a (`connect timeout, read timeout 31 | `_) tuple. 32 | :type timeout: float or tuple 33 | :param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed. 34 | :type allow_redirects: bool 35 | :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy. 36 | :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided. 37 | :param stream: (optional) if ``False``, the response content will be immediately downloaded. 38 | :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair. 39 | :return: :class:`Response ` object 40 | :rtype: requests.Response 41 | 42 | Usage:: 43 | 44 | >>> import requests 45 | >>> req = requests.request('GET', 'http://httpbin.org/get') 46 | 47 | """ 48 | 49 | session = sessions.Session() 50 | response = session.request(method=method, url=url, **kwargs) 51 | # By explicitly closing the session, we avoid leaving sockets open which 52 | # can trigger a ResourceWarning in some cases, and look like a memory leak 53 | # in others. 54 | session.close() 55 | return response 56 | 57 | 58 | def get(url, params=None, **kwargs): 59 | """Sends a GET request. 60 | 61 | :param url: URL for the new :class:`Request` object. 62 | :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. 63 | :param \*\*kwargs: Optional arguments that ``request`` takes. 64 | :return: :class:`Response ` object 65 | :rtype: requests.Response 66 | """ 67 | 68 | kwargs.setdefault('allow_redirects', True) 69 | return request('get', url, params=params, **kwargs) 70 | 71 | 72 | def options(url, **kwargs): 73 | """Sends a OPTIONS request. 74 | 75 | :param url: URL for the new :class:`Request` object. 76 | :param \*\*kwargs: Optional arguments that ``request`` takes. 77 | :return: :class:`Response ` object 78 | :rtype: requests.Response 79 | """ 80 | 81 | kwargs.setdefault('allow_redirects', True) 82 | return request('options', url, **kwargs) 83 | 84 | 85 | def head(url, **kwargs): 86 | """Sends a HEAD request. 87 | 88 | :param url: URL for the new :class:`Request` object. 89 | :param \*\*kwargs: Optional arguments that ``request`` takes. 90 | :return: :class:`Response ` object 91 | :rtype: requests.Response 92 | """ 93 | 94 | kwargs.setdefault('allow_redirects', False) 95 | return request('head', url, **kwargs) 96 | 97 | 98 | def post(url, data=None, json=None, **kwargs): 99 | """Sends a POST request. 100 | 101 | :param url: URL for the new :class:`Request` object. 102 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. 103 | :param json: (optional) json data to send in the body of the :class:`Request`. 104 | :param \*\*kwargs: Optional arguments that ``request`` takes. 105 | :return: :class:`Response ` object 106 | :rtype: requests.Response 107 | """ 108 | 109 | return request('post', url, data=data, json=json, **kwargs) 110 | 111 | 112 | def put(url, data=None, **kwargs): 113 | """Sends a PUT request. 114 | 115 | :param url: URL for the new :class:`Request` object. 116 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. 117 | :param \*\*kwargs: Optional arguments that ``request`` takes. 118 | :return: :class:`Response ` object 119 | :rtype: requests.Response 120 | """ 121 | 122 | return request('put', url, data=data, **kwargs) 123 | 124 | 125 | def patch(url, data=None, **kwargs): 126 | """Sends a PATCH request. 127 | 128 | :param url: URL for the new :class:`Request` object. 129 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. 130 | :param \*\*kwargs: Optional arguments that ``request`` takes. 131 | :return: :class:`Response ` object 132 | :rtype: requests.Response 133 | """ 134 | 135 | return request('patch', url, data=data, **kwargs) 136 | 137 | 138 | def delete(url, **kwargs): 139 | """Sends a DELETE request. 140 | 141 | :param url: URL for the new :class:`Request` object. 142 | :param \*\*kwargs: Optional arguments that ``request`` takes. 143 | :return: :class:`Response ` object 144 | :rtype: requests.Response 145 | """ 146 | 147 | return request('delete', url, **kwargs) 148 | --------------------------------------------------------------------------------