├── ntlm
├── __init__.py
├── des.py
├── U32.py
└── HTTPNtlmAuthHandler.py
├── .gitignore
├── requests
├── packages
│ ├── urllib3
│ │ ├── contrib
│ │ │ ├── __init__.py
│ │ │ └── ntlmpool.py
│ │ ├── packages
│ │ │ ├── __init__.py
│ │ │ └── ssl_match_hostname
│ │ │ │ ├── __init__.py
│ │ │ │ └── _implementation.py
│ │ ├── __init__.py
│ │ ├── filepost.py
│ │ ├── _collections.py
│ │ ├── exceptions.py
│ │ ├── request.py
│ │ ├── connection.py
│ │ └── fields.py
│ ├── __init__.py
│ └── chardet
│ │ ├── compat.py
│ │ ├── chardetect.py
│ │ ├── __init__.py
│ │ ├── constants.py
│ │ ├── euctwprober.py
│ │ ├── gb2312prober.py
│ │ ├── euckrprober.py
│ │ ├── big5prober.py
│ │ ├── cp949prober.py
│ │ ├── charsetprober.py
│ │ ├── mbcsgroupprober.py
│ │ ├── codingstatemachine.py
│ │ ├── utf8prober.py
│ │ ├── escprober.py
│ │ ├── sbcsgroupprober.py
│ │ ├── mbcharsetprober.py
│ │ ├── eucjpprober.py
│ │ ├── sjisprober.py
│ │ ├── charsetgroupprober.py
│ │ ├── sbcharsetprober.py
│ │ ├── latin1prober.py
│ │ └── universaldetector.py
├── .settings
│ └── org.eclipse.core.resources.prefs
├── .project
├── .pydevproject
├── certs.py
├── hooks.py
├── exceptions.py
├── __init__.py
├── compat.py
├── status_codes.py
├── structures.py
├── api.py
└── auth.py
├── icon.png
├── iconOLD.png
├── requests_ntlm
├── __init__.py
└── requests_ntlm.py
├── i18n
├── connector_de.qm
├── connector_en.qm
├── connector_en.ts
└── connector_de.ts
├── resources.qrc
├── help
├── source
│ ├── index.rst
│ └── conf.py
├── make.bat
└── Makefile
├── README.md
├── metadata.txt
├── __init__.py
├── inputdialog.py
├── connectordialog.py
├── XMLWriter.py
├── plugin_upload.py
├── input.ui
├── ui_connector.ui
├── ui_input.py
├── ui_connector.py
└── resources_rc.py
/ntlm/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | tmp/
3 | temp/
4 | conns.dat
--------------------------------------------------------------------------------
/requests/packages/urllib3/contrib/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geometalab/ArcGISConnector-QGIS-Plugin/HEAD/icon.png
--------------------------------------------------------------------------------
/iconOLD.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geometalab/ArcGISConnector-QGIS-Plugin/HEAD/iconOLD.png
--------------------------------------------------------------------------------
/requests/packages/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 |
3 | from . import urllib3
4 |
--------------------------------------------------------------------------------
/requests_ntlm/__init__.py:
--------------------------------------------------------------------------------
1 | from .requests_ntlm import HttpNtlmAuth
2 |
3 | __all__ = [HttpNtlmAuth]
4 |
--------------------------------------------------------------------------------
/i18n/connector_de.qm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geometalab/ArcGISConnector-QGIS-Plugin/HEAD/i18n/connector_de.qm
--------------------------------------------------------------------------------
/i18n/connector_en.qm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geometalab/ArcGISConnector-QGIS-Plugin/HEAD/i18n/connector_en.qm
--------------------------------------------------------------------------------
/requests/packages/urllib3/packages/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 |
3 | from . import ssl_match_hostname
4 |
5 |
--------------------------------------------------------------------------------
/resources.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | icon.png
4 |
5 |
6 |
--------------------------------------------------------------------------------
/requests/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/api.py=utf-8
3 | encoding/models.py=utf-8
4 | encoding/sessions.py=utf-8
5 |
--------------------------------------------------------------------------------
/requests/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | requests
4 |
5 |
6 |
7 |
8 |
9 | org.python.pydev.PyDevBuilder
10 |
11 |
12 |
13 |
14 |
15 | org.python.pydev.pythonNature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/requests/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | /${PROJECT_DIR_NAME}
5 |
6 | python 2.7
7 | Default
8 |
9 |
--------------------------------------------------------------------------------
/help/source/index.rst:
--------------------------------------------------------------------------------
1 | .. connector documentation master file, created by
2 | sphinx-quickstart on Sun Feb 12 17:11:03 2012.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Welcome to connector's documentation!
7 | ============================================
8 |
9 | Contents:
10 |
11 | .. toctree::
12 | :maxdepth: 2
13 |
14 | Indices and tables
15 | ==================
16 |
17 | * :ref:`genindex`
18 | * :ref:`modindex`
19 | * :ref:`search`
20 |
21 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
15 | import os.path
16 |
17 |
18 | def where():
19 | """Return the preferred certificate bundle."""
20 | # vendored bundle inside Requests
21 | return os.path.join(os.path.dirname(__file__), 'cacert.pem')
22 |
23 | if __name__ == '__main__':
24 | print(where())
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | "ArcGIS REST API Connector" (short name: ArcGISConnector).
2 |
3 | This plugin is in alpha release phase (QGIS experimental). Beta release (still QGIS experimental) is planned as of end of august 2015.
4 |
5 | A QGIS-Plugin which reads "Feature Services" - aka vector-based, WFS-alike services - from ArcGIS Online or ArcGIS Server. ArcGIS REST API includes also "Map Services" - aka raster-based WMS/WMTS-alike services - are currently NOT supported (and won't be supported in near future).
6 |
7 | Websites:
8 |
9 | * [Homepage](http://giswiki.hsr.ch/QGIS_ArcGIS_REST_API_Connector_Plugin)
10 |
11 | * [QGIS plugin directory](http://plugins.qgis.org/plugins/connector/)
12 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/metadata.txt:
--------------------------------------------------------------------------------
1 | # Mandatory items:
2 |
3 | [general]
4 | name=ArcGIS REST API Connector
5 | qgisMinimumVersion=2.0
6 | version=0.3.5
7 |
8 | author=Stefan Keller, Dennis Ligtenberg
9 | email=geometalab@ost.ch
10 |
11 | description=This plugin allows to connect to ArcGIS REST API Services. Currently only feature layers (from Feature Services or Map Services) are supported.
12 |
13 | about=A QGIS-Plugin which reads "Feature Services" - aka vector-based, WFS-alike services - from ArcGIS Online or ArcGIS Server. ArcGIS REST API includes also "Map Services" - aka raster-based WMS/WMTS-alike services - are currently NOT supported (and won't be supported in near future).
14 |
15 | repository=https://github.com/geometalab/ArcGISConnector-QGIS-Plugin
16 |
17 | # Optional items:
18 |
19 | homepage=http://giswiki.hsr.ch/QGIS_ArcGIS_REST_API_Connector_Plugin
20 | tracker=https://github.com/geometalab/ArcGISConnector-QGIS-Plugin/issues
21 |
22 | tags=vector, feature, layer, service, webservice, provider, arcgis
23 | icon=icon.png
24 | category=Web
25 | experimental=True
26 | server=False
27 | deprecated=False
28 |
29 | changelog=
30 | 0.3.5 2024-06-20: Update metadata
31 |
--------------------------------------------------------------------------------
/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | /***************************************************************************
4 | Connector
5 | A QGIS plugin
6 | ArcGIS REST API Connector
7 | -------------------
8 | begin : 2014-03-25
9 | copyright : (C) 2014 by tschmitz HSR
10 | email : tschmitz@hsr.ch
11 | ***************************************************************************/
12 |
13 | /***************************************************************************
14 | * *
15 | * This program is free software; you can redistribute it and/or modify *
16 | * it under the terms of the GNU General Public License as published by *
17 | * the Free Software Foundation; either version 2 of the License, or *
18 | * (at your option) any later version. *
19 | * *
20 | ***************************************************************************/
21 | This script initializes the plugin, making it known to QGIS.
22 | """
23 |
24 |
25 | def classFactory(iface):
26 | # load Connector class from file Connector
27 | from connector import Connector
28 | return Connector(iface)
29 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | from io import open
16 | from sys import argv, stdin
17 |
18 | from chardet.universaldetector import UniversalDetector
19 |
20 |
21 | def description_of(file, name='stdin'):
22 | """Return a string describing the probable encoding of a file."""
23 | u = UniversalDetector()
24 | for line in file:
25 | u.feed(line)
26 | u.close()
27 | result = u.result
28 | if result['encoding']:
29 | return '%s: %s with confidence %s' % (name,
30 | result['encoding'],
31 | result['confidence'])
32 | else:
33 | return '%s: no result' % name
34 |
35 |
36 | def main():
37 | if len(argv) <= 1:
38 | print(description_of(stdin))
39 | else:
40 | for path in argv[1:]:
41 | with open(path, 'rb') as f:
42 | print(description_of(f, path))
43 |
44 |
45 | if __name__ == '__main__':
46 | main()
47 |
--------------------------------------------------------------------------------
/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.2.1"
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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/inputdialog.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | /***************************************************************************
4 | ConnectorDialog
5 | A QGIS plugin
6 | ArcGIS REST API Connector
7 | -------------------
8 | begin : 2014-03-25
9 | copyright : (C) 2014 by tschmitz HSR
10 | email : tschmitz@hsr.ch
11 | ***************************************************************************/
12 |
13 | /***************************************************************************
14 | * *
15 | * This program is free software; you can redistribute it and/or modify *
16 | * it under the terms of the GNU General Public License as published by *
17 | * the Free Software Foundation; either version 2 of the License, or *
18 | * (at your option) any later version. *
19 | * *
20 | ***************************************************************************/
21 | """
22 |
23 | from PyQt4 import QtCore, QtGui
24 | from ui_input import Ui_Input
25 | # create the dialog for zoom to point
26 |
27 |
28 | class InputDialog(QtGui.QDialog, Ui_Input):
29 |
30 | def __init__(self):
31 | QtGui.QDialog.__init__(self)
32 | # Set up the user interface from Designer.
33 | # After setupUI you can access any designer object by doing
34 | # self., and you can use autoconnect slots - see
35 | # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
36 | # widgets-and-dialogs-with-auto-connect
37 | self.setupUi(self)
38 |
--------------------------------------------------------------------------------
/connectordialog.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | /***************************************************************************
4 | ConnectorDialog
5 | A QGIS plugin
6 | ArcGIS REST API Connector
7 | -------------------
8 | begin : 2014-03-25
9 | copyright : (C) 2014 by tschmitz HSR
10 | email : tschmitz@hsr.ch
11 | ***************************************************************************/
12 |
13 | /***************************************************************************
14 | * *
15 | * This program is free software; you can redistribute it and/or modify *
16 | * it under the terms of the GNU General Public License as published by *
17 | * the Free Software Foundation; either version 2 of the License, or *
18 | * (at your option) any later version. *
19 | * *
20 | ***************************************************************************/
21 | """
22 |
23 | from PyQt4 import QtCore, QtGui
24 | from ui_connector import Ui_Connector
25 | # create the dialog for zoom to point
26 |
27 |
28 | class ConnectorDialog(QtGui.QDialog, Ui_Connector):
29 |
30 | def __init__(self):
31 | QtGui.QDialog.__init__(self)
32 | # Set up the user interface from Designer.
33 | # After setupUI you can access any designer object by doing
34 | # self., and you can use autoconnect slots - see
35 | # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
36 | # widgets-and-dialogs-with-auto-connect
37 | self.setupUi(self)
38 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
36 | def __init__(self):
37 | MultiByteCharSetProber.__init__(self)
38 | self._mCodingSM = CodingStateMachine(EUCKRSMModel)
39 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis()
40 | self.reset()
41 |
42 | def get_charset_name(self):
43 | return "EUC-KR"
44 |
--------------------------------------------------------------------------------
/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 |
36 | def __init__(self):
37 | MultiByteCharSetProber.__init__(self)
38 | self._mCodingSM = CodingStateMachine(Big5SMModel)
39 | self._mDistributionAnalyzer = Big5DistributionAnalysis()
40 | self.reset()
41 |
42 | def get_charset_name(self):
43 | return "Big5"
44 |
--------------------------------------------------------------------------------
/requests/packages/urllib3/__init__.py:
--------------------------------------------------------------------------------
1 | # urllib3/__init__.py
2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | """
8 | urllib3 - Thread-safe connection pooling and re-using.
9 | """
10 |
11 | __author__ = 'Andrey Petrov (andrey.petrov@shazow.net)'
12 | __license__ = 'MIT'
13 | __version__ = 'dev'
14 |
15 |
16 | from .connectionpool import (
17 | HTTPConnectionPool,
18 | HTTPSConnectionPool,
19 | connection_from_url
20 | )
21 |
22 | from . import exceptions
23 | from .filepost import encode_multipart_formdata
24 | from .poolmanager import PoolManager, ProxyManager, proxy_from_url
25 | from .response import HTTPResponse
26 | from .util import make_headers, get_host, Timeout
27 |
28 |
29 | # Set default logging handler to avoid "No handler found" warnings.
30 | import logging
31 | try: # Python 2.7+
32 | from logging import NullHandler
33 | except ImportError:
34 | class NullHandler(logging.Handler):
35 | def emit(self, record):
36 | pass
37 |
38 | logging.getLogger(__name__).addHandler(NullHandler())
39 |
40 | def add_stderr_logger(level=logging.DEBUG):
41 | """
42 | Helper for quickly adding a StreamHandler to the logger. Useful for
43 | debugging.
44 |
45 | Returns the handler after adding it.
46 | """
47 | # This method needs to be in this __init__.py to get the __name__ correct
48 | # even if urllib3 is vendored within another package.
49 | logger = logging.getLogger(__name__)
50 | handler = logging.StreamHandler()
51 | handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
52 | logger.addHandler(handler)
53 | logger.setLevel(level)
54 | logger.debug('Added an stderr logging handler to logger: %s' % __name__)
55 | return handler
56 |
57 | # ... Clean up.
58 | del NullHandler
59 |
--------------------------------------------------------------------------------
/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 |
15 | """There was an ambiguous exception that occurred while handling your
16 | request."""
17 |
18 |
19 | class HTTPError(RequestException):
20 |
21 | """An HTTP error occurred."""
22 |
23 | def __init__(self, *args, **kwargs):
24 | """ Initializes HTTPError with optional `response` object. """
25 | self.response = kwargs.pop('response', None)
26 | super(HTTPError, self).__init__(*args, **kwargs)
27 |
28 |
29 | class ConnectionError(RequestException):
30 |
31 | """A Connection error occurred."""
32 |
33 |
34 | class ProxyError(ConnectionError):
35 |
36 | """A proxy error occurred."""
37 |
38 |
39 | class SSLError(ConnectionError):
40 |
41 | """An SSL error occurred."""
42 |
43 |
44 | class Timeout(RequestException):
45 |
46 | """The request timed out."""
47 |
48 |
49 | class URLRequired(RequestException):
50 |
51 | """A valid URL is required to make a request."""
52 |
53 |
54 | class TooManyRedirects(RequestException):
55 |
56 | """Too many redirects."""
57 |
58 |
59 | class MissingSchema(RequestException, ValueError):
60 |
61 | """The URL schema (e.g. http or https) is missing."""
62 |
63 |
64 | class InvalidSchema(RequestException, ValueError):
65 |
66 | """See defaults.py for valid schemas."""
67 |
68 |
69 | class InvalidURL(RequestException, ValueError):
70 |
71 | """ The URL provided was somehow invalid. """
72 |
73 |
74 | class ChunkedEncodingError(RequestException):
75 |
76 | """The server declared chunked encoding but sent an invalid chunk."""
77 |
78 |
79 | class ContentDecodingError(RequestException, BaseHTTPError):
80 |
81 | """Failed to decode response content"""
82 |
--------------------------------------------------------------------------------
/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 |
36 | def __init__(self):
37 | MultiByteCharSetProber.__init__(self)
38 | self._mCodingSM = CodingStateMachine(CP949SMModel)
39 | # NOTE: CP949 is a superset of EUC-KR, so the distribution should be
40 | # not different.
41 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis()
42 | self.reset()
43 |
44 | def get_charset_name(self):
45 | return "CP949"
46 |
--------------------------------------------------------------------------------
/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 |
35 | def __init__(self):
36 | pass
37 |
38 | def reset(self):
39 | self._mState = constants.eDetecting
40 |
41 | def get_charset_name(self):
42 | return None
43 |
44 | def feed(self, aBuf):
45 | pass
46 |
47 | def get_state(self):
48 | return self._mState
49 |
50 | def get_confidence(self):
51 | return 0.0
52 |
53 | def filter_high_bit_only(self, aBuf):
54 | aBuf = re.sub(b'([\x00-\x7F])+', b' ', aBuf)
55 | return aBuf
56 |
57 | def filter_without_english_letters(self, aBuf):
58 | aBuf = re.sub(b'([A-Za-z])+', b' ', aBuf)
59 | return aBuf
60 |
61 | def filter_with_english_letters(self, aBuf):
62 | # TODO
63 | return aBuf
64 |
--------------------------------------------------------------------------------
/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('http://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) 2014 by Kenneth Reitz.
40 | :license: Apache 2.0, see LICENSE for more details.
41 |
42 | """
43 |
44 | __title__ = 'requests'
45 | __version__ = '2.2.1'
46 | __build__ = 0x020201
47 | __author__ = 'Kenneth Reitz'
48 | __license__ = 'Apache 2.0'
49 | __copyright__ = 'Copyright 2014 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 |
75 | def emit(self, record):
76 | pass
77 |
78 | logging.getLogger(__name__).addHandler(NullHandler())
79 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/XMLWriter.py:
--------------------------------------------------------------------------------
1 | '''
2 | Created on 26.03.2014
3 |
4 | @author: tobi
5 | '''
6 |
7 | url = ""
8 | originX = -20037508.342787
9 | originY = 20037508.342787
10 | anzZooms = 18
11 | latestwkid = 900913
12 | blockX = 256
13 | blockY = 256
14 |
15 |
16 | def writeFile():
17 | text = '''
18 |
19 | '''
20 |
21 | text += str(url)
22 |
23 | text += '''
24 |
25 |
26 | '''
27 |
28 | text += str(originX)
29 |
30 | text += '''
31 | '''
32 |
33 | text += str(originY)
34 |
35 | text += '''
36 | '''
37 |
38 | text += str(originY)
39 |
40 | text += '''
41 | '''
42 |
43 | text += str(originX)
44 |
45 | text += '''
46 | '''
47 |
48 | text += str(anzZooms)
49 |
50 | text += '''
51 | 1
52 | 1
53 | top
54 |
55 | EPSG:'''
56 |
57 | text += str(latestwkid)
58 |
59 | text += '''
60 | '''
61 |
62 | text += str(blockX)
63 |
64 | text += '''
65 | '''
66 |
67 | text += str(blockY)
68 |
69 | text += '''
70 |
71 | '''
72 |
73 | return text
74 |
75 |
76 | def writeV2():
77 | text = '''
78 |
79 | '''
80 | text += url
81 |
82 | text += '''
83 |
84 |
85 | -20037508.34
86 | 20037508.34
87 | 20037508.34
88 | -20037508.34
89 | '''
90 |
91 | text += str(anzZooms)
92 |
93 | text += '''
94 | 1
95 | 1
96 | top
97 |
98 | EPSG:900913
99 | 256
100 | 256
101 | 3
102 |
103 | '''
104 | return text
105 |
--------------------------------------------------------------------------------
/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 |
34 | def __init__(self, sm):
35 | self._mModel = sm
36 | self._mCurrentBytePos = 0
37 | self._mCurrentCharLen = 0
38 | self.reset()
39 |
40 | def reset(self):
41 | self._mCurrentState = eStart
42 |
43 | def next_state(self, c):
44 | # for each byte we get its class
45 | # if it is first byte, we also get byte length
46 | # PY3K: aBuf is a byte stream, so c is an int, not a byte
47 | byteCls = self._mModel['classTable'][wrap_ord(c)]
48 | if self._mCurrentState == eStart:
49 | self._mCurrentBytePos = 0
50 | self._mCurrentCharLen = self._mModel['charLenTable'][byteCls]
51 | # from byte's class and stateTable, we get its next state
52 | curr_state = (self._mCurrentState * self._mModel['classFactor']
53 | + byteCls)
54 | self._mCurrentState = self._mModel['stateTable'][curr_state]
55 | self._mCurrentBytePos += 1
56 | return self._mCurrentState
57 |
58 | def get_current_charlen(self):
59 | return self._mCurrentCharLen
60 |
61 | def get_coding_state_machine(self):
62 | return self._mModel['name']
63 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/requests/packages/urllib3/filepost.py:
--------------------------------------------------------------------------------
1 | # urllib3/filepost.py
2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | import codecs
8 | import mimetypes
9 |
10 | from uuid import uuid4
11 | from io import BytesIO
12 |
13 | from .packages import six
14 | from .packages.six import b
15 | from .fields import RequestField
16 |
17 | writer = codecs.lookup('utf-8')[3]
18 |
19 |
20 | def choose_boundary():
21 | """
22 | Our embarassingly-simple replacement for mimetools.choose_boundary.
23 | """
24 | return uuid4().hex
25 |
26 |
27 | def iter_field_objects(fields):
28 | """
29 | Iterate over fields.
30 |
31 | Supports list of (k, v) tuples and dicts, and lists of
32 | :class:`~urllib3.fields.RequestField`.
33 |
34 | """
35 | if isinstance(fields, dict):
36 | i = six.iteritems(fields)
37 | else:
38 | i = iter(fields)
39 |
40 | for field in i:
41 | if isinstance(field, RequestField):
42 | yield field
43 | else:
44 | yield RequestField.from_tuples(*field)
45 |
46 |
47 | def iter_fields(fields):
48 | """
49 | .. deprecated:: 1.6
50 |
51 | Iterate over fields.
52 |
53 | The addition of :class:`~urllib3.fields.RequestField` makes this function
54 | obsolete. Instead, use :func:`iter_field_objects`, which returns
55 | :class:`~urllib3.fields.RequestField` objects.
56 |
57 | Supports list of (k, v) tuples and dicts.
58 | """
59 | if isinstance(fields, dict):
60 | return ((k, v) for k, v in six.iteritems(fields))
61 |
62 | return ((k, v) for k, v in fields)
63 |
64 |
65 | def encode_multipart_formdata(fields, boundary=None):
66 | """
67 | Encode a dictionary of ``fields`` using the multipart/form-data MIME format.
68 |
69 | :param fields:
70 | Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).
71 |
72 | :param boundary:
73 | If not specified, then a random boundary will be generated using
74 | :func:`mimetools.choose_boundary`.
75 | """
76 | body = BytesIO()
77 | if boundary is None:
78 | boundary = choose_boundary()
79 |
80 | for field in iter_field_objects(fields):
81 | body.write(b('--%s\r\n' % (boundary)))
82 |
83 | writer(body).write(field.render_headers())
84 | data = field.data
85 |
86 | if isinstance(data, int):
87 | data = str(data) # Backwards compatibility
88 |
89 | if isinstance(data, six.text_type):
90 | writer(body).write(data)
91 | else:
92 | body.write(data)
93 |
94 | body.write(b'\r\n')
95 |
96 | body.write(b('--%s--\r\n' % (boundary)))
97 |
98 | content_type = str('multipart/form-data; boundary=%s' % boundary)
99 |
100 | return body.getvalue(), content_type
101 |
--------------------------------------------------------------------------------
/plugin_upload.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # This script uploads a plugin package on the server
3 | #
4 | # Author: A. Pasotti, V. Picavet
5 |
6 | import xmlrpclib
7 | import sys
8 | import os
9 | import getpass
10 | from optparse import OptionParser
11 |
12 | # Configuration
13 | PROTOCOL = 'http'
14 | SERVER = 'plugins.qgis.org'
15 | PORT = '80'
16 | ENDPOINT = '/plugins/RPC2/'
17 | VERBOSE = False
18 |
19 |
20 | def main(options, args):
21 | address = "%s://%s:%s@%s:%s%s" % (PROTOCOL, options.username, options.password,
22 | options.server, options.port, ENDPOINT)
23 | print "Connecting to: %s" % hidepassword(address)
24 |
25 | server = xmlrpclib.ServerProxy(address, verbose=VERBOSE)
26 |
27 | try:
28 | plugin_id, version_id = server.plugin.upload(
29 | xmlrpclib.Binary(open(args[0]).read()))
30 | print "Plugin ID: %s" % plugin_id
31 | print "Version ID: %s" % version_id
32 | except xmlrpclib.ProtocolError, err:
33 | print "A protocol error occurred"
34 | print "URL: %s" % hidepassword(err.url, 0)
35 | print "HTTP/HTTPS headers: %s" % err.headers
36 | print "Error code: %d" % err.errcode
37 | print "Error message: %s" % err.errmsg
38 | except xmlrpclib.Fault, err:
39 | print "A fault occurred"
40 | print "Fault code: %d" % err.faultCode
41 | print "Fault string: %s" % err.faultString
42 |
43 |
44 | def hidepassword(url, start=6):
45 | """Returns the http url with password part replaced with '*'."""
46 | passdeb = url.find(':', start) + 1
47 | passend = url.find('@')
48 | return "%s%s%s" % (url[:passdeb], '*' * (passend - passdeb), url[passend:])
49 |
50 |
51 | if __name__ == "__main__":
52 | parser = OptionParser(usage="%prog [options] plugin.zip")
53 | parser.add_option("-w", "--password", dest="password",
54 | help="Password for plugin site", metavar="******")
55 | parser.add_option("-u", "--username", dest="username",
56 | help="Username of plugin site", metavar="user")
57 | parser.add_option("-p", "--port", dest="port",
58 | help="Server port to connect to", metavar="80")
59 | parser.add_option("-s", "--server", dest="server",
60 | help="Specify server name", metavar="plugins.qgis.org")
61 | (options, args) = parser.parse_args()
62 | if len(args) != 1:
63 | print "Please specify zip file.\n"
64 | parser.print_help()
65 | sys.exit(1)
66 | if not options.server:
67 | options.server = SERVER
68 | if not options.port:
69 | options.port = PORT
70 | if not options.username:
71 | # interactive mode
72 | username = getpass.getuser()
73 | print "Please enter user name [%s] :" % username,
74 | res = raw_input()
75 | if res != "":
76 | options.username = res
77 | else:
78 | options.username = username
79 | if not options.password:
80 | # interactive mode
81 | options.password = getpass.getpass()
82 | main(options, args)
83 |
--------------------------------------------------------------------------------
/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 | #: Python 3.0.x
25 | is_py30 = (is_py3 and _ver[1] == 0)
26 |
27 | #: Python 3.1.x
28 | is_py31 = (is_py3 and _ver[1] == 1)
29 |
30 | #: Python 3.2.x
31 | is_py32 = (is_py3 and _ver[1] == 2)
32 |
33 | #: Python 3.3.x
34 | is_py33 = (is_py3 and _ver[1] == 3)
35 |
36 | #: Python 3.4.x
37 | is_py34 = (is_py3 and _ver[1] == 4)
38 |
39 | #: Python 2.7.x
40 | is_py27 = (is_py2 and _ver[1] == 7)
41 |
42 | #: Python 2.6.x
43 | is_py26 = (is_py2 and _ver[1] == 6)
44 |
45 | #: Python 2.5.x
46 | is_py25 = (is_py2 and _ver[1] == 5)
47 |
48 | #: Python 2.4.x
49 | is_py24 = (is_py2 and _ver[1] == 4) # I'm assuming this is not by choice.
50 |
51 |
52 | # ---------
53 | # Platforms
54 | # ---------
55 |
56 |
57 | # Syntax sugar.
58 | _ver = sys.version.lower()
59 |
60 | is_pypy = ('pypy' in _ver)
61 | is_jython = ('jython' in _ver)
62 | is_ironpython = ('iron' in _ver)
63 |
64 | # Assume CPython, if nothing else.
65 | is_cpython = not any((is_pypy, is_jython, is_ironpython))
66 |
67 | # Windows-based system.
68 | is_windows = 'win32' in str(sys.platform).lower()
69 |
70 | # Standard Linux 2+ system.
71 | is_linux = ('linux' in str(sys.platform).lower())
72 | is_osx = ('darwin' in str(sys.platform).lower())
73 | is_hpux = ('hpux' in str(sys.platform).lower()) # Complete guess.
74 | is_solaris = ('solar==' in str(sys.platform).lower()) # Complete guess.
75 |
76 | try:
77 | import simplejson as json
78 | except ImportError:
79 | import json
80 |
81 | # ---------
82 | # Specifics
83 | # ---------
84 |
85 | if is_py2:
86 | from urllib import quote, unquote, quote_plus, unquote_plus, urlencode, getproxies, proxy_bypass
87 | from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag
88 | from urllib2 import parse_http_list
89 | import cookielib
90 | from Cookie import Morsel
91 | from StringIO import StringIO
92 | from .packages.urllib3.packages.ordered_dict import OrderedDict
93 | from httplib import IncompleteRead
94 |
95 | builtin_str = str
96 | bytes = str
97 | str = unicode
98 | basestring = basestring
99 | numeric_types = (int, long, float)
100 |
101 |
102 | elif is_py3:
103 | from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag
104 | from urllib.request import parse_http_list, getproxies, proxy_bypass
105 | from http import cookiejar as cookielib
106 | from http.cookies import Morsel
107 | from io import StringIO
108 | from collections import OrderedDict
109 | from http.client import IncompleteRead
110 |
111 | builtin_str = str
112 | str = str
113 | bytes = bytes
114 | basestring = (str, bytes)
115 | numeric_types = (int, float)
116 |
--------------------------------------------------------------------------------
/input.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Input
4 |
5 |
6 |
7 | 0
8 | 0
9 | 427
10 | 233
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
22 | -
23 |
24 |
25 | Service URL:
26 |
27 |
28 |
29 | -
30 |
31 |
32 | Username
33 |
34 |
35 |
36 | -
37 |
38 |
39 | Password
40 |
41 |
42 |
43 | -
44 |
45 |
46 | -
47 |
48 |
49 | -
50 |
51 |
52 | -
53 |
54 |
55 | Name
56 |
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 | Qt::Vertical
65 |
66 |
67 |
68 | 20
69 | 40
70 |
71 |
72 |
73 |
74 | -
75 |
76 |
-
77 |
78 |
79 | Qt::Horizontal
80 |
81 |
82 |
83 | 40
84 | 20
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 | Cancel
93 |
94 |
95 |
96 | -
97 |
98 |
99 | OK
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/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: ('resume_incomplete', 'resume'),
34 |
35 | # Client Error.
36 | 400: ('bad_request', 'bad'),
37 | 401: ('unauthorized',),
38 | 402: ('payment_required', 'payment'),
39 | 403: ('forbidden',),
40 | 404: ('not_found', '-o-'),
41 | 405: ('method_not_allowed', 'not_allowed'),
42 | 406: ('not_acceptable',),
43 | 407: ('proxy_authentication_required', 'proxy_auth', 'proxy_authentication'),
44 | 408: ('request_timeout', 'timeout'),
45 | 409: ('conflict',),
46 | 410: ('gone',),
47 | 411: ('length_required',),
48 | 412: ('precondition_failed', 'precondition'),
49 | 413: ('request_entity_too_large',),
50 | 414: ('request_uri_too_large',),
51 | 415: ('unsupported_media_type', 'unsupported_media', 'media_type'),
52 | 416: ('requested_range_not_satisfiable', 'requested_range', 'range_not_satisfiable'),
53 | 417: ('expectation_failed',),
54 | 418: ('im_a_teapot', 'teapot', 'i_am_a_teapot'),
55 | 422: ('unprocessable_entity', 'unprocessable'),
56 | 423: ('locked',),
57 | 424: ('failed_dependency', 'dependency'),
58 | 425: ('unordered_collection', 'unordered'),
59 | 426: ('upgrade_required', 'upgrade'),
60 | 428: ('precondition_required', 'precondition'),
61 | 429: ('too_many_requests', 'too_many'),
62 | 431: ('header_fields_too_large', 'fields_too_large'),
63 | 444: ('no_response', 'none'),
64 | 449: ('retry_with', 'retry'),
65 | 450: ('blocked_by_windows_parental_controls', 'parental_controls'),
66 | 451: ('unavailable_for_legal_reasons', 'legal_reasons'),
67 | 499: ('client_closed_request',),
68 |
69 | # Server Error.
70 | 500: ('internal_server_error', 'server_error', '/o\\', '✗'),
71 | 501: ('not_implemented',),
72 | 502: ('bad_gateway',),
73 | 503: ('service_unavailable', 'unavailable'),
74 | 504: ('gateway_timeout',),
75 | 505: ('http_version_not_supported', 'http_version'),
76 | 506: ('variant_also_negotiates',),
77 | 507: ('insufficient_storage',),
78 | 509: ('bandwidth_limit_exceeded', 'bandwidth'),
79 | 510: ('not_extended',),
80 | }
81 |
82 | codes = LookupDict(name='status_codes')
83 |
84 | for (code, titles) in list(_codes.items()):
85 | for title in titles:
86 | setattr(codes, title, code)
87 | if not title.startswith('\\'):
88 | setattr(codes, title.upper(), code)
89 |
--------------------------------------------------------------------------------
/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 |
38 | def __init__(self):
39 | CharSetProber.__init__(self)
40 | self._mCodingSM = [
41 | CodingStateMachine(HZSMModel),
42 | CodingStateMachine(ISO2022CNSMModel),
43 | CodingStateMachine(ISO2022JPSMModel),
44 | CodingStateMachine(ISO2022KRSMModel)
45 | ]
46 | self.reset()
47 |
48 | def reset(self):
49 | CharSetProber.reset(self)
50 | for codingSM in self._mCodingSM:
51 | if not codingSM:
52 | continue
53 | codingSM.active = True
54 | codingSM.reset()
55 | self._mActiveSM = len(self._mCodingSM)
56 | self._mDetectedCharset = None
57 |
58 | def get_charset_name(self):
59 | return self._mDetectedCharset
60 |
61 | def get_confidence(self):
62 | if self._mDetectedCharset:
63 | return 0.99
64 | else:
65 | return 0.00
66 |
67 | def feed(self, aBuf):
68 | for c in aBuf:
69 | # PY3K: aBuf is a byte array, so c is an int, not a byte
70 | for codingSM in self._mCodingSM:
71 | if not codingSM:
72 | continue
73 | if not codingSM.active:
74 | continue
75 | codingState = codingSM.next_state(wrap_ord(c))
76 | if codingState == constants.eError:
77 | codingSM.active = False
78 | self._mActiveSM -= 1
79 | if self._mActiveSM <= 0:
80 | self._mState = constants.eNotMe
81 | return self.get_state()
82 | elif codingState == constants.eItsMe:
83 | self._mState = constants.eFoundIt
84 | self._mDetectedCharset = codingSM.get_coding_state_machine() # nopep8
85 | return self.get_state()
86 |
87 | return self.get_state()
88 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/requests/packages/urllib3/_collections.py:
--------------------------------------------------------------------------------
1 | # urllib3/_collections.py
2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | from collections import MutableMapping
8 | try:
9 | from threading import RLock
10 | except ImportError: # Platform-specific: No threads available
11 | class RLock:
12 | def __enter__(self):
13 | pass
14 |
15 | def __exit__(self, exc_type, exc_value, traceback):
16 | pass
17 |
18 |
19 | try: # Python 2.7+
20 | from collections import OrderedDict
21 | except ImportError:
22 | from .packages.ordered_dict import OrderedDict
23 |
24 |
25 | __all__ = ['RecentlyUsedContainer']
26 |
27 |
28 | _Null = object()
29 |
30 |
31 | class RecentlyUsedContainer(MutableMapping):
32 | """
33 | Provides a thread-safe dict-like container which maintains up to
34 | ``maxsize`` keys while throwing away the least-recently-used keys beyond
35 | ``maxsize``.
36 |
37 | :param maxsize:
38 | Maximum number of recent elements to retain.
39 |
40 | :param dispose_func:
41 | Every time an item is evicted from the container,
42 | ``dispose_func(value)`` is called. Callback which will get called
43 | """
44 |
45 | ContainerCls = OrderedDict
46 |
47 | def __init__(self, maxsize=10, dispose_func=None):
48 | self._maxsize = maxsize
49 | self.dispose_func = dispose_func
50 |
51 | self._container = self.ContainerCls()
52 | self.lock = RLock()
53 |
54 | def __getitem__(self, key):
55 | # Re-insert the item, moving it to the end of the eviction line.
56 | with self.lock:
57 | item = self._container.pop(key)
58 | self._container[key] = item
59 | return item
60 |
61 | def __setitem__(self, key, value):
62 | evicted_value = _Null
63 | with self.lock:
64 | # Possibly evict the existing value of 'key'
65 | evicted_value = self._container.get(key, _Null)
66 | self._container[key] = value
67 |
68 | # If we didn't evict an existing value, we might have to evict the
69 | # least recently used item from the beginning of the container.
70 | if len(self._container) > self._maxsize:
71 | _key, evicted_value = self._container.popitem(last=False)
72 |
73 | if self.dispose_func and evicted_value is not _Null:
74 | self.dispose_func(evicted_value)
75 |
76 | def __delitem__(self, key):
77 | with self.lock:
78 | value = self._container.pop(key)
79 |
80 | if self.dispose_func:
81 | self.dispose_func(value)
82 |
83 | def __len__(self):
84 | with self.lock:
85 | return len(self._container)
86 |
87 | def __iter__(self):
88 | raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.')
89 |
90 | def clear(self):
91 | with self.lock:
92 | # Copy pointers to all values, then wipe the mapping
93 | # under Python 2, this copies the list of values twice :-|
94 | values = list(self._container.values())
95 | self._container.clear()
96 |
97 | if self.dispose_func:
98 | for value in values:
99 | self.dispose_func(value)
100 |
101 | def keys(self):
102 | with self.lock:
103 | return self._container.keys()
104 |
--------------------------------------------------------------------------------
/ntlm/des.py:
--------------------------------------------------------------------------------
1 | # This file is part of 'NTLM Authorization Proxy Server' http://sourceforge.net/projects/ntlmaps/
2 | # Copyright 2001 Dmitry A. Rozmanov
3 | #
4 | # This library is free software: you can redistribute it and/or
5 | # modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation, either
7 | # version 3 of the License, or (at your option) any later version.
8 |
9 | # This library is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # Lesser General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU Lesser General Public
15 | # License along with this library. If not, see
16 | # or
17 | # .
18 |
19 | import des_c
20 |
21 | #---------------------------------------------------------------------
22 |
23 |
24 | class DES:
25 |
26 | des_c_obj = None
27 |
28 | #-----------------------------------------------------------------
29 | def __init__(self, key_str):
30 | ""
31 | k = str_to_key56(key_str)
32 | k = key56_to_key64(k)
33 | key_str = ''
34 | for i in k:
35 | key_str += chr(i & 0xFF)
36 | self.des_c_obj = des_c.DES(key_str)
37 |
38 | #-----------------------------------------------------------------
39 | def encrypt(self, plain_text):
40 | ""
41 | return self.des_c_obj.encrypt(plain_text)
42 |
43 | #-----------------------------------------------------------------
44 | def decrypt(self, crypted_text):
45 | ""
46 | return self.des_c_obj.decrypt(crypted_text)
47 |
48 | #---------------------------------------------------------------------
49 | # Some Helpers
50 | #---------------------------------------------------------------------
51 |
52 | DESException = 'DESException'
53 |
54 | #---------------------------------------------------------------------
55 |
56 |
57 | def str_to_key56(key_str):
58 | ""
59 | if type(key_str) != type(''):
60 | # rise DESException, 'ERROR. Wrong key type.'
61 | pass
62 | if len(key_str) < 7:
63 | key_str = key_str + '\000\000\000\000\000\000\000'[:(7 - len(key_str))]
64 | key_56 = []
65 | for i in key_str[:7]:
66 | key_56.append(ord(i))
67 |
68 | return key_56
69 |
70 | #---------------------------------------------------------------------
71 |
72 |
73 | def key56_to_key64(key_56):
74 | ""
75 | key = []
76 | for i in range(8):
77 | key.append(0)
78 |
79 | key[0] = key_56[0]
80 | key[1] = ((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1)
81 | key[2] = ((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2)
82 | key[3] = ((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3)
83 | key[4] = ((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4)
84 | key[5] = ((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5)
85 | key[6] = ((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6)
86 | key[7] = (key_56[6] << 1) & 0xFF
87 |
88 | key = set_key_odd_parity(key)
89 |
90 | return key
91 |
92 | #---------------------------------------------------------------------
93 |
94 |
95 | def set_key_odd_parity(key):
96 | ""
97 | for i in range(len(key)):
98 | for k in range(7):
99 | bit = 0
100 | t = key[i] >> k
101 | bit = (t ^ bit) & 0x1
102 | key[i] = (key[i] & 0xFE) | bit
103 |
104 | return key
105 |
--------------------------------------------------------------------------------
/ntlm/U32.py:
--------------------------------------------------------------------------------
1 | # This file is part of 'NTLM Authorization Proxy Server' http://sourceforge.net/projects/ntlmaps/
2 | # Copyright 2001 Dmitry A. Rozmanov
3 | #
4 | # This library is free software: you can redistribute it and/or
5 | # modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation, either
7 | # version 3 of the License, or (at your option) any later version.
8 |
9 | # This library is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # Lesser General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU Lesser General Public
15 | # License along with this library. If not, see
16 | # or
17 | # .
18 |
19 |
20 | C = 0x1000000000L
21 |
22 |
23 | def norm(n):
24 | return n & 0xFFFFFFFFL
25 |
26 |
27 | class U32:
28 | v = 0L
29 |
30 | def __init__(self, value=0):
31 | self.v = C + norm(abs(long(value)))
32 |
33 | def set(self, value=0):
34 | self.v = C + norm(abs(long(value)))
35 |
36 | def __repr__(self):
37 | return hex(norm(self.v))
38 |
39 | def __long__(self):
40 | return long(norm(self.v))
41 |
42 | def __int__(self):
43 | return int(norm(self.v))
44 |
45 | def __chr__(self):
46 | return chr(norm(self.v))
47 |
48 | def __add__(self, b):
49 | r = U32()
50 | r.v = C + norm(self.v + b.v)
51 | return r
52 |
53 | def __sub__(self, b):
54 | r = U32()
55 | if self.v < b.v:
56 | r.v = C + norm(0x100000000L - (b.v - self.v))
57 | else:
58 | r.v = C + norm(self.v - b.v)
59 | return r
60 |
61 | def __mul__(self, b):
62 | r = U32()
63 | r.v = C + norm(self.v * b.v)
64 | return r
65 |
66 | def __div__(self, b):
67 | r = U32()
68 | r.v = C + (norm(self.v) / norm(b.v))
69 | return r
70 |
71 | def __mod__(self, b):
72 | r = U32()
73 | r.v = C + (norm(self.v) % norm(b.v))
74 | return r
75 |
76 | def __neg__(self):
77 | return U32(self.v)
78 |
79 | def __pos__(self):
80 | return U32(self.v)
81 |
82 | def __abs__(self):
83 | return U32(self.v)
84 |
85 | def __invert__(self):
86 | r = U32()
87 | r.v = C + norm(~self.v)
88 | return r
89 |
90 | def __lshift__(self, b):
91 | r = U32()
92 | r.v = C + norm(self.v << b)
93 | return r
94 |
95 | def __rshift__(self, b):
96 | r = U32()
97 | r.v = C + (norm(self.v) >> b)
98 | return r
99 |
100 | def __and__(self, b):
101 | r = U32()
102 | r.v = C + norm(self.v & b.v)
103 | return r
104 |
105 | def __or__(self, b):
106 | r = U32()
107 | r.v = C + norm(self.v | b.v)
108 | return r
109 |
110 | def __xor__(self, b):
111 | r = U32()
112 | r.v = C + norm(self.v ^ b.v)
113 | return r
114 |
115 | def __not__(self):
116 | return U32(not norm(self.v))
117 |
118 | def truth(self):
119 | return norm(self.v)
120 |
121 | def __cmp__(self, b):
122 | if norm(self.v) > norm(b.v):
123 | return 1
124 | elif norm(self.v) < norm(b.v):
125 | return -1
126 | else:
127 | return 0
128 |
129 | def __nonzero__(self):
130 | return norm(self.v)
131 |
--------------------------------------------------------------------------------
/requests/packages/urllib3/exceptions.py:
--------------------------------------------------------------------------------
1 | # urllib3/exceptions.py
2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 |
8 | ## Base Exceptions
9 |
10 | class HTTPError(Exception):
11 | "Base exception used by this module."
12 | pass
13 |
14 |
15 | class PoolError(HTTPError):
16 | "Base exception for errors caused within a pool."
17 | def __init__(self, pool, message):
18 | self.pool = pool
19 | HTTPError.__init__(self, "%s: %s" % (pool, message))
20 |
21 | def __reduce__(self):
22 | # For pickling purposes.
23 | return self.__class__, (None, None)
24 |
25 |
26 | class RequestError(PoolError):
27 | "Base exception for PoolErrors that have associated URLs."
28 | def __init__(self, pool, url, message):
29 | self.url = url
30 | PoolError.__init__(self, pool, message)
31 |
32 | def __reduce__(self):
33 | # For pickling purposes.
34 | return self.__class__, (None, self.url, None)
35 |
36 |
37 | class SSLError(HTTPError):
38 | "Raised when SSL certificate fails in an HTTPS connection."
39 | pass
40 |
41 |
42 | class ProxyError(HTTPError):
43 | "Raised when the connection to a proxy fails."
44 | pass
45 |
46 |
47 | class DecodeError(HTTPError):
48 | "Raised when automatic decoding based on Content-Type fails."
49 | pass
50 |
51 |
52 | ## Leaf Exceptions
53 |
54 | class MaxRetryError(RequestError):
55 | "Raised when the maximum number of retries is exceeded."
56 |
57 | def __init__(self, pool, url, reason=None):
58 | self.reason = reason
59 |
60 | message = "Max retries exceeded with url: %s" % url
61 | if reason:
62 | message += " (Caused by %s: %s)" % (type(reason), reason)
63 | else:
64 | message += " (Caused by redirect)"
65 |
66 | RequestError.__init__(self, pool, url, message)
67 |
68 |
69 | class HostChangedError(RequestError):
70 | "Raised when an existing pool gets a request for a foreign host."
71 |
72 | def __init__(self, pool, url, retries=3):
73 | message = "Tried to open a foreign host with url: %s" % url
74 | RequestError.__init__(self, pool, url, message)
75 | self.retries = retries
76 |
77 |
78 | class TimeoutStateError(HTTPError):
79 | """ Raised when passing an invalid state to a timeout """
80 | pass
81 |
82 |
83 | class TimeoutError(HTTPError):
84 | """ Raised when a socket timeout error occurs.
85 |
86 | Catching this error will catch both :exc:`ReadTimeoutErrors
87 | ` and :exc:`ConnectTimeoutErrors `.
88 | """
89 | pass
90 |
91 |
92 | class ReadTimeoutError(TimeoutError, RequestError):
93 | "Raised when a socket timeout occurs while receiving data from a server"
94 | pass
95 |
96 |
97 | # This timeout error does not have a URL attached and needs to inherit from the
98 | # base HTTPError
99 | class ConnectTimeoutError(TimeoutError):
100 | "Raised when a socket timeout occurs while connecting to a server"
101 | pass
102 |
103 |
104 | class EmptyPoolError(PoolError):
105 | "Raised when a pool runs out of connections and no more are allowed."
106 | pass
107 |
108 |
109 | class ClosedPoolError(PoolError):
110 | "Raised when a request enters a pool after the pool has been closed."
111 | pass
112 |
113 |
114 | class LocationParseError(ValueError, HTTPError):
115 | "Raised when get_host or similar fails to parse the URL input."
116 |
117 | def __init__(self, location):
118 | message = "Failed to parse: %s" % location
119 | HTTPError.__init__(self, message)
120 |
121 | self.location = location
122 |
--------------------------------------------------------------------------------
/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 |
39 | def __init__(self):
40 | MultiByteCharSetProber.__init__(self)
41 | self._mCodingSM = CodingStateMachine(EUCJPSMModel)
42 | self._mDistributionAnalyzer = EUCJPDistributionAnalysis()
43 | self._mContextAnalyzer = EUCJPContextAnalysis()
44 | self.reset()
45 |
46 | def reset(self):
47 | MultiByteCharSetProber.reset(self)
48 | self._mContextAnalyzer.reset()
49 |
50 | def get_charset_name(self):
51 | return "EUC-JP"
52 |
53 | def feed(self, aBuf):
54 | aLen = len(aBuf)
55 | for i in range(0, aLen):
56 | # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte
57 | codingState = self._mCodingSM.next_state(aBuf[i])
58 | if codingState == constants.eError:
59 | if constants._debug:
60 | sys.stderr.write(self.get_charset_name()
61 | + ' prober hit error at byte ' + str(i)
62 | + '\n')
63 | self._mState = constants.eNotMe
64 | break
65 | elif codingState == constants.eItsMe:
66 | self._mState = constants.eFoundIt
67 | break
68 | elif codingState == constants.eStart:
69 | charLen = self._mCodingSM.get_current_charlen()
70 | if i == 0:
71 | self._mLastChar[1] = aBuf[0]
72 | self._mContextAnalyzer.feed(self._mLastChar, charLen)
73 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
74 | else:
75 | self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], 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 |
--------------------------------------------------------------------------------
/i18n/connector_en.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Connector
6 |
7 | Warning
8 | Warning
9 |
10 |
11 | Info
12 | Info
13 |
14 |
15 | Question
16 | Question
17 |
18 |
19 | Connector
20 | ArcGIS REST API Connector
21 |
22 |
23 | Connections
24 | Connections
25 |
26 |
27 | Connect
28 | Connect
29 |
30 |
31 | New
32 | New
33 |
34 |
35 | Edit
36 | Edit
37 |
38 |
39 | Delete
40 | Delete
41 |
42 |
43 | Services
44 | Services
45 |
46 |
47 | Import Layer
48 | Import Layer
49 |
50 |
51 | Cancel
52 | Cancel
53 |
54 |
55 | Url not found.
56 | Url not found.
57 |
58 |
59 | Quering JSON must be allowed on the Server.
60 | Quering JSON must be allowed on the Server.
61 |
62 |
63 | Input SRID
64 | Input SRID
65 |
66 |
67 | Input the X-Extend
68 | Input the X-Extend
69 |
70 |
71 | Input the Y-Extend
72 | Input the Y-Extend
73 |
74 |
75 | Image width in pixels
76 | Image width in pixels
77 |
78 |
79 | Image height in pixels
80 | Image height in pixels
81 |
82 |
83 | Number of Zoom levels
84 | Number of Zoom levels
85 |
86 |
87 | Nothing selected
88 | Nothing selected
89 |
90 |
91 | Select a Service
92 | Select a Service
93 |
94 |
95 |
96 | Input
97 |
98 | Dialog
99 | Dialog
100 |
101 |
102 | Service URL:
103 | Service URL:
104 |
105 |
106 | Username
107 | Username:
108 |
109 |
110 | Password
111 | Password:
112 |
113 | Name
114 | Name:
115 |
116 |
117 | Cancel
118 | Cancel
119 |
120 |
121 | OK
122 | OK
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/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 "SHIFT_JIS"
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 |
--------------------------------------------------------------------------------
/i18n/connector_de.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Connector
6 |
7 | Warning
8 | Warnung
9 |
10 |
11 | Info
12 | Info
13 |
14 |
15 | Question
16 | Frage
17 |
18 |
19 | Connector
20 | ArcGIS REST API Connector
21 |
22 |
23 | Connections
24 | Verbindungen
25 |
26 |
27 | Connect
28 | Verbinden
29 |
30 |
31 | New
32 | Neu
33 |
34 |
35 | Edit
36 | Bearbeiten
37 |
38 |
39 | Delete
40 | Löschen
41 |
42 |
43 | Services
44 | Services
45 |
46 |
47 | Import Layer
48 | Layer Importieren
49 |
50 |
51 | Cancel
52 | Abbrechen
53 |
54 |
55 | Url not found.
56 | URL nicht gefunden.
57 |
58 |
59 | Quering JSON must be allowed on the Server.
60 | JSON Abfragen muessen auf dem Server erlaubt sein.
61 |
62 |
63 | Input SRID
64 | SRID Eingeben
65 |
66 |
67 | Input the X-Extend
68 | X-Extend Eingeben
69 |
70 |
71 | Input the Y-Extend
72 | Y-Extend Eingeben
73 |
74 |
75 | Image width in pixels
76 | Bildbreite in Pixel eingeben
77 |
78 |
79 | Image height in pixels
80 | Bildhoehe in Pixel eingeben
81 |
82 |
83 | Number of Zoom levels
84 | Anzahl der Zoom Ebenen eingeben
85 |
86 |
87 | Nothing selected
88 | Sie muessen zuerst einen Eintrag waehlen
89 |
90 |
91 | Select a Service
92 | Sie muessen einen Service waehlen
93 |
94 |
95 |
96 | Input
97 |
98 | Dialog
99 | Dialog
100 |
101 |
102 | Service URL:
103 | Service URL:
104 |
105 |
106 | Username
107 | Benutzername:
108 |
109 |
110 | Password
111 | Passwort:
112 |
113 | Name
114 | Name:
115 |
116 |
117 | Cancel
118 | Abbrechen
119 |
120 |
121 | OK
122 | OK
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/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 os
12 | import collections
13 | from itertools import islice
14 |
15 |
16 | class IteratorProxy(object):
17 |
18 | """docstring for IteratorProxy"""
19 |
20 | def __init__(self, i):
21 | self.i = i
22 | # self.i = chain.from_iterable(i)
23 |
24 | def __iter__(self):
25 | return self.i
26 |
27 | def __len__(self):
28 | if hasattr(self.i, '__len__'):
29 | return len(self.i)
30 | if hasattr(self.i, 'len'):
31 | return self.i.len
32 | if hasattr(self.i, 'fileno'):
33 | return os.fstat(self.i.fileno()).st_size
34 |
35 | def read(self, n):
36 | return "".join(islice(self.i, None, n))
37 |
38 |
39 | class CaseInsensitiveDict(collections.MutableMapping):
40 |
41 | """
42 | A case-insensitive ``dict``-like object.
43 |
44 | Implements all methods and operations of
45 | ``collections.MutableMapping`` as well as dict's ``copy``. Also
46 | provides ``lower_items``.
47 |
48 | All keys are expected to be strings. The structure remembers the
49 | case of the last key to be set, and ``iter(instance)``,
50 | ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()``
51 | will contain case-sensitive keys. However, querying and contains
52 | testing is case insensitive:
53 |
54 | cid = CaseInsensitiveDict()
55 | cid['Accept'] = 'application/json'
56 | cid['aCCEPT'] == 'application/json' # True
57 | list(cid) == ['Accept'] # True
58 |
59 | For example, ``headers['content-encoding']`` will return the
60 | value of a ``'Content-Encoding'`` response header, regardless
61 | of how the header name was originally stored.
62 |
63 | If the constructor, ``.update``, or equality comparison
64 | operations are given keys that have equal ``.lower()``s, the
65 | behavior is undefined.
66 |
67 | """
68 |
69 | def __init__(self, data=None, **kwargs):
70 | self._store = dict()
71 | if data is None:
72 | data = {}
73 | self.update(data, **kwargs)
74 |
75 | def __setitem__(self, key, value):
76 | # Use the lowercased key for lookups, but store the actual
77 | # key alongside the value.
78 | self._store[key.lower()] = (key, value)
79 |
80 | def __getitem__(self, key):
81 | return self._store[key.lower()][1]
82 |
83 | def __delitem__(self, key):
84 | del self._store[key.lower()]
85 |
86 | def __iter__(self):
87 | return (casedkey for casedkey, mappedvalue in self._store.values())
88 |
89 | def __len__(self):
90 | return len(self._store)
91 |
92 | def lower_items(self):
93 | """Like iteritems(), but with all lowercase keys."""
94 | return (
95 | (lowerkey, keyval[1])
96 | for (lowerkey, keyval)
97 | in self._store.items()
98 | )
99 |
100 | def __eq__(self, other):
101 | if isinstance(other, collections.Mapping):
102 | other = CaseInsensitiveDict(other)
103 | else:
104 | return NotImplemented
105 | # Compare insensitively
106 | return dict(self.lower_items()) == dict(other.lower_items())
107 |
108 | # Copy is required
109 | def copy(self):
110 | return CaseInsensitiveDict(self._store.values())
111 |
112 | def __repr__(self):
113 | return '%s(%r)' % (self.__class__.__name__, dict(self.items()))
114 |
115 |
116 | class LookupDict(dict):
117 |
118 | """Dictionary lookup object."""
119 |
120 | def __init__(self, name=None):
121 | self.name = name
122 | super(LookupDict, self).__init__()
123 |
124 | def __repr__(self):
125 | return '' % (self.name)
126 |
127 | def __getitem__(self, key):
128 | # We allow fall-through here, so values default to None
129 |
130 | return self.__dict__.get(key, None)
131 |
132 | def get(self, key, default=None):
133 | return self.__dict__.get(key, default)
134 |
--------------------------------------------------------------------------------
/ui_connector.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Connector
4 |
5 |
6 |
7 | 0
8 | 0
9 | 830
10 | 401
11 |
12 |
13 |
14 | Connector
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
22 | Connections
23 |
24 |
25 |
-
26 |
27 |
-
28 |
29 |
30 | -
31 |
32 |
-
33 |
34 |
35 | Connect
36 |
37 |
38 |
39 | -
40 |
41 |
42 | New
43 |
44 |
45 |
46 | -
47 |
48 |
49 | Edit
50 |
51 |
52 |
53 | -
54 |
55 |
56 | Delete
57 |
58 |
59 |
60 | -
61 |
62 |
63 | Qt::Horizontal
64 |
65 |
66 |
67 | 40
68 | 20
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | -
83 |
84 |
-
85 |
86 |
87 |
88 | Services
89 |
90 |
91 |
92 |
93 |
94 |
95 | -
96 |
97 |
-
98 |
99 |
100 | Qt::Horizontal
101 |
102 |
103 |
104 | 40
105 | 20
106 |
107 |
108 |
109 |
110 | -
111 |
112 |
113 | Import Layer
114 |
115 |
116 |
117 | -
118 |
119 |
120 | Cancel
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | importLayers
130 | cancelButton
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/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 |
35 | def __init__(self):
36 | CharSetProber.__init__(self)
37 | self._mActiveNum = 0
38 | self._mProbers = []
39 | self._mBestGuessProber = None
40 |
41 | def reset(self):
42 | CharSetProber.reset(self)
43 | self._mActiveNum = 0
44 | for prober in self._mProbers:
45 | if prober:
46 | prober.reset()
47 | prober.active = True
48 | self._mActiveNum += 1
49 | self._mBestGuessProber = None
50 |
51 | def get_charset_name(self):
52 | if not self._mBestGuessProber:
53 | self.get_confidence()
54 | if not self._mBestGuessProber:
55 | return None
56 | # self._mBestGuessProber = self._mProbers[0]
57 | return self._mBestGuessProber.get_charset_name()
58 |
59 | def feed(self, aBuf):
60 | for prober in self._mProbers:
61 | if not prober:
62 | continue
63 | if not prober.active:
64 | continue
65 | st = prober.feed(aBuf)
66 | if not st:
67 | continue
68 | if st == constants.eFoundIt:
69 | self._mBestGuessProber = prober
70 | return self.get_state()
71 | elif st == constants.eNotMe:
72 | prober.active = False
73 | self._mActiveNum -= 1
74 | if self._mActiveNum <= 0:
75 | self._mState = constants.eNotMe
76 | return self.get_state()
77 | return self.get_state()
78 |
79 | def get_confidence(self):
80 | st = self.get_state()
81 | if st == constants.eFoundIt:
82 | return 0.99
83 | elif st == constants.eNotMe:
84 | return 0.01
85 | bestConf = 0.0
86 | self._mBestGuessProber = None
87 | for prober in self._mProbers:
88 | if not prober:
89 | continue
90 | if not prober.active:
91 | if constants._debug:
92 | sys.stderr.write(prober.get_charset_name()
93 | + ' not active\n')
94 | continue
95 | cf = prober.get_confidence()
96 | if constants._debug:
97 | sys.stderr.write('%s confidence = %s\n' %
98 | (prober.get_charset_name(), cf))
99 | if bestConf < cf:
100 | bestConf = cf
101 | self._mBestGuessProber = prober
102 | if not self._mBestGuessProber:
103 | return 0.0
104 | return bestConf
105 | # else:
106 | # self._mBestGuessProber = self._mProbers[0]
107 | # return self._mBestGuessProber.get_confidence()
108 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ui_input.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'input.ui'
4 | #
5 | # Created: Fri Jun 06 17:25:41 2014
6 | # by: PyQt4 UI code generator 4.10.3
7 | #
8 | # WARNING! All changes made in this file will be lost!
9 |
10 | from PyQt4 import QtCore, QtGui
11 |
12 | try:
13 | _fromUtf8 = QtCore.QString.fromUtf8
14 | except AttributeError:
15 | def _fromUtf8(s):
16 | return s
17 |
18 | try:
19 | _encoding = QtGui.QApplication.UnicodeUTF8
20 |
21 | def _translate(context, text, disambig):
22 | return QtGui.QApplication.translate(context, text, disambig, _encoding)
23 | except AttributeError:
24 | def _translate(context, text, disambig):
25 | return QtGui.QApplication.translate(context, text, disambig)
26 |
27 |
28 | class Ui_Input(object):
29 |
30 | def setupUi(self, Input):
31 | Input.setObjectName(_fromUtf8("Input"))
32 | Input.resize(427, 233)
33 | self.verticalLayout = QtGui.QVBoxLayout(Input)
34 | self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
35 | self.formLayout = QtGui.QFormLayout()
36 | self.formLayout.setObjectName(_fromUtf8("formLayout"))
37 | self.serviceURLBox = QtGui.QLineEdit(Input)
38 | self.serviceURLBox.setObjectName(_fromUtf8("serviceURLBox"))
39 | self.formLayout.setWidget(
40 | 1, QtGui.QFormLayout.FieldRole, self.serviceURLBox)
41 | self.label = QtGui.QLabel(Input)
42 | self.label.setObjectName(_fromUtf8("label"))
43 | self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.label)
44 | self.label_2 = QtGui.QLabel(Input)
45 | self.label_2.setObjectName(_fromUtf8("label_2"))
46 | self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.label_2)
47 | self.label_3 = QtGui.QLabel(Input)
48 | self.label_3.setObjectName(_fromUtf8("label_3"))
49 | self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.label_3)
50 | self.usernameBox = QtGui.QLineEdit(Input)
51 | self.usernameBox.setObjectName(_fromUtf8("usernameBox"))
52 | self.formLayout.setWidget(
53 | 2, QtGui.QFormLayout.FieldRole, self.usernameBox)
54 | self.passwordBox = QtGui.QLineEdit(Input)
55 | self.passwordBox.setObjectName(_fromUtf8("passwordBox"))
56 | self.formLayout.setWidget(
57 | 3, QtGui.QFormLayout.FieldRole, self.passwordBox)
58 | self.nameBox = QtGui.QLineEdit(Input)
59 | self.nameBox.setObjectName(_fromUtf8("nameBox"))
60 | self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.nameBox)
61 | self.label_4 = QtGui.QLabel(Input)
62 | self.label_4.setObjectName(_fromUtf8("label_4"))
63 | self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.label_4)
64 | self.verticalLayout.addLayout(self.formLayout)
65 | spacerItem = QtGui.QSpacerItem(
66 | 20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
67 | self.verticalLayout.addItem(spacerItem)
68 | self.horizontalLayout = QtGui.QHBoxLayout()
69 | self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
70 | spacerItem1 = QtGui.QSpacerItem(
71 | 40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
72 | self.horizontalLayout.addItem(spacerItem1)
73 | self.cancelButton = QtGui.QPushButton(Input)
74 | self.cancelButton.setObjectName(_fromUtf8("cancelButton"))
75 | self.horizontalLayout.addWidget(self.cancelButton)
76 | self.OKButton = QtGui.QPushButton(Input)
77 | self.OKButton.setObjectName(_fromUtf8("OKButton"))
78 | self.horizontalLayout.addWidget(self.OKButton)
79 | self.verticalLayout.addLayout(self.horizontalLayout)
80 |
81 | self.retranslateUi(Input)
82 | QtCore.QMetaObject.connectSlotsByName(Input)
83 |
84 | def retranslateUi(self, Input):
85 | Input.setWindowTitle(_translate("Input", "Dialog", None))
86 | self.label.setText(_translate("Input", "Service URL:", None))
87 | self.label_2.setText(_translate("Input", "Username", None))
88 | self.label_3.setText(_translate("Input", "Password", None))
89 | self.label_4.setText(_translate("Input", "Name", None))
90 | self.cancelButton.setText(_translate("Input", "Cancel", None))
91 | self.OKButton.setText(_translate("Input", "OK", None))
92 |
--------------------------------------------------------------------------------
/requests_ntlm/requests_ntlm.py:
--------------------------------------------------------------------------------
1 | from ..requests.auth import AuthBase
2 | from ..requests.adapters import HTTPAdapter
3 | from ..requests.models import PreparedRequest
4 | from ..ntlm import ntlm
5 |
6 |
7 | class HttpNtlmAuth(AuthBase):
8 | """HTTP NTLM Authentication Handler for Requests. Supports pass-the-hash."""
9 |
10 | def __init__(self, username, password):
11 | """
12 | :username - Username in 'domain\\username' format
13 | :password - Password or hash in "ABCDABCDABCDABCD:ABCDABCDABCDABCD" format.
14 | """
15 | if ntlm is None:
16 | raise Exception("NTLM libraries unavailable")
17 | #parse the username
18 | try:
19 | self.domain, self.username = username.split('\\', 1)
20 | except ValueError:
21 | raise ValueError("username should be in 'domain\\username' format.")
22 | self.domain = self.domain.upper()
23 |
24 | self.password = password
25 | self.adapter = HTTPAdapter()
26 |
27 | def retry_using_http_NTLM_auth(self, auth_header_field, auth_header,
28 | response, args):
29 | """Attempts to authenticate using HTTP NTLM challenge/response"""
30 |
31 | if auth_header in response.request.headers:
32 | return response
33 |
34 | request = copy_request(response.request)
35 |
36 |
37 | # initial auth header with username. will result in challenge
38 | auth = 'NTLM %s' % ntlm.create_NTLM_NEGOTIATE_MESSAGE("%s\\%s" % (self.domain,self.username))
39 | request.headers[auth_header] = auth
40 |
41 | # we must keep the connection because NTLM authenticates the connection, not single requests
42 | request.headers["Connection"] = "Keep-Alive"
43 |
44 | # A streaming response breaks authentication.
45 | # This can be fixed by not streaming this request, which is safe because
46 | # the returned response3 will still have stream=True set if specified in
47 | # args. In addition, we expect this request to give us a challenge
48 | # and not the real content, so the content will be short anyway.
49 | args_nostream = dict(args, stream=False)
50 | response2 = self.adapter.send(request, **args_nostream)
51 |
52 | # this is important for some web applications that store authentication-related info in cookies (it took a long time to figure out)
53 | if response2.headers.get('set-cookie'):
54 | request.headers['Cookie'] = response2.headers.get('set-cookie')
55 |
56 | # get the challenge
57 | auth_header_value = response2.headers[auth_header_field]
58 | ntlm_header_value = filter(lambda s: s.startswith('NTLM '), auth_header_value.split(','))[0].strip()
59 | ServerChallenge, NegotiateFlags = ntlm.parse_NTLM_CHALLENGE_MESSAGE(ntlm_header_value[5:])
60 |
61 | # build response
62 | request = copy_request(request)
63 | auth = 'NTLM %s' % ntlm.create_NTLM_AUTHENTICATE_MESSAGE(ServerChallenge, self.username, self.domain, self.password, NegotiateFlags)
64 | request.headers[auth_header] = auth
65 |
66 | response3 = self.adapter.send(request, **args)
67 |
68 | # Update the history.
69 | response3.history.append(response)
70 | response3.history.append(response2)
71 |
72 | return response3
73 |
74 | def response_hook(self, r, **kwargs):
75 |
76 | if r.status_code == 401 and 'ntlm' in r.headers.get('www-authenticate','').lower():
77 | return self.retry_using_http_NTLM_auth('www-authenticate',
78 | 'Authorization', r, kwargs)
79 |
80 | if r.status_code == 407 and 'ntlm' in r.headers.get('proxy-authenticate','').lower():
81 | return self.retry_using_http_NTLM_auth('proxy-authenticate',
82 | 'Proxy-authorization', r,
83 | kwargs)
84 |
85 | return r
86 |
87 | def __call__(self, r):
88 | r.register_hook('response', self.response_hook)
89 | return r
90 |
91 |
92 | def copy_request(request):
93 | """
94 | Copies a Requests PreparedRequest.
95 | """
96 | new_request = PreparedRequest()
97 |
98 | new_request.method = request.method
99 | new_request.url = request.url
100 | new_request.body = request.body
101 | new_request.hooks = request.hooks
102 | new_request.headers = request.headers.copy()
103 |
104 | return new_request
105 |
--------------------------------------------------------------------------------
/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 | import sessions
15 |
16 |
17 | def request(method, url, **kwargs):
18 | """Constructs and sends a :class:`Request `.
19 | Returns :class:`Response ` object.
20 |
21 | :param method: method for the new :class:`Request` object.
22 | :param url: URL for the new :class:`Request` object.
23 | :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.
24 | :param data: (optional) Dictionary, bytes, or file-like object 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) Float describing the timeout of the request.
30 | :param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
31 | :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
32 | :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided.
33 | :param stream: (optional) if ``False``, the response content will be immediately downloaded.
34 | :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
35 |
36 | Usage::
37 |
38 | >>> import requests
39 | >>> req = requests.request('GET', 'http://httpbin.org/get')
40 |
41 | """
42 |
43 | session = sessions.Session()
44 | return session.request(method=method, url=url, **kwargs)
45 |
46 |
47 | def get(url, **kwargs):
48 | """Sends a GET request. Returns :class:`Response` object.
49 |
50 | :param url: URL for the new :class:`Request` object.
51 | :param \*\*kwargs: Optional arguments that ``request`` takes.
52 | """
53 |
54 | kwargs.setdefault('allow_redirects', True)
55 | return request('get', url, **kwargs)
56 |
57 |
58 | def options(url, **kwargs):
59 | """Sends a OPTIONS request. Returns :class:`Response` object.
60 |
61 | :param url: URL for the new :class:`Request` object.
62 | :param \*\*kwargs: Optional arguments that ``request`` takes.
63 | """
64 |
65 | kwargs.setdefault('allow_redirects', True)
66 | return request('options', url, **kwargs)
67 |
68 |
69 | def head(url, **kwargs):
70 | """Sends a HEAD request. Returns :class:`Response` object.
71 |
72 | :param url: URL for the new :class:`Request` object.
73 | :param \*\*kwargs: Optional arguments that ``request`` takes.
74 | """
75 |
76 | kwargs.setdefault('allow_redirects', False)
77 | return request('head', url, **kwargs)
78 |
79 |
80 | def post(url, data=None, **kwargs):
81 | """Sends a POST request. Returns :class:`Response` object.
82 |
83 | :param url: URL for the new :class:`Request` object.
84 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
85 | :param \*\*kwargs: Optional arguments that ``request`` takes.
86 | """
87 |
88 | return request('post', url, data=data, **kwargs)
89 |
90 |
91 | def put(url, data=None, **kwargs):
92 | """Sends a PUT request. Returns :class:`Response` object.
93 |
94 | :param url: URL for the new :class:`Request` object.
95 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
96 | :param \*\*kwargs: Optional arguments that ``request`` takes.
97 | """
98 |
99 | return request('put', url, data=data, **kwargs)
100 |
101 |
102 | def patch(url, data=None, **kwargs):
103 | """Sends a PATCH request. Returns :class:`Response` object.
104 |
105 | :param url: URL for the new :class:`Request` object.
106 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
107 | :param \*\*kwargs: Optional arguments that ``request`` takes.
108 | """
109 |
110 | return request('patch', url, data=data, **kwargs)
111 |
112 |
113 | def delete(url, **kwargs):
114 | """Sends a DELETE request. Returns :class:`Response` object.
115 |
116 | :param url: URL for the new :class:`Request` object.
117 | :param \*\*kwargs: Optional arguments that ``request`` takes.
118 | """
119 |
120 | return request('delete', url, **kwargs)
121 |
--------------------------------------------------------------------------------
/help/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | REM Command file for Sphinx documentation
4 |
5 | if "%SPHINXBUILD%" == "" (
6 | set SPHINXBUILD=sphinx-build
7 | )
8 | set BUILDDIR=build
9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
10 | if NOT "%PAPER%" == "" (
11 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
12 | )
13 |
14 | if "%1" == "" goto help
15 |
16 | if "%1" == "help" (
17 | :help
18 | echo.Please use `make ^` where ^ is one of
19 | echo. html to make standalone HTML files
20 | echo. dirhtml to make HTML files named index.html in directories
21 | echo. singlehtml to make a single large HTML file
22 | echo. pickle to make pickle files
23 | echo. json to make JSON files
24 | echo. htmlhelp to make HTML files and a HTML help project
25 | echo. qthelp to make HTML files and a qthelp project
26 | echo. devhelp to make HTML files and a Devhelp project
27 | echo. epub to make an epub
28 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
29 | echo. text to make text files
30 | echo. man to make manual pages
31 | echo. changes to make an overview over all changed/added/deprecated items
32 | echo. linkcheck to check all external links for integrity
33 | echo. doctest to run all doctests embedded in the documentation if enabled
34 | goto end
35 | )
36 |
37 | if "%1" == "clean" (
38 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
39 | del /q /s %BUILDDIR%\*
40 | goto end
41 | )
42 |
43 | if "%1" == "html" (
44 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
45 | echo.
46 | echo.Build finished. The HTML pages are in %BUILDDIR%/html.
47 | goto end
48 | )
49 |
50 | if "%1" == "dirhtml" (
51 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
52 | echo.
53 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
54 | goto end
55 | )
56 |
57 | if "%1" == "singlehtml" (
58 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
59 | echo.
60 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
61 | goto end
62 | )
63 |
64 | if "%1" == "pickle" (
65 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
66 | echo.
67 | echo.Build finished; now you can process the pickle files.
68 | goto end
69 | )
70 |
71 | if "%1" == "json" (
72 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
73 | echo.
74 | echo.Build finished; now you can process the JSON files.
75 | goto end
76 | )
77 |
78 | if "%1" == "htmlhelp" (
79 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
80 | echo.
81 | echo.Build finished; now you can run HTML Help Workshop with the ^
82 | .hhp project file in %BUILDDIR%/htmlhelp.
83 | goto end
84 | )
85 |
86 | if "%1" == "qthelp" (
87 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
88 | echo.
89 | echo.Build finished; now you can run "qcollectiongenerator" with the ^
90 | .qhcp project file in %BUILDDIR%/qthelp, like this:
91 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\templateclass.qhcp
92 | echo.To view the help file:
93 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\templateclass.ghc
94 | goto end
95 | )
96 |
97 | if "%1" == "devhelp" (
98 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
99 | echo.
100 | echo.Build finished.
101 | goto end
102 | )
103 |
104 | if "%1" == "epub" (
105 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
106 | echo.
107 | echo.Build finished. The epub file is in %BUILDDIR%/epub.
108 | goto end
109 | )
110 |
111 | if "%1" == "latex" (
112 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
113 | echo.
114 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
115 | goto end
116 | )
117 |
118 | if "%1" == "text" (
119 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
120 | echo.
121 | echo.Build finished. The text files are in %BUILDDIR%/text.
122 | goto end
123 | )
124 |
125 | if "%1" == "man" (
126 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
127 | echo.
128 | echo.Build finished. The manual pages are in %BUILDDIR%/man.
129 | goto end
130 | )
131 |
132 | if "%1" == "changes" (
133 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
134 | echo.
135 | echo.The overview file is in %BUILDDIR%/changes.
136 | goto end
137 | )
138 |
139 | if "%1" == "linkcheck" (
140 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
141 | echo.
142 | echo.Link check complete; look for any errors in the above output ^
143 | or in %BUILDDIR%/linkcheck/output.txt.
144 | goto end
145 | )
146 |
147 | if "%1" == "doctest" (
148 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
149 | echo.
150 | echo.Testing of doctests in the sources finished, look at the ^
151 | results in %BUILDDIR%/doctest/output.txt.
152 | goto end
153 | )
154 |
155 | :end
156 |
--------------------------------------------------------------------------------
/help/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | PAPER =
8 | BUILDDIR = build
9 |
10 | # Internal variables.
11 | PAPEROPT_a4 = -D latex_paper_size=a4
12 | PAPEROPT_letter = -D latex_paper_size=letter
13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
14 |
15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
16 |
17 | help:
18 | @echo "Please use \`make ' where is one of"
19 | @echo " html to make standalone HTML files"
20 | @echo " dirhtml to make HTML files named index.html in directories"
21 | @echo " singlehtml to make a single large HTML file"
22 | @echo " pickle to make pickle files"
23 | @echo " json to make JSON files"
24 | @echo " htmlhelp to make HTML files and a HTML help project"
25 | @echo " qthelp to make HTML files and a qthelp project"
26 | @echo " devhelp to make HTML files and a Devhelp project"
27 | @echo " epub to make an epub"
28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
29 | @echo " latexpdf to make LaTeX files and run them through pdflatex"
30 | @echo " text to make text files"
31 | @echo " man to make manual pages"
32 | @echo " changes to make an overview of all changed/added/deprecated items"
33 | @echo " linkcheck to check all external links for integrity"
34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)"
35 |
36 | clean:
37 | -rm -rf $(BUILDDIR)/*
38 |
39 | html:
40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
41 | @echo
42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
43 |
44 | dirhtml:
45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
46 | @echo
47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
48 |
49 | singlehtml:
50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
51 | @echo
52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
53 |
54 | pickle:
55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
56 | @echo
57 | @echo "Build finished; now you can process the pickle files."
58 |
59 | json:
60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
61 | @echo
62 | @echo "Build finished; now you can process the JSON files."
63 |
64 | htmlhelp:
65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
66 | @echo
67 | @echo "Build finished; now you can run HTML Help Workshop with the" \
68 | ".hhp project file in $(BUILDDIR)/htmlhelp."
69 |
70 | qthelp:
71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
72 | @echo
73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \
74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/templateclass.qhcp"
76 | @echo "To view the help file:"
77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/templateclass.qhc"
78 |
79 | devhelp:
80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
81 | @echo
82 | @echo "Build finished."
83 | @echo "To view the help file:"
84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/templateclass"
85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/templateclass"
86 | @echo "# devhelp"
87 |
88 | epub:
89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
90 | @echo
91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
92 |
93 | latex:
94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
95 | @echo
96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \
98 | "(use \`make latexpdf' here to do that automatically)."
99 |
100 | latexpdf:
101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
102 | @echo "Running LaTeX files through pdflatex..."
103 | make -C $(BUILDDIR)/latex all-pdf
104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
105 |
106 | text:
107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
108 | @echo
109 | @echo "Build finished. The text files are in $(BUILDDIR)/text."
110 |
111 | man:
112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
113 | @echo
114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
115 |
116 | changes:
117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
118 | @echo
119 | @echo "The overview file is in $(BUILDDIR)/changes."
120 |
121 | linkcheck:
122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
123 | @echo
124 | @echo "Link check complete; look for any errors in the above output " \
125 | "or in $(BUILDDIR)/linkcheck/output.txt."
126 |
127 | doctest:
128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
129 | @echo "Testing of doctests in the sources finished, look at the " \
130 | "results in $(BUILDDIR)/doctest/output.txt."
131 |
--------------------------------------------------------------------------------
/requests/packages/urllib3/contrib/ntlmpool.py:
--------------------------------------------------------------------------------
1 | # urllib3/contrib/ntlmpool.py
2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | """
8 | NTLM authenticating pool, contributed by erikcederstran
9 |
10 | Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10
11 | """
12 |
13 | try:
14 | from http.client import HTTPSConnection
15 | except ImportError:
16 | from httplib import HTTPSConnection
17 | from logging import getLogger
18 | from ntlm import ntlm
19 |
20 | from urllib3 import HTTPSConnectionPool
21 |
22 |
23 | log = getLogger(__name__)
24 |
25 |
26 | class NTLMConnectionPool(HTTPSConnectionPool):
27 | """
28 | Implements an NTLM authentication version of an urllib3 connection pool
29 | """
30 |
31 | scheme = 'https'
32 |
33 | def __init__(self, user, pw, authurl, *args, **kwargs):
34 | """
35 | authurl is a random URL on the server that is protected by NTLM.
36 | user is the Windows user, probably in the DOMAIN\\username format.
37 | pw is the password for the user.
38 | """
39 | super(NTLMConnectionPool, self).__init__(*args, **kwargs)
40 | self.authurl = authurl
41 | self.rawuser = user
42 | user_parts = user.split('\\', 1)
43 | self.domain = user_parts[0].upper()
44 | self.user = user_parts[1]
45 | self.pw = pw
46 |
47 | def _new_conn(self):
48 | # Performs the NTLM handshake that secures the connection. The socket
49 | # must be kept open while requests are performed.
50 | self.num_connections += 1
51 | log.debug('Starting NTLM HTTPS connection no. %d: https://%s%s' %
52 | (self.num_connections, self.host, self.authurl))
53 |
54 | headers = {}
55 | headers['Connection'] = 'Keep-Alive'
56 | req_header = 'Authorization'
57 | resp_header = 'www-authenticate'
58 |
59 | conn = HTTPSConnection(host=self.host, port=self.port)
60 |
61 | # Send negotiation message
62 | headers[req_header] = (
63 | 'NTLM %s' % ntlm.create_NTLM_NEGOTIATE_MESSAGE(self.rawuser))
64 | log.debug('Request headers: %s' % headers)
65 | conn.request('GET', self.authurl, None, headers)
66 | res = conn.getresponse()
67 | reshdr = dict(res.getheaders())
68 | log.debug('Response status: %s %s' % (res.status, res.reason))
69 | log.debug('Response headers: %s' % reshdr)
70 | log.debug('Response data: %s [...]' % res.read(100))
71 |
72 | # Remove the reference to the socket, so that it can not be closed by
73 | # the response object (we want to keep the socket open)
74 | res.fp = None
75 |
76 | # Server should respond with a challenge message
77 | auth_header_values = reshdr[resp_header].split(', ')
78 | auth_header_value = None
79 | for s in auth_header_values:
80 | if s[:5] == 'NTLM ':
81 | auth_header_value = s[5:]
82 | if auth_header_value is None:
83 | raise Exception('Unexpected %s response header: %s' %
84 | (resp_header, reshdr[resp_header]))
85 |
86 | # Send authentication message
87 | ServerChallenge, NegotiateFlags = \
88 | ntlm.parse_NTLM_CHALLENGE_MESSAGE(auth_header_value)
89 | auth_msg = ntlm.create_NTLM_AUTHENTICATE_MESSAGE(ServerChallenge,
90 | self.user,
91 | self.domain,
92 | self.pw,
93 | NegotiateFlags)
94 | headers[req_header] = 'NTLM %s' % auth_msg
95 | log.debug('Request headers: %s' % headers)
96 | conn.request('GET', self.authurl, None, headers)
97 | res = conn.getresponse()
98 | log.debug('Response status: %s %s' % (res.status, res.reason))
99 | log.debug('Response headers: %s' % dict(res.getheaders()))
100 | log.debug('Response data: %s [...]' % res.read()[:100])
101 | if res.status != 200:
102 | if res.status == 401:
103 | raise Exception('Server rejected request: wrong '
104 | 'username or password')
105 | raise Exception('Wrong server response: %s %s' %
106 | (res.status, res.reason))
107 |
108 | res.fp = None
109 | log.debug('Connection established')
110 | return conn
111 |
112 | def urlopen(self, method, url, body=None, headers=None, retries=3,
113 | redirect=True, assert_same_host=True):
114 | if headers is None:
115 | headers = {}
116 | headers['Connection'] = 'Keep-Alive'
117 | return super(NTLMConnectionPool, self).urlopen(method, url, body,
118 | headers, retries,
119 | redirect,
120 | assert_same_host)
121 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ui_connector.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'ui_connector.ui'
4 | #
5 | # Created: Tue Jun 10 09:38:37 2014
6 | # by: PyQt4 UI code generator 4.10.3
7 | #
8 | # WARNING! All changes made in this file will be lost!
9 |
10 | from PyQt4 import QtCore, QtGui
11 |
12 | try:
13 | _fromUtf8 = QtCore.QString.fromUtf8
14 | except AttributeError:
15 | def _fromUtf8(s):
16 | return s
17 |
18 | try:
19 | _encoding = QtGui.QApplication.UnicodeUTF8
20 |
21 | def _translate(context, text, disambig):
22 | return QtGui.QApplication.translate(context, text, disambig, _encoding)
23 | except AttributeError:
24 | def _translate(context, text, disambig):
25 | return QtGui.QApplication.translate(context, text, disambig)
26 |
27 |
28 | class Ui_Connector(object):
29 |
30 | def setupUi(self, Connector):
31 | Connector.setObjectName(_fromUtf8("Connector"))
32 | Connector.resize(830, 401)
33 | self.verticalLayout_3 = QtGui.QVBoxLayout(Connector)
34 | self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
35 | self.gridLayout_2 = QtGui.QGridLayout()
36 | self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
37 | self.groupBox = QtGui.QGroupBox(Connector)
38 | self.groupBox.setObjectName(_fromUtf8("groupBox"))
39 | self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox)
40 | self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
41 | self.verticalLayout = QtGui.QVBoxLayout()
42 | self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
43 | self.connections = QtGui.QComboBox(self.groupBox)
44 | self.connections.setObjectName(_fromUtf8("connections"))
45 | self.verticalLayout.addWidget(self.connections)
46 | self.horizontalLayout_3 = QtGui.QHBoxLayout()
47 | self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
48 | self.connectButton = QtGui.QPushButton(self.groupBox)
49 | self.connectButton.setObjectName(_fromUtf8("connectButton"))
50 | self.horizontalLayout_3.addWidget(self.connectButton)
51 | self.newButton = QtGui.QPushButton(self.groupBox)
52 | self.newButton.setObjectName(_fromUtf8("newButton"))
53 | self.horizontalLayout_3.addWidget(self.newButton)
54 | self.editButton = QtGui.QPushButton(self.groupBox)
55 | self.editButton.setObjectName(_fromUtf8("editButton"))
56 | self.horizontalLayout_3.addWidget(self.editButton)
57 | self.deleteButton = QtGui.QPushButton(self.groupBox)
58 | self.deleteButton.setObjectName(_fromUtf8("deleteButton"))
59 | self.horizontalLayout_3.addWidget(self.deleteButton)
60 | spacerItem = QtGui.QSpacerItem(
61 | 40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
62 | self.horizontalLayout_3.addItem(spacerItem)
63 | self.verticalLayout.addLayout(self.horizontalLayout_3)
64 | self.verticalLayout_2.addLayout(self.verticalLayout)
65 | self.gridLayout_2.addWidget(self.groupBox, 0, 0, 1, 1)
66 | self.verticalLayout_3.addLayout(self.gridLayout_2)
67 | self.horizontalLayout_2 = QtGui.QHBoxLayout()
68 | self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
69 | self.treeView = QtGui.QTreeWidget(Connector)
70 | self.treeView.setObjectName(_fromUtf8("treeView"))
71 | self.horizontalLayout_2.addWidget(self.treeView)
72 | self.verticalLayout_3.addLayout(self.horizontalLayout_2)
73 | self.horizontalLayout = QtGui.QHBoxLayout()
74 | self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
75 | spacerItem1 = QtGui.QSpacerItem(
76 | 40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
77 | self.horizontalLayout.addItem(spacerItem1)
78 | self.importLayers = QtGui.QPushButton(Connector)
79 | self.importLayers.setObjectName(_fromUtf8("importLayers"))
80 | self.horizontalLayout.addWidget(self.importLayers)
81 | self.cancelButton = QtGui.QPushButton(Connector)
82 | self.cancelButton.setObjectName(_fromUtf8("cancelButton"))
83 | self.horizontalLayout.addWidget(self.cancelButton)
84 | self.verticalLayout_3.addLayout(self.horizontalLayout)
85 |
86 | self.retranslateUi(Connector)
87 | QtCore.QMetaObject.connectSlotsByName(Connector)
88 | Connector.setTabOrder(self.importLayers, self.cancelButton)
89 |
90 | def retranslateUi(self, Connector):
91 | Connector.setWindowTitle(_translate("Connector", "Connector", None))
92 | self.groupBox.setTitle(_translate("Connector", "Connections", None))
93 | self.connectButton.setText(_translate("Connector", "Connect", None))
94 | self.newButton.setText(_translate("Connector", "New", None))
95 | self.editButton.setText(_translate("Connector", "Edit", None))
96 | self.deleteButton.setText(_translate("Connector", "Delete", None))
97 | self.treeView.headerItem().setText(
98 | 0, _translate("Connector", "Services", None))
99 | self.importLayers.setText(
100 | _translate("Connector", "Import Layer", None))
101 | self.cancelButton.setText(_translate("Connector", "Cancel", None))
102 |
--------------------------------------------------------------------------------
/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] / total)
133 | - (self._mFreqCounter[1] * 20.0 / 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.5
139 | return confidence
140 |
--------------------------------------------------------------------------------
/requests/packages/urllib3/request.py:
--------------------------------------------------------------------------------
1 | # urllib3/request.py
2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | try:
8 | from urllib.parse import urlencode
9 | except ImportError:
10 | from urllib import urlencode
11 |
12 | from .filepost import encode_multipart_formdata
13 |
14 |
15 | __all__ = ['RequestMethods']
16 |
17 |
18 | class RequestMethods(object):
19 | """
20 | Convenience mixin for classes who implement a :meth:`urlopen` method, such
21 | as :class:`~urllib3.connectionpool.HTTPConnectionPool` and
22 | :class:`~urllib3.poolmanager.PoolManager`.
23 |
24 | Provides behavior for making common types of HTTP request methods and
25 | decides which type of request field encoding to use.
26 |
27 | Specifically,
28 |
29 | :meth:`.request_encode_url` is for sending requests whose fields are encoded
30 | in the URL (such as GET, HEAD, DELETE).
31 |
32 | :meth:`.request_encode_body` is for sending requests whose fields are
33 | encoded in the *body* of the request using multipart or www-form-urlencoded
34 | (such as for POST, PUT, PATCH).
35 |
36 | :meth:`.request` is for making any kind of request, it will look up the
37 | appropriate encoding format and use one of the above two methods to make
38 | the request.
39 |
40 | Initializer parameters:
41 |
42 | :param headers:
43 | Headers to include with all requests, unless other headers are given
44 | explicitly.
45 | """
46 |
47 | _encode_url_methods = set(['DELETE', 'GET', 'HEAD', 'OPTIONS'])
48 |
49 | def __init__(self, headers=None):
50 | self.headers = headers or {}
51 |
52 | def urlopen(self, method, url, body=None, headers=None,
53 | encode_multipart=True, multipart_boundary=None,
54 | **kw): # Abstract
55 | raise NotImplemented("Classes extending RequestMethods must implement "
56 | "their own ``urlopen`` method.")
57 |
58 | def request(self, method, url, fields=None, headers=None, **urlopen_kw):
59 | """
60 | Make a request using :meth:`urlopen` with the appropriate encoding of
61 | ``fields`` based on the ``method`` used.
62 |
63 | This is a convenience method that requires the least amount of manual
64 | effort. It can be used in most situations, while still having the option
65 | to drop down to more specific methods when necessary, such as
66 | :meth:`request_encode_url`, :meth:`request_encode_body`,
67 | or even the lowest level :meth:`urlopen`.
68 | """
69 | method = method.upper()
70 |
71 | if method in self._encode_url_methods:
72 | return self.request_encode_url(method, url, fields=fields,
73 | headers=headers,
74 | **urlopen_kw)
75 | else:
76 | return self.request_encode_body(method, url, fields=fields,
77 | headers=headers,
78 | **urlopen_kw)
79 |
80 | def request_encode_url(self, method, url, fields=None, **urlopen_kw):
81 | """
82 | Make a request using :meth:`urlopen` with the ``fields`` encoded in
83 | the url. This is useful for request methods like GET, HEAD, DELETE, etc.
84 | """
85 | if fields:
86 | url += '?' + urlencode(fields)
87 | return self.urlopen(method, url, **urlopen_kw)
88 |
89 | def request_encode_body(self, method, url, fields=None, headers=None,
90 | encode_multipart=True, multipart_boundary=None,
91 | **urlopen_kw):
92 | """
93 | Make a request using :meth:`urlopen` with the ``fields`` encoded in
94 | the body. This is useful for request methods like POST, PUT, PATCH, etc.
95 |
96 | When ``encode_multipart=True`` (default), then
97 | :meth:`urllib3.filepost.encode_multipart_formdata` is used to encode the
98 | payload with the appropriate content type. Otherwise
99 | :meth:`urllib.urlencode` is used with the
100 | 'application/x-www-form-urlencoded' content type.
101 |
102 | Multipart encoding must be used when posting files, and it's reasonably
103 | safe to use it in other times too. However, it may break request signing,
104 | such as with OAuth.
105 |
106 | Supports an optional ``fields`` parameter of key/value strings AND
107 | key/filetuple. A filetuple is a (filename, data, MIME type) tuple where
108 | the MIME type is optional. For example: ::
109 |
110 | fields = {
111 | 'foo': 'bar',
112 | 'fakefile': ('foofile.txt', 'contents of foofile'),
113 | 'realfile': ('barfile.txt', open('realfile').read()),
114 | 'typedfile': ('bazfile.bin', open('bazfile').read(),
115 | 'image/jpeg'),
116 | 'nonamefile': 'contents of nonamefile field',
117 | }
118 |
119 | When uploading a file, providing a filename (the first parameter of the
120 | tuple) is optional but recommended to best mimick behavior of browsers.
121 |
122 | Note that if ``headers`` are supplied, the 'Content-Type' header will be
123 | overwritten because it depends on the dynamic random boundary string
124 | which is used to compose the body of the request. The random boundary
125 | string can be explicitly set with the ``multipart_boundary`` parameter.
126 | """
127 | if encode_multipart:
128 | body, content_type = encode_multipart_formdata(fields or {},
129 | boundary=multipart_boundary)
130 | else:
131 | body, content_type = (urlencode(fields or {}),
132 | 'application/x-www-form-urlencoded')
133 |
134 | if headers is None:
135 | headers = self.headers
136 |
137 | headers_ = {'Content-Type': content_type}
138 | headers_.update(headers)
139 |
140 | return self.urlopen(method, url, body=body, headers=headers_,
141 | **urlopen_kw)
142 |
--------------------------------------------------------------------------------
/requests/packages/urllib3/connection.py:
--------------------------------------------------------------------------------
1 | # urllib3/connection.py
2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | import socket
8 | from socket import timeout as SocketTimeout
9 |
10 | try: # Python 3
11 | from http.client import HTTPConnection as _HTTPConnection, HTTPException
12 | except ImportError:
13 | from httplib import HTTPConnection as _HTTPConnection, HTTPException
14 |
15 | class DummyConnection(object):
16 | "Used to detect a failed ConnectionCls import."
17 | pass
18 |
19 | try: # Compiled with SSL?
20 | ssl = None
21 | HTTPSConnection = DummyConnection
22 |
23 | class BaseSSLError(BaseException):
24 | pass
25 |
26 | try: # Python 3
27 | from http.client import HTTPSConnection as _HTTPSConnection
28 | except ImportError:
29 | from httplib import HTTPSConnection as _HTTPSConnection
30 |
31 | import ssl
32 | BaseSSLError = ssl.SSLError
33 |
34 | except (ImportError, AttributeError): # Platform-specific: No SSL.
35 | pass
36 |
37 | from .exceptions import (
38 | ConnectTimeoutError,
39 | )
40 | from .packages.ssl_match_hostname import match_hostname
41 | from .util import (
42 | assert_fingerprint,
43 | resolve_cert_reqs,
44 | resolve_ssl_version,
45 | ssl_wrap_socket,
46 | )
47 |
48 |
49 | port_by_scheme = {
50 | 'http': 80,
51 | 'https': 443,
52 | }
53 |
54 |
55 | class HTTPConnection(_HTTPConnection, object):
56 | default_port = port_by_scheme['http']
57 |
58 | # By default, disable Nagle's Algorithm.
59 | tcp_nodelay = 1
60 |
61 | def _new_conn(self):
62 | """ Establish a socket connection and set nodelay settings on it
63 |
64 | :return: a new socket connection
65 | """
66 | try:
67 | conn = socket.create_connection(
68 | (self.host, self.port),
69 | self.timeout,
70 | self.source_address,
71 | )
72 | except AttributeError: # Python 2.6
73 | conn = socket.create_connection(
74 | (self.host, self.port),
75 | self.timeout,
76 | )
77 | conn.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY,
78 | self.tcp_nodelay)
79 | return conn
80 |
81 | def _prepare_conn(self, conn):
82 | self.sock = conn
83 | if self._tunnel_host:
84 | # TODO: Fix tunnel so it doesn't depend on self.sock state.
85 | self._tunnel()
86 |
87 | def connect(self):
88 | conn = self._new_conn()
89 | self._prepare_conn(conn)
90 |
91 |
92 | class HTTPSConnection(HTTPConnection):
93 | default_port = port_by_scheme['https']
94 |
95 | def __init__(self, host, port=None, key_file=None, cert_file=None,
96 | strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
97 | source_address=None):
98 | try:
99 | HTTPConnection.__init__(self, host, port, strict, timeout, source_address)
100 | except TypeError: # Python 2.6
101 | HTTPConnection.__init__(self, host, port, strict, timeout)
102 | self.key_file = key_file
103 | self.cert_file = cert_file
104 |
105 | def connect(self):
106 | conn = self._new_conn()
107 | self._prepare_conn(conn)
108 | self.sock = ssl.wrap_socket(conn, self.key_file, self.cert_file)
109 |
110 |
111 | class VerifiedHTTPSConnection(HTTPSConnection):
112 | """
113 | Based on httplib.HTTPSConnection but wraps the socket with
114 | SSL certification.
115 | """
116 | cert_reqs = None
117 | ca_certs = None
118 | ssl_version = None
119 |
120 | def set_cert(self, key_file=None, cert_file=None,
121 | cert_reqs=None, ca_certs=None,
122 | assert_hostname=None, assert_fingerprint=None):
123 |
124 | self.key_file = key_file
125 | self.cert_file = cert_file
126 | self.cert_reqs = cert_reqs
127 | self.ca_certs = ca_certs
128 | self.assert_hostname = assert_hostname
129 | self.assert_fingerprint = assert_fingerprint
130 |
131 | def connect(self):
132 | # Add certificate verification
133 | try:
134 | sock = socket.create_connection(
135 | address=(self.host, self.port),
136 | timeout=self.timeout,
137 | )
138 | except SocketTimeout:
139 | raise ConnectTimeoutError(
140 | self, "Connection to %s timed out. (connect timeout=%s)" %
141 | (self.host, self.timeout))
142 |
143 | sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY,
144 | self.tcp_nodelay)
145 |
146 | resolved_cert_reqs = resolve_cert_reqs(self.cert_reqs)
147 | resolved_ssl_version = resolve_ssl_version(self.ssl_version)
148 |
149 | # the _tunnel_host attribute was added in python 2.6.3 (via
150 | # http://hg.python.org/cpython/rev/0f57b30a152f) so pythons 2.6(0-2) do
151 | # not have them.
152 | if getattr(self, '_tunnel_host', None):
153 | self.sock = sock
154 | # Calls self._set_hostport(), so self.host is
155 | # self._tunnel_host below.
156 | self._tunnel()
157 |
158 | # Wrap socket using verification with the root certs in
159 | # trusted_root_certs
160 | self.sock = ssl_wrap_socket(sock, self.key_file, self.cert_file,
161 | cert_reqs=resolved_cert_reqs,
162 | ca_certs=self.ca_certs,
163 | server_hostname=self.host,
164 | ssl_version=resolved_ssl_version)
165 |
166 | if resolved_cert_reqs != ssl.CERT_NONE:
167 | if self.assert_fingerprint:
168 | assert_fingerprint(self.sock.getpeercert(binary_form=True),
169 | self.assert_fingerprint)
170 | elif self.assert_hostname is not False:
171 | match_hostname(self.sock.getpeercert(),
172 | self.assert_hostname or self.host)
173 |
174 |
175 | if ssl:
176 | # Make a copy for testing.
177 | UnverifiedHTTPSConnection = HTTPSConnection
178 | HTTPSConnection = VerifiedHTTPSConnection
179 |
--------------------------------------------------------------------------------
/requests/packages/urllib3/fields.py:
--------------------------------------------------------------------------------
1 | # urllib3/fields.py
2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | import email.utils
8 | import mimetypes
9 |
10 | from .packages import six
11 |
12 |
13 | def guess_content_type(filename, default='application/octet-stream'):
14 | """
15 | Guess the "Content-Type" of a file.
16 |
17 | :param filename:
18 | The filename to guess the "Content-Type" of using :mod:`mimetimes`.
19 | :param default:
20 | If no "Content-Type" can be guessed, default to `default`.
21 | """
22 | if filename:
23 | return mimetypes.guess_type(filename)[0] or default
24 | return default
25 |
26 |
27 | def format_header_param(name, value):
28 | """
29 | Helper function to format and quote a single header parameter.
30 |
31 | Particularly useful for header parameters which might contain
32 | non-ASCII values, like file names. This follows RFC 2231, as
33 | suggested by RFC 2388 Section 4.4.
34 |
35 | :param name:
36 | The name of the parameter, a string expected to be ASCII only.
37 | :param value:
38 | The value of the parameter, provided as a unicode string.
39 | """
40 | if not any(ch in value for ch in '"\\\r\n'):
41 | result = '%s="%s"' % (name, value)
42 | try:
43 | result.encode('ascii')
44 | except UnicodeEncodeError:
45 | pass
46 | else:
47 | return result
48 | if not six.PY3: # Python 2:
49 | value = value.encode('utf-8')
50 | value = email.utils.encode_rfc2231(value, 'utf-8')
51 | value = '%s*=%s' % (name, value)
52 | return value
53 |
54 |
55 | class RequestField(object):
56 | """
57 | A data container for request body parameters.
58 |
59 | :param name:
60 | The name of this request field.
61 | :param data:
62 | The data/value body.
63 | :param filename:
64 | An optional filename of the request field.
65 | :param headers:
66 | An optional dict-like object of headers to initially use for the field.
67 | """
68 | def __init__(self, name, data, filename=None, headers=None):
69 | self._name = name
70 | self._filename = filename
71 | self.data = data
72 | self.headers = {}
73 | if headers:
74 | self.headers = dict(headers)
75 |
76 | @classmethod
77 | def from_tuples(cls, fieldname, value):
78 | """
79 | A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.
80 |
81 | Supports constructing :class:`~urllib3.fields.RequestField` from parameter
82 | of key/value strings AND key/filetuple. A filetuple is a (filename, data, MIME type)
83 | tuple where the MIME type is optional. For example: ::
84 |
85 | 'foo': 'bar',
86 | 'fakefile': ('foofile.txt', 'contents of foofile'),
87 | 'realfile': ('barfile.txt', open('realfile').read()),
88 | 'typedfile': ('bazfile.bin', open('bazfile').read(), 'image/jpeg'),
89 | 'nonamefile': 'contents of nonamefile field',
90 |
91 | Field names and filenames must be unicode.
92 | """
93 | if isinstance(value, tuple):
94 | if len(value) == 3:
95 | filename, data, content_type = value
96 | else:
97 | filename, data = value
98 | content_type = guess_content_type(filename)
99 | else:
100 | filename = None
101 | content_type = None
102 | data = value
103 |
104 | request_param = cls(fieldname, data, filename=filename)
105 | request_param.make_multipart(content_type=content_type)
106 |
107 | return request_param
108 |
109 | def _render_part(self, name, value):
110 | """
111 | Overridable helper function to format a single header parameter.
112 |
113 | :param name:
114 | The name of the parameter, a string expected to be ASCII only.
115 | :param value:
116 | The value of the parameter, provided as a unicode string.
117 | """
118 | return format_header_param(name, value)
119 |
120 | def _render_parts(self, header_parts):
121 | """
122 | Helper function to format and quote a single header.
123 |
124 | Useful for single headers that are composed of multiple items. E.g.,
125 | 'Content-Disposition' fields.
126 |
127 | :param header_parts:
128 | A sequence of (k, v) typles or a :class:`dict` of (k, v) to format as
129 | `k1="v1"; k2="v2"; ...`.
130 | """
131 | parts = []
132 | iterable = header_parts
133 | if isinstance(header_parts, dict):
134 | iterable = header_parts.items()
135 |
136 | for name, value in iterable:
137 | if value:
138 | parts.append(self._render_part(name, value))
139 |
140 | return '; '.join(parts)
141 |
142 | def render_headers(self):
143 | """
144 | Renders the headers for this request field.
145 | """
146 | lines = []
147 |
148 | sort_keys = ['Content-Disposition', 'Content-Type', 'Content-Location']
149 | for sort_key in sort_keys:
150 | if self.headers.get(sort_key, False):
151 | lines.append('%s: %s' % (sort_key, self.headers[sort_key]))
152 |
153 | for header_name, header_value in self.headers.items():
154 | if header_name not in sort_keys:
155 | if header_value:
156 | lines.append('%s: %s' % (header_name, header_value))
157 |
158 | lines.append('\r\n')
159 | return '\r\n'.join(lines)
160 |
161 | def make_multipart(self, content_disposition=None, content_type=None, content_location=None):
162 | """
163 | Makes this request field into a multipart request field.
164 |
165 | This method overrides "Content-Disposition", "Content-Type" and
166 | "Content-Location" headers to the request parameter.
167 |
168 | :param content_type:
169 | The 'Content-Type' of the request body.
170 | :param content_location:
171 | The 'Content-Location' of the request body.
172 |
173 | """
174 | self.headers['Content-Disposition'] = content_disposition or 'form-data'
175 | self.headers['Content-Disposition'] += '; '.join(['', self._render_parts((('name', self._name), ('filename', self._filename)))])
176 | self.headers['Content-Type'] = content_type
177 | self.headers['Content-Location'] = content_location
178 |
--------------------------------------------------------------------------------
/ntlm/HTTPNtlmAuthHandler.py:
--------------------------------------------------------------------------------
1 | # This library is free software: you can redistribute it and/or
2 | # modify it under the terms of the GNU Lesser General Public
3 | # License as published by the Free Software Foundation, either
4 | # version 3 of the License, or (at your option) any later version.
5 |
6 | # This library is distributed in the hope that it will be useful,
7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 | # Lesser General Public License for more details.
10 | #
11 | # You should have received a copy of the GNU Lesser General Public
12 | # License along with this library. If not, see
13 | # or
14 | # .
15 |
16 | import urllib2
17 | import httplib
18 | import socket
19 | from urllib import addinfourl
20 | import ntlm
21 |
22 |
23 | class AbstractNtlmAuthHandler:
24 |
25 | def __init__(self, password_mgr=None, debuglevel=0):
26 | if password_mgr is None:
27 | password_mgr = HTTPPasswordMgr()
28 | self.passwd = password_mgr
29 | self.add_password = self.passwd.add_password
30 | self._debuglevel = debuglevel
31 |
32 | def set_http_debuglevel(self, level):
33 | self._debuglevel = level
34 |
35 | def http_error_authentication_required(self, auth_header_field, req, fp, headers):
36 | auth_header_value = headers.get(auth_header_field, None)
37 | if auth_header_field:
38 | if auth_header_value is not None and 'ntlm' in auth_header_value.lower():
39 | fp.close()
40 | return self.retry_using_http_NTLM_auth(req, auth_header_field, None, headers)
41 |
42 | def retry_using_http_NTLM_auth(self, req, auth_header_field, realm, headers):
43 | user, pw = self.passwd.find_user_password(realm, req.get_full_url())
44 | if pw is not None:
45 | # ntlm secures a socket, so we must use the same socket for the
46 | # complete handshake
47 | headers = dict(req.headers)
48 | headers.update(req.unredirected_hdrs)
49 | auth = 'NTLM %s' % ntlm.create_NTLM_NEGOTIATE_MESSAGE(user)
50 | if req.headers.get(self.auth_header, None) == auth:
51 | return None
52 | headers[self.auth_header] = auth
53 |
54 | host = req.get_host()
55 | if not host:
56 | raise urllib2.URLError('no host given')
57 | h = None
58 | if req.get_full_url().startswith('https://'):
59 | h = httplib.HTTPSConnection(host) # will parse host:port
60 | else:
61 | h = httplib.HTTPConnection(host) # will parse host:port
62 | h.set_debuglevel(self._debuglevel)
63 | # we must keep the connection because NTLM authenticates the
64 | # connection, not single requests
65 | headers["Connection"] = "Keep-Alive"
66 | headers = dict((name.title(), val)
67 | for name, val in headers.items())
68 | h.request(req.get_method(), req.get_selector(), req.data, headers)
69 | r = h.getresponse()
70 | r.begin()
71 | r._safe_read(int(r.getheader('content-length')))
72 | if r.getheader('set-cookie'):
73 | # this is important for some web applications that store
74 | # authentication-related info in cookies (it took a long time
75 | # to figure out)
76 | headers['Cookie'] = r.getheader('set-cookie')
77 | # remove the reference to the socket, so that it can not be closed
78 | # by the response object (we want to keep the socket open)
79 | r.fp = None
80 | auth_header_value = r.getheader(auth_header_field, None)
81 | (ServerChallenge, NegotiateFlags) = ntlm.parse_NTLM_CHALLENGE_MESSAGE(
82 | auth_header_value[5:])
83 | user_parts = user.split('\\', 1)
84 | DomainName = user_parts[0].upper()
85 | UserName = user_parts[1]
86 | auth = 'NTLM %s' % ntlm.create_NTLM_AUTHENTICATE_MESSAGE(
87 | ServerChallenge, UserName, DomainName, pw, NegotiateFlags)
88 | headers[self.auth_header] = auth
89 | headers["Connection"] = "Close"
90 | headers = dict((name.title(), val)
91 | for name, val in headers.items())
92 | try:
93 | h.request(
94 | req.get_method(), req.get_selector(), req.data, headers)
95 | # none of the configured handlers are triggered, for example
96 | # redirect-responses are not handled!
97 | response = h.getresponse()
98 |
99 | def notimplemented():
100 | raise NotImplementedError
101 | response.readline = notimplemented
102 | infourl = addinfourl(
103 | response, response.msg, req.get_full_url())
104 | infourl.code = response.status
105 | infourl.msg = response.reason
106 | return infourl
107 | except socket.error, err:
108 | raise urllib2.URLError(err)
109 | else:
110 | return None
111 |
112 |
113 | class HTTPNtlmAuthHandler(AbstractNtlmAuthHandler, urllib2.BaseHandler):
114 |
115 | auth_header = 'Authorization'
116 |
117 | def http_error_401(self, req, fp, code, msg, headers):
118 | return self.http_error_authentication_required('www-authenticate', req, fp, headers)
119 |
120 |
121 | class ProxyNtlmAuthHandler(AbstractNtlmAuthHandler, urllib2.BaseHandler):
122 |
123 | """
124 | CAUTION: this class has NOT been tested at all!!!
125 | use at your own risk
126 | """
127 | auth_header = 'Proxy-authorization'
128 |
129 | def http_error_407(self, req, fp, code, msg, headers):
130 | return self.http_error_authentication_required('proxy-authenticate', req, fp, headers)
131 |
132 |
133 | if __name__ == "__main__":
134 | url = "http://ntlmprotectedserver/securedfile.html"
135 | user = u'DOMAIN\\User'
136 | password = 'Password'
137 |
138 | passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
139 | passman.add_password(None, url, user, password)
140 | auth_basic = urllib2.HTTPBasicAuthHandler(passman)
141 | auth_digest = urllib2.HTTPDigestAuthHandler(passman)
142 | auth_NTLM = HTTPNtlmAuthHandler(passman)
143 |
144 | # disable proxies (just for testing)
145 | proxy_handler = urllib2.ProxyHandler({})
146 |
147 | # , auth_digest, auth_basic)
148 | opener = urllib2.build_opener(proxy_handler, auth_NTLM)
149 |
150 | urllib2.install_opener(opener)
151 |
152 | response = urllib2.urlopen(url)
153 | print(response.read())
154 |
--------------------------------------------------------------------------------
/requests/auth.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | requests.auth
5 | ~~~~~~~~~~~~~
6 |
7 | This module contains the authentication handlers for Requests.
8 | """
9 |
10 | import os
11 | import re
12 | import time
13 | import hashlib
14 | import logging
15 |
16 | from base64 import b64encode
17 |
18 | from .compat import urlparse, str
19 | from .cookies import extract_cookies_to_jar
20 | from .utils import parse_dict_header
21 |
22 | log = logging.getLogger(__name__)
23 |
24 | CONTENT_TYPE_FORM_URLENCODED = 'application/x-www-form-urlencoded'
25 | CONTENT_TYPE_MULTI_PART = 'multipart/form-data'
26 |
27 |
28 | def _basic_auth_str(username, password):
29 | """Returns a Basic Auth string."""
30 |
31 | return 'Basic ' + b64encode(('%s:%s' % (username, password)).encode('latin1')).strip().decode('latin1')
32 |
33 |
34 | class AuthBase(object):
35 |
36 | """Base class that all auth implementations derive from"""
37 |
38 | def __call__(self, r):
39 | raise NotImplementedError('Auth hooks must be callable.')
40 |
41 |
42 | class HTTPBasicAuth(AuthBase):
43 |
44 | """Attaches HTTP Basic Authentication to the given Request object."""
45 |
46 | def __init__(self, username, password):
47 | self.username = username
48 | self.password = password
49 |
50 | def __call__(self, r):
51 | r.headers['Authorization'] = _basic_auth_str(
52 | self.username, self.password)
53 | return r
54 |
55 |
56 | class HTTPProxyAuth(HTTPBasicAuth):
57 |
58 | """Attaches HTTP Proxy Authentication to a given Request object."""
59 |
60 | def __call__(self, r):
61 | r.headers[
62 | 'Proxy-Authorization'] = _basic_auth_str(self.username, self.password)
63 | return r
64 |
65 |
66 | class HTTPDigestAuth(AuthBase):
67 |
68 | """Attaches HTTP Digest Authentication to the given Request object."""
69 |
70 | def __init__(self, username, password):
71 | self.username = username
72 | self.password = password
73 | self.last_nonce = ''
74 | self.nonce_count = 0
75 | self.chal = {}
76 | self.pos = None
77 |
78 | def build_digest_header(self, method, url):
79 |
80 | realm = self.chal['realm']
81 | nonce = self.chal['nonce']
82 | qop = self.chal.get('qop')
83 | algorithm = self.chal.get('algorithm')
84 | opaque = self.chal.get('opaque')
85 |
86 | if algorithm is None:
87 | _algorithm = 'MD5'
88 | else:
89 | _algorithm = algorithm.upper()
90 | # lambdas assume digest modules are imported at the top level
91 | if _algorithm == 'MD5' or _algorithm == 'MD5-SESS':
92 | def md5_utf8(x):
93 | if isinstance(x, str):
94 | x = x.encode('utf-8')
95 | return hashlib.md5(x).hexdigest()
96 | hash_utf8 = md5_utf8
97 | elif _algorithm == 'SHA':
98 | def sha_utf8(x):
99 | if isinstance(x, str):
100 | x = x.encode('utf-8')
101 | return hashlib.sha1(x).hexdigest()
102 | hash_utf8 = sha_utf8
103 |
104 | KD = lambda s, d: hash_utf8("%s:%s" % (s, d))
105 |
106 | if hash_utf8 is None:
107 | return None
108 |
109 | # XXX not implemented yet
110 | entdig = None
111 | p_parsed = urlparse(url)
112 | path = p_parsed.path
113 | if p_parsed.query:
114 | path += '?' + p_parsed.query
115 |
116 | A1 = '%s:%s:%s' % (self.username, realm, self.password)
117 | A2 = '%s:%s' % (method, path)
118 |
119 | HA1 = hash_utf8(A1)
120 | HA2 = hash_utf8(A2)
121 |
122 | if nonce == self.last_nonce:
123 | self.nonce_count += 1
124 | else:
125 | self.nonce_count = 1
126 | ncvalue = '%08x' % self.nonce_count
127 | s = str(self.nonce_count).encode('utf-8')
128 | s += nonce.encode('utf-8')
129 | s += time.ctime().encode('utf-8')
130 | s += os.urandom(8)
131 |
132 | cnonce = (hashlib.sha1(s).hexdigest()[:16])
133 | noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, HA2)
134 | if _algorithm == 'MD5-SESS':
135 | HA1 = hash_utf8('%s:%s:%s' % (HA1, nonce, cnonce))
136 |
137 | if qop is None:
138 | respdig = KD(HA1, "%s:%s" % (nonce, HA2))
139 | elif qop == 'auth' or 'auth' in qop.split(','):
140 | respdig = KD(HA1, noncebit)
141 | else:
142 | # XXX handle auth-int.
143 | return None
144 |
145 | self.last_nonce = nonce
146 |
147 | # XXX should the partial digests be encoded too?
148 | base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \
149 | 'response="%s"' % (self.username, realm, nonce, path, respdig)
150 | if opaque:
151 | base += ', opaque="%s"' % opaque
152 | if algorithm:
153 | base += ', algorithm="%s"' % algorithm
154 | if entdig:
155 | base += ', digest="%s"' % entdig
156 | if qop:
157 | base += ', qop="auth", nc=%s, cnonce="%s"' % (ncvalue, cnonce)
158 |
159 | return 'Digest %s' % (base)
160 |
161 | def handle_401(self, r, **kwargs):
162 | """Takes the given response and tries digest-auth, if needed."""
163 |
164 | if self.pos is not None:
165 | # Rewind the file position indicator of the body to where
166 | # it was to resend the request.
167 | r.request.body.seek(self.pos)
168 | num_401_calls = getattr(self, 'num_401_calls', 1)
169 | s_auth = r.headers.get('www-authenticate', '')
170 |
171 | if 'digest' in s_auth.lower() and num_401_calls < 2:
172 |
173 | setattr(self, 'num_401_calls', num_401_calls + 1)
174 | pat = re.compile(r'digest ', flags=re.IGNORECASE)
175 | self.chal = parse_dict_header(pat.sub('', s_auth, count=1))
176 |
177 | # Consume content and release the original connection
178 | # to allow our new request to reuse the same one.
179 | r.content
180 | r.raw.release_conn()
181 | prep = r.request.copy()
182 | extract_cookies_to_jar(prep._cookies, r.request, r.raw)
183 | prep.prepare_cookies(prep._cookies)
184 |
185 | prep.headers['Authorization'] = self.build_digest_header(
186 | prep.method, prep.url)
187 | _r = r.connection.send(prep, **kwargs)
188 | _r.history.append(r)
189 | _r.request = prep
190 |
191 | return _r
192 |
193 | setattr(self, 'num_401_calls', 1)
194 | return r
195 |
196 | def __call__(self, r):
197 | # If we have a saved nonce, skip the 401
198 | if self.last_nonce:
199 | r.headers['Authorization'] = self.build_digest_header(
200 | r.method, r.url)
201 | try:
202 | self.pos = r.body.tell()
203 | except AttributeError:
204 | pass
205 | r.register_hook('response', self.handle_401)
206 | return r
207 |
--------------------------------------------------------------------------------
/resources_rc.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Resource object code
4 | #
5 | # Created: Fr 6. Jun 15:05:49 2014
6 | # by: The Resource Compiler for PyQt (Qt v4.8.5)
7 | #
8 | # WARNING! All changes made in this file will be lost!
9 |
10 | from PyQt4 import QtCore
11 |
12 | qt_resource_data = "\
13 | \x00\x00\x05\x62\
14 | \x89\
15 | \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
16 | \x00\x00\x18\x00\x00\x00\x18\x08\x06\x00\x00\x00\xe0\x77\x3d\xf8\
17 | \x00\x00\x00\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\
18 | \xa7\x93\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\
19 | \x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\
20 | \xde\x06\x06\x0c\x0b\x17\x27\xf6\xd8\xeb\x00\x00\x04\xef\x49\x44\
21 | \x41\x54\x48\xc7\x75\x95\xcb\x8f\x1c\x57\x15\xc6\x7f\xe7\xdc\x5b\
22 | \x55\xfd\xf0\x4c\x0f\xf3\xf0\x2b\xf1\x38\x89\x83\x8c\x03\x01\x94\
23 | \x48\x83\x17\xa0\xb0\x60\x89\xc4\x82\x15\xe2\x0f\x88\xc4\xc2\x92\
24 | \x17\x6c\xd8\xb2\xc8\x0a\x59\x32\x48\xb0\x86\x05\x88\x0d\x48\x61\
25 | \x07\x0b\x48\x40\x16\x26\x04\xdb\x91\x49\x9c\xc4\xc8\x33\xc4\x93\
26 | \x79\x78\x3c\x0f\xf7\xa3\xaa\xab\xee\x3d\x2c\xaa\xba\x7b\x0c\xe2\
27 | \x48\xa5\x5b\xdd\x55\xf5\x9d\x73\xee\xf7\x7d\xe7\x0a\x4d\xac\x5d\
28 | \xbf\x26\x9f\x69\x25\xd5\x93\xb1\x69\x15\xeb\xff\x22\x8a\x12\x10\
29 | \x0c\x30\x54\x85\x18\x0d\x10\x22\x60\x18\x98\x21\x0d\x86\x89\xc3\
30 | \x89\x37\xb3\x22\xbb\x79\xe5\x6a\x09\xd4\xcf\xd6\xae\x5f\x4b\x5b\
31 | \x3e\x29\x86\x55\x89\x9a\x61\x13\x48\x03\x13\xd0\x06\x20\x98\xa3\
32 | \xfe\xc8\x9a\x94\x86\x62\xa8\x80\x62\xc4\xc9\x3b\x9a\x92\x90\xeb\
33 | \xcd\x2b\x57\x4d\xd6\xae\x5f\x4b\x33\xa7\xb9\x58\x2e\x17\x7b\xdb\
34 | \x2c\xb5\x86\xbc\xb7\x7f\x86\x9d\xd1\x09\x8a\xe0\x39\x2a\x13\x42\
35 | \x53\x49\x1e\x1c\x82\x20\x62\x38\x55\xa2\x19\xa9\x06\xce\x77\x0f\
36 | \x79\x75\x79\x93\xf5\xfe\x02\x9b\x83\x1e\xa5\x39\x82\xa4\xa4\x14\
37 | \xea\x7b\xa9\x14\xc3\xb2\xe0\xeb\x67\xee\xf3\x9d\x17\x6f\x93\xba\
38 | \x8a\xdf\x6d\x7c\x8e\x9f\x7f\xf8\x0a\x3b\x45\xc6\xa8\xf2\x44\x04\
39 | \xb0\x49\xc3\x4f\x85\x02\xdf\x7e\x6e\x83\xd7\x2f\xfd\x8d\x77\x77\
40 | \x9f\xe1\x17\x1f\xbd\xca\x6e\xde\x05\x1b\x83\xb6\x2a\x1d\x95\x91\
41 | \x96\x1f\xf3\xda\xd9\xfb\x2c\xb7\x06\x24\x12\x58\xce\x9e\x20\x5a\
42 | \x32\xa8\x3c\x11\x6d\x80\x27\xeb\xd3\x97\x88\xf2\xd2\xc2\x36\xbd\
43 | \x34\xe7\x95\x95\x4f\x78\xee\xc4\x5e\xf3\xc4\x08\xb1\x50\xdd\xca\
44 | \x13\x06\x65\x4a\x51\x79\x00\x9c\x54\x64\xae\x22\xaf\x1c\xb3\xdd\
45 | \xff\x7f\x61\x2c\x24\x23\x5e\x5e\xdc\x42\x31\x16\x92\x9c\x2f\x2d\
46 | \x7e\x8a\x34\x3d\x2b\x56\x23\x04\x73\x6c\x8e\xe6\x40\x20\xf3\xb0\
47 | \x76\xf2\x21\xdf\x3a\x7f\x8f\xb6\x16\x53\x05\x1d\xbf\x54\x22\xf3\
48 | \xc9\x88\xcb\x27\xd7\xf9\xde\xa5\xbf\x70\xb6\xd3\x07\xe0\x70\x9c\
49 | \xf2\xf6\xf6\xb9\xa6\xeb\x3a\x7c\xe6\x8c\x71\x50\x36\x87\xf3\x84\
50 | \xa8\x24\x1a\x49\x35\xf0\xcd\xd5\x7b\x9c\x6a\xf7\xd9\x2b\xba\x7c\
51 | \x7c\xb4\x48\x11\x12\x82\x09\x73\x49\xce\x97\x17\x3f\xe5\x74\x67\
52 | \xc8\x8b\x73\xbb\x3c\x7b\xe2\x90\xcc\x41\x34\x78\x7b\x7b\x95\x3f\
53 | \x6d\x9d\x67\x29\x8b\x78\xad\xbb\xf0\xa9\x46\x86\x95\xe3\xc3\xc3\
54 | \x65\x76\x46\x5d\x96\x5a\x43\xaa\x28\x7c\xb6\xb7\xcf\x85\xf9\x03\
55 | \xc0\x18\x54\x29\x7b\x79\x9b\x32\x3a\x7a\x69\xce\x4a\x6b\x88\x4a\
56 | \x0d\x2a\x32\xf1\x8c\xf0\xfe\xfe\x49\x06\x55\x46\xc7\x8f\x99\xd3\
57 | \xda\x4c\x5e\x30\x32\x17\x78\x9c\x77\xf9\xe0\x70\x99\xcb\xd9\x06\
58 | \x2d\x5f\x67\x77\x62\x00\xcc\x27\x63\xda\xae\x22\x98\xe0\x35\xa2\
59 | \x0d\xa8\x1e\x13\xd5\x07\xfb\x4b\xbc\xf9\xef\x8b\x94\xe6\x18\x54\
60 | \x9e\xae\xaf\x70\x62\xa8\x59\xad\x87\xed\x51\x97\xdb\x7b\xa7\xa8\
61 | \xa2\xc3\x49\xfc\x1f\x3a\x13\x8d\xb4\x5c\xc0\x37\x49\x8f\xc7\x28\
62 | \x28\xbf\x59\xbf\xc4\xe6\xb0\x07\x40\x65\x35\x73\x00\xaa\x0a\x89\
63 | \x42\x11\x52\x40\x49\xb4\x22\x44\x08\x71\x46\xeb\x7f\x47\x44\x28\
64 | \x82\x9b\x02\x3d\x78\xb2\xc8\x1f\x37\x5f\x98\xaa\x4e\x8e\x39\x46\
65 | \x27\x7c\x17\xd1\xf1\xa0\x3f\xcf\x41\xd1\x21\x98\xa2\x3a\x7b\x29\
66 | \xd8\xac\xaa\x68\x50\x04\xc5\x6b\xc4\x4b\x3d\x32\x3e\x3a\x5a\x62\
67 | \xb7\xe8\x4e\x0b\x48\x35\xe2\xc4\x10\x01\x9d\x54\x18\x0d\x6e\xec\
68 | \xac\x72\x63\xe7\x1c\x4e\x9a\x2a\x9a\x55\x65\xc6\x47\x04\x32\x0d\
69 | \xd3\xdf\x0a\xac\xb4\x86\xb4\x5d\x35\xed\xb7\xe5\x42\xed\x12\x3b\
70 | \xc6\x93\x88\xf1\xb8\x68\xf3\xdb\xf5\x97\x78\x6f\xff\x24\xe3\xe8\
71 | \x30\x7b\x3a\x89\x0a\x78\x99\x7d\x94\x07\x47\xbf\x4a\xf8\xeb\xce\
72 | \xb3\x1c\x95\x2d\x40\x50\xa0\xed\xc2\x54\x5d\x53\x47\x44\xab\xbd\
73 | \xf7\xf7\x47\x67\xf9\xf1\xdd\xcb\xbc\xb5\xb5\x4a\x65\x3a\x4d\x62\
74 | \x36\x29\x84\x69\x27\x37\x76\xce\xf1\xc6\xad\xaf\xf1\xcb\xfb\x2f\
75 | \x33\x8e\x1e\x1a\x45\xba\x46\xa2\x11\xf0\x93\x7d\x05\x41\x30\x8a\
76 | \x98\x70\x63\xe7\x1c\x65\x74\x9c\xe9\xf4\xf9\xfc\xc2\x2e\x66\x35\
77 | \xb1\xd2\x64\xe9\x97\x09\xef\x3c\x7a\x86\x9f\xbe\xbf\xc6\xbb\x8f\
78 | \xce\x4e\x06\x02\x5e\x8c\xa5\xac\x40\x9b\xed\x29\xa3\xd6\x4f\x9c\
79 | \xc0\x5c\x52\x92\x69\x00\x8c\x71\x4c\xb8\xf3\xf8\x34\x3f\xb9\xfb\
80 | \x15\xfe\xb9\xbf\x42\x30\x61\x58\x7a\xf2\xa0\x1c\x8c\x33\x7e\xfd\
81 | \xaf\x2f\xf0\xc3\x7f\xbc\xc6\xad\xbd\x19\xb8\x62\xf4\xd2\x31\xed\
82 | \xc9\xfe\x37\x3e\xd2\x89\x14\xbd\x44\xbc\xce\x84\xd9\xaf\x52\xde\
83 | \xda\x7a\x9e\x1f\xbc\xf3\x0d\xfe\xbc\xb5\x4a\xea\x02\x2d\x17\x79\
84 | \x38\xe8\xf1\xe6\xc6\x45\x36\xfa\x8b\x04\xd3\xe9\xd0\xeb\xf8\x8a\
85 | \x5e\x52\x12\x81\x3c\x28\x95\x09\x5e\x0c\x25\xd6\x47\x5e\xa2\xb0\
86 | \x94\x8d\x98\xf7\x25\x8e\xd8\x90\x98\x70\xf7\xe0\x14\xb7\x1e\x9f\
87 | \x99\x4a\x76\x58\x25\xec\x17\x9d\xa6\x8c\xd9\x00\x6c\xbb\x8a\xa4\
88 | \x91\x6e\xea\xea\x35\x1a\x78\xe7\x66\x04\xb6\x1d\xa4\xed\x9c\xc3\
89 | \x32\xb0\x57\xa4\x04\x73\x44\x83\xdb\x7b\xa7\x59\xef\x2f\xd0\xf5\
90 | \x63\x7e\xff\xc9\x05\x0e\xc6\x2d\xd2\x06\xcc\x89\x91\xba\x8a\xb4\
91 | \x21\x56\x98\xe1\x19\xe0\x41\xee\x88\xd8\x17\xad\x31\x92\x13\x98\
92 | \x4f\x2a\x30\x28\x1b\x65\x7d\x7c\xb4\xc2\x8f\xee\x7c\x15\xaf\x91\
93 | \x7b\x07\x2b\xcc\x27\x01\x91\x30\x4d\x90\x34\xe0\x93\x7e\x62\xa3\
94 | \x4a\x27\x7c\xd7\x03\xdf\x07\x79\x5e\xc4\x7e\x66\x26\xd3\x43\xbd\
95 | \x97\x96\x4f\x1d\x91\x0f\x9e\xac\xa0\x62\x78\x15\xba\x12\xa6\x33\
96 | \x27\x98\x30\x18\xa7\x04\x13\xa2\x41\xa7\x19\x72\x1d\x1f\x2f\x00\
97 | \x0f\x3d\xf0\x87\x46\xe1\xbf\x3a\xe1\xcb\xfd\x61\xf0\xe2\x45\x08\
98 | \x76\xac\x57\x40\x1b\xe7\x0a\xd6\xf8\x42\x70\xcd\x7d\xd6\x28\x47\
99 | \x30\x12\x8d\x31\x51\x12\xc0\x6e\x5e\xb9\x6a\xff\x01\xee\xa0\x5e\
100 | \x8d\x8d\x31\x8b\x24\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
101 | \x82\
102 | "
103 |
104 | qt_resource_name = "\
105 | \x00\x07\
106 | \x07\x3b\xe0\xb3\
107 | \x00\x70\
108 | \x00\x6c\x00\x75\x00\x67\x00\x69\x00\x6e\x00\x73\
109 | \x00\x09\
110 | \x05\x4b\x7f\xa2\
111 | \x00\x63\
112 | \x00\x6f\x00\x6e\x00\x6e\x00\x65\x00\x63\x00\x74\x00\x6f\x00\x72\
113 | \x00\x08\
114 | \x0a\x61\x5a\xa7\
115 | \x00\x69\
116 | \x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
117 | "
118 |
119 | qt_resource_struct = "\
120 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
121 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
122 | \x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
123 | \x00\x00\x00\x2c\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
124 | "
125 |
126 |
127 | def qInitResources():
128 | QtCore.qRegisterResourceData(
129 | 0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
130 |
131 |
132 | def qCleanupResources():
133 | QtCore.qUnregisterResourceData(
134 | 0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
135 |
136 | qInitResources()
137 |
--------------------------------------------------------------------------------
/requests/packages/chardet/universaldetector.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 sys
31 | import codecs
32 | from .latin1prober import Latin1Prober # windows-1252
33 | from .mbcsgroupprober import MBCSGroupProber # multi-byte character sets
34 | from .sbcsgroupprober import SBCSGroupProber # single-byte character sets
35 | from .escprober import EscCharSetProber # ISO-2122, etc.
36 | import re
37 |
38 | MINIMUM_THRESHOLD = 0.20
39 | ePureAscii = 0
40 | eEscAscii = 1
41 | eHighbyte = 2
42 |
43 |
44 | class UniversalDetector:
45 | def __init__(self):
46 | self._highBitDetector = re.compile(b'[\x80-\xFF]')
47 | self._escDetector = re.compile(b'(\033|~{)')
48 | self._mEscCharSetProber = None
49 | self._mCharSetProbers = []
50 | self.reset()
51 |
52 | def reset(self):
53 | self.result = {'encoding': None, 'confidence': 0.0}
54 | self.done = False
55 | self._mStart = True
56 | self._mGotData = False
57 | self._mInputState = ePureAscii
58 | self._mLastChar = b''
59 | if self._mEscCharSetProber:
60 | self._mEscCharSetProber.reset()
61 | for prober in self._mCharSetProbers:
62 | prober.reset()
63 |
64 | def feed(self, aBuf):
65 | if self.done:
66 | return
67 |
68 | aLen = len(aBuf)
69 | if not aLen:
70 | return
71 |
72 | if not self._mGotData:
73 | # If the data starts with BOM, we know it is UTF
74 | if aBuf[:3] == codecs.BOM:
75 | # EF BB BF UTF-8 with BOM
76 | self.result = {'encoding': "UTF-8", 'confidence': 1.0}
77 | elif aBuf[:4] == codecs.BOM_UTF32_LE:
78 | # FF FE 00 00 UTF-32, little-endian BOM
79 | self.result = {'encoding': "UTF-32LE", 'confidence': 1.0}
80 | elif aBuf[:4] == codecs.BOM_UTF32_BE:
81 | # 00 00 FE FF UTF-32, big-endian BOM
82 | self.result = {'encoding': "UTF-32BE", 'confidence': 1.0}
83 | elif aBuf[:4] == b'\xFE\xFF\x00\x00':
84 | # FE FF 00 00 UCS-4, unusual octet order BOM (3412)
85 | self.result = {
86 | 'encoding': "X-ISO-10646-UCS-4-3412",
87 | 'confidence': 1.0
88 | }
89 | elif aBuf[:4] == b'\x00\x00\xFF\xFE':
90 | # 00 00 FF FE UCS-4, unusual octet order BOM (2143)
91 | self.result = {
92 | 'encoding': "X-ISO-10646-UCS-4-2143",
93 | 'confidence': 1.0
94 | }
95 | elif aBuf[:2] == codecs.BOM_LE:
96 | # FF FE UTF-16, little endian BOM
97 | self.result = {'encoding': "UTF-16LE", 'confidence': 1.0}
98 | elif aBuf[:2] == codecs.BOM_BE:
99 | # FE FF UTF-16, big endian BOM
100 | self.result = {'encoding': "UTF-16BE", 'confidence': 1.0}
101 |
102 | self._mGotData = True
103 | if self.result['encoding'] and (self.result['confidence'] > 0.0):
104 | self.done = True
105 | return
106 |
107 | if self._mInputState == ePureAscii:
108 | if self._highBitDetector.search(aBuf):
109 | self._mInputState = eHighbyte
110 | elif ((self._mInputState == ePureAscii) and
111 | self._escDetector.search(self._mLastChar + aBuf)):
112 | self._mInputState = eEscAscii
113 |
114 | self._mLastChar = aBuf[-1:]
115 |
116 | if self._mInputState == eEscAscii:
117 | if not self._mEscCharSetProber:
118 | self._mEscCharSetProber = EscCharSetProber()
119 | if self._mEscCharSetProber.feed(aBuf) == constants.eFoundIt:
120 | self.result = {'encoding': self._mEscCharSetProber.get_charset_name(),
121 | 'confidence': self._mEscCharSetProber.get_confidence()}
122 | self.done = True
123 | elif self._mInputState == eHighbyte:
124 | if not self._mCharSetProbers:
125 | self._mCharSetProbers = [MBCSGroupProber(), SBCSGroupProber(),
126 | Latin1Prober()]
127 | for prober in self._mCharSetProbers:
128 | if prober.feed(aBuf) == constants.eFoundIt:
129 | self.result = {'encoding': prober.get_charset_name(),
130 | 'confidence': prober.get_confidence()}
131 | self.done = True
132 | break
133 |
134 | def close(self):
135 | if self.done:
136 | return
137 | if not self._mGotData:
138 | if constants._debug:
139 | sys.stderr.write('no data received!\n')
140 | return
141 | self.done = True
142 |
143 | if self._mInputState == ePureAscii:
144 | self.result = {'encoding': 'ascii', 'confidence': 1.0}
145 | return self.result
146 |
147 | if self._mInputState == eHighbyte:
148 | proberConfidence = None
149 | maxProberConfidence = 0.0
150 | maxProber = None
151 | for prober in self._mCharSetProbers:
152 | if not prober:
153 | continue
154 | proberConfidence = prober.get_confidence()
155 | if proberConfidence > maxProberConfidence:
156 | maxProberConfidence = proberConfidence
157 | maxProber = prober
158 | if maxProber and (maxProberConfidence > MINIMUM_THRESHOLD):
159 | self.result = {'encoding': maxProber.get_charset_name(),
160 | 'confidence': maxProber.get_confidence()}
161 | return self.result
162 |
163 | if constants._debug:
164 | sys.stderr.write('no probers hit minimum threshhold\n')
165 | for prober in self._mCharSetProbers[0].mProbers:
166 | if not prober:
167 | continue
168 | sys.stderr.write('%s confidence = %s\n' %
169 | (prober.get_charset_name(),
170 | prober.get_confidence()))
171 |
--------------------------------------------------------------------------------
/help/source/conf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #
3 | # connector documentation build configuration file, created by
4 | # sphinx-quickstart on Sun Feb 12 17:11:03 2012.
5 | #
6 | # This file is execfile()d with the current directory set to its containing dir.
7 | #
8 | # Note that not all possible configuration values are present in this
9 | # autogenerated file.
10 | #
11 | # All configuration values have a default; values that are commented out
12 | # serve to show the default.
13 |
14 | import sys
15 | import os
16 |
17 | # If extensions (or modules to document with autodoc) are in another directory,
18 | # add these directories to sys.path here. If the directory is relative to the
19 | # documentation root, use os.path.abspath to make it absolute, like shown here.
20 | #sys.path.insert(0, os.path.abspath('.'))
21 |
22 | # -- General configuration -----------------------------------------------
23 |
24 | # If your documentation needs a minimal Sphinx version, state it here.
25 | #needs_sphinx = '1.0'
26 |
27 | # Add any Sphinx extension module names here, as strings. They can be extensions
28 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
29 | extensions = ['sphinx.ext.todo', 'sphinx.ext.pngmath', 'sphinx.ext.viewcode']
30 |
31 | # Add any paths that contain templates here, relative to this directory.
32 | templates_path = ['_templates']
33 |
34 | # The suffix of source filenames.
35 | source_suffix = '.rst'
36 |
37 | # The encoding of source files.
38 | #source_encoding = 'utf-8-sig'
39 |
40 | # The master toctree document.
41 | master_doc = 'index'
42 |
43 | # General information about the project.
44 | project = u'connector'
45 | copyright = u'2013, tschmitz HSR'
46 |
47 | # The version info for the project you're documenting, acts as replacement for
48 | # |version| and |release|, also used in various other places throughout the
49 | # built documents.
50 | #
51 | # The short X.Y version.
52 | version = '0.1'
53 | # The full version, including alpha/beta/rc tags.
54 | release = '0.1'
55 |
56 | # The language for content autogenerated by Sphinx. Refer to documentation
57 | # for a list of supported languages.
58 | #language = None
59 |
60 | # There are two options for replacing |today|: either, you set today to some
61 | # non-false value, then it is used:
62 | #today = ''
63 | # Else, today_fmt is used as the format for a strftime call.
64 | #today_fmt = '%B %d, %Y'
65 |
66 | # List of patterns, relative to source directory, that match files and
67 | # directories to ignore when looking for source files.
68 | exclude_patterns = []
69 |
70 | # The reST default role (used for this markup: `text`) to use for all documents.
71 | #default_role = None
72 |
73 | # If true, '()' will be appended to :func: etc. cross-reference text.
74 | #add_function_parentheses = True
75 |
76 | # If true, the current module name will be prepended to all description
77 | # unit titles (such as .. function::).
78 | #add_module_names = True
79 |
80 | # If true, sectionauthor and moduleauthor directives will be shown in the
81 | # output. They are ignored by default.
82 | #show_authors = False
83 |
84 | # The name of the Pygments (syntax highlighting) style to use.
85 | pygments_style = 'sphinx'
86 |
87 | # A list of ignored prefixes for module index sorting.
88 | #modindex_common_prefix = []
89 |
90 |
91 | # -- Options for HTML output ---------------------------------------------
92 |
93 | # The theme to use for HTML and HTML Help pages. See the documentation for
94 | # a list of builtin themes.
95 | html_theme = 'default'
96 |
97 | # Theme options are theme-specific and customize the look and feel of a theme
98 | # further. For a list of options available for each theme, see the
99 | # documentation.
100 | #html_theme_options = {}
101 |
102 | # Add any paths that contain custom themes here, relative to this directory.
103 | #html_theme_path = []
104 |
105 | # The name for this set of Sphinx documents. If None, it defaults to
106 | # " v documentation".
107 | #html_title = None
108 |
109 | # A shorter title for the navigation bar. Default is the same as html_title.
110 | #html_short_title = None
111 |
112 | # The name of an image file (relative to this directory) to place at the top
113 | # of the sidebar.
114 | #html_logo = None
115 |
116 | # The name of an image file (within the static path) to use as favicon of the
117 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
118 | # pixels large.
119 | #html_favicon = None
120 |
121 | # Add any paths that contain custom static files (such as style sheets) here,
122 | # relative to this directory. They are copied after the builtin static files,
123 | # so a file named "default.css" will overwrite the builtin "default.css".
124 | html_static_path = ['_static']
125 |
126 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
127 | # using the given strftime format.
128 | #html_last_updated_fmt = '%b %d, %Y'
129 |
130 | # If true, SmartyPants will be used to convert quotes and dashes to
131 | # typographically correct entities.
132 | #html_use_smartypants = True
133 |
134 | # Custom sidebar templates, maps document names to template names.
135 | #html_sidebars = {}
136 |
137 | # Additional templates that should be rendered to pages, maps page names to
138 | # template names.
139 | #html_additional_pages = {}
140 |
141 | # If false, no module index is generated.
142 | #html_domain_indices = True
143 |
144 | # If false, no index is generated.
145 | #html_use_index = True
146 |
147 | # If true, the index is split into individual pages for each letter.
148 | #html_split_index = False
149 |
150 | # If true, links to the reST sources are added to the pages.
151 | #html_show_sourcelink = True
152 |
153 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
154 | #html_show_sphinx = True
155 |
156 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
157 | #html_show_copyright = True
158 |
159 | # If true, an OpenSearch description file will be output, and all pages will
160 | # contain a tag referring to it. The value of this option must be the
161 | # base URL from which the finished HTML is served.
162 | #html_use_opensearch = ''
163 |
164 | # This is the file name suffix for HTML files (e.g. ".xhtml").
165 | #html_file_suffix = None
166 |
167 | # Output file base name for HTML help builder.
168 | htmlhelp_basename = 'templateclassdoc'
169 |
170 |
171 | # -- Options for LaTeX output --------------------------------------------
172 |
173 | # The paper size ('letter' or 'a4').
174 | #latex_paper_size = 'letter'
175 |
176 | # The font size ('10pt', '11pt' or '12pt').
177 | #latex_font_size = '10pt'
178 |
179 | # Grouping the document tree into LaTeX files. List of tuples
180 | # (source start file, target name, title, author, documentclass [howto/manual]).
181 | latex_documents = [
182 | ('index', 'connector.tex', u'connector Documentation',
183 | u'tschmitz HSR', 'manual'),
184 | ]
185 |
186 | # The name of an image file (relative to this directory) to place at the top of
187 | # the title page.
188 | #latex_logo = None
189 |
190 | # For "manual" documents, if this is true, then toplevel headings are parts,
191 | # not chapters.
192 | #latex_use_parts = False
193 |
194 | # If true, show page references after internal links.
195 | #latex_show_pagerefs = False
196 |
197 | # If true, show URL addresses after external links.
198 | #latex_show_urls = False
199 |
200 | # Additional stuff for the LaTeX preamble.
201 | #latex_preamble = ''
202 |
203 | # Documents to append as an appendix to all manuals.
204 | #latex_appendices = []
205 |
206 | # If false, no module index is generated.
207 | #latex_domain_indices = True
208 |
209 |
210 | # -- Options for manual page output --------------------------------------
211 |
212 | # One entry per manual page. List of tuples
213 | # (source start file, name, description, authors, manual section).
214 | man_pages = [
215 | ('index', 'templateclass', u'connector Documentation',
216 | [u'tschmitz HSR'], 1)
217 | ]
218 |
--------------------------------------------------------------------------------