├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── ALL_README.md ├── LICENSE ├── README.md ├── README_fr.md ├── check_process ├── conf ├── app.src ├── nginx.conf ├── requirement.txt ├── syncserver.ini └── systemd.service ├── doc ├── DESCRIPTION.md ├── DESCRIPTION_fr.md ├── DISCLAIMER.md ├── DISCLAIMER_fr.md └── PRE_UPGRADE.md ├── manifest.json ├── scripts ├── _common.sh ├── backup ├── install ├── remove ├── restore └── upgrade └── sources ├── .gitignore ├── .travis.yml ├── homepage.patch ├── page ├── index.pt ├── media │ ├── fonts │ │ ├── opensans-bold.5cf854f3d1c0.woff2 │ │ ├── opensans-italic.c86748d08341.woff2 │ │ ├── opensans-light.2120033991a4.woff2 │ │ ├── opensans-lightitalic.580ce2d5ac1d.woff2 │ │ └── opensans-regular.668362de763a.woff2 │ └── img │ │ ├── firefox │ │ ├── family │ │ │ └── nav-sprite.56fbf5a8d218.png │ │ └── sync │ │ │ ├── device-lineup.a60618c7dacb.png │ │ │ └── icons.b80c6430793b.png │ │ ├── sandstone │ │ ├── bg-gradient-sky.7ea325995978.png │ │ ├── footer-mozilla.fafef0912042.png │ │ └── grain.855f29e0c686.png │ │ └── tabzilla │ │ └── tabzilla-static.953a65a1f4a4.png └── sync_files │ ├── btn-app-store.svg │ ├── btn-google-play.png │ ├── common-bundle.js │ ├── firefox_sync-bundle.css │ ├── firefox_sync-bundle.js │ ├── firefox_sync_anim-bundle.css │ ├── gtm-snippet-bundle.js │ ├── responsive-bundle.css │ └── site-bundle.js └── pip_20.1 ├── __init__.py ├── __main__.py ├── _internal ├── __init__.py ├── build_env.py ├── cache.py ├── cli │ ├── __init__.py │ ├── autocompletion.py │ ├── base_command.py │ ├── cmdoptions.py │ ├── command_context.py │ ├── main.py │ ├── main_parser.py │ ├── parser.py │ ├── progress_bars.py │ ├── req_command.py │ ├── spinners.py │ └── status_codes.py ├── commands │ ├── __init__.py │ ├── cache.py │ ├── check.py │ ├── completion.py │ ├── configuration.py │ ├── debug.py │ ├── download.py │ ├── freeze.py │ ├── hash.py │ ├── help.py │ ├── install.py │ ├── list.py │ ├── search.py │ ├── show.py │ ├── uninstall.py │ └── wheel.py ├── configuration.py ├── distributions │ ├── __init__.py │ ├── base.py │ ├── installed.py │ ├── sdist.py │ └── wheel.py ├── exceptions.py ├── index │ ├── __init__.py │ ├── collector.py │ └── package_finder.py ├── locations.py ├── main.py ├── models │ ├── __init__.py │ ├── candidate.py │ ├── direct_url.py │ ├── format_control.py │ ├── index.py │ ├── link.py │ ├── scheme.py │ ├── search_scope.py │ ├── selection_prefs.py │ ├── target_python.py │ └── wheel.py ├── network │ ├── __init__.py │ ├── auth.py │ ├── cache.py │ ├── download.py │ ├── session.py │ ├── utils.py │ └── xmlrpc.py ├── operations │ ├── __init__.py │ ├── build │ │ ├── __init__.py │ │ ├── metadata.py │ │ ├── metadata_legacy.py │ │ ├── wheel.py │ │ └── wheel_legacy.py │ ├── check.py │ ├── freeze.py │ ├── install │ │ ├── __init__.py │ │ ├── editable_legacy.py │ │ ├── legacy.py │ │ └── wheel.py │ └── prepare.py ├── pyproject.py ├── req │ ├── __init__.py │ ├── constructors.py │ ├── req_file.py │ ├── req_install.py │ ├── req_set.py │ ├── req_tracker.py │ └── req_uninstall.py ├── resolution │ ├── __init__.py │ ├── base.py │ ├── legacy │ │ ├── __init__.py │ │ └── resolver.py │ └── resolvelib │ │ ├── __init__.py │ │ ├── base.py │ │ ├── candidates.py │ │ ├── factory.py │ │ ├── provider.py │ │ ├── requirements.py │ │ └── resolver.py ├── self_outdated_check.py ├── utils │ ├── __init__.py │ ├── appdirs.py │ ├── compat.py │ ├── compatibility_tags.py │ ├── deprecation.py │ ├── direct_url_helpers.py │ ├── distutils_args.py │ ├── encoding.py │ ├── entrypoints.py │ ├── filesystem.py │ ├── filetypes.py │ ├── glibc.py │ ├── hashes.py │ ├── inject_securetransport.py │ ├── logging.py │ ├── misc.py │ ├── models.py │ ├── packaging.py │ ├── pkg_resources.py │ ├── setuptools_build.py │ ├── subprocess.py │ ├── temp_dir.py │ ├── typing.py │ ├── unpacking.py │ ├── urls.py │ ├── virtualenv.py │ └── wheel.py ├── vcs │ ├── __init__.py │ ├── bazaar.py │ ├── git.py │ ├── mercurial.py │ ├── subversion.py │ └── versioncontrol.py └── wheel_builder.py └── _vendor ├── __init__.py ├── appdirs.py ├── cachecontrol ├── __init__.py ├── _cmd.py ├── adapter.py ├── cache.py ├── caches │ ├── __init__.py │ ├── file_cache.py │ └── redis_cache.py ├── compat.py ├── controller.py ├── filewrapper.py ├── heuristics.py ├── serialize.py └── wrapper.py ├── certifi ├── __init__.py ├── __main__.py ├── cacert.pem └── core.py ├── chardet ├── __init__.py ├── big5freq.py ├── big5prober.py ├── chardistribution.py ├── charsetgroupprober.py ├── charsetprober.py ├── cli │ ├── __init__.py │ └── chardetect.py ├── codingstatemachine.py ├── compat.py ├── cp949prober.py ├── enums.py ├── escprober.py ├── escsm.py ├── eucjpprober.py ├── euckrfreq.py ├── euckrprober.py ├── euctwfreq.py ├── euctwprober.py ├── gb2312freq.py ├── gb2312prober.py ├── hebrewprober.py ├── jisfreq.py ├── jpcntx.py ├── langbulgarianmodel.py ├── langcyrillicmodel.py ├── langgreekmodel.py ├── langhebrewmodel.py ├── langhungarianmodel.py ├── langthaimodel.py ├── langturkishmodel.py ├── latin1prober.py ├── mbcharsetprober.py ├── mbcsgroupprober.py ├── mbcssm.py ├── sbcharsetprober.py ├── sbcsgroupprober.py ├── sjisprober.py ├── universaldetector.py ├── utf8prober.py └── version.py ├── colorama ├── __init__.py ├── ansi.py ├── ansitowin32.py ├── initialise.py ├── win32.py └── winterm.py ├── contextlib2.py ├── distlib ├── __init__.py ├── _backport │ ├── __init__.py │ ├── misc.py │ ├── shutil.py │ ├── sysconfig.cfg │ ├── sysconfig.py │ └── tarfile.py ├── compat.py ├── database.py ├── index.py ├── locators.py ├── manifest.py ├── markers.py ├── metadata.py ├── resources.py ├── scripts.py ├── t32.exe ├── t64.exe ├── util.py ├── version.py ├── w32.exe ├── w64.exe └── wheel.py ├── distro.py ├── html5lib ├── __init__.py ├── _ihatexml.py ├── _inputstream.py ├── _tokenizer.py ├── _trie │ ├── __init__.py │ ├── _base.py │ ├── datrie.py │ └── py.py ├── _utils.py ├── constants.py ├── filters │ ├── __init__.py │ ├── alphabeticalattributes.py │ ├── base.py │ ├── inject_meta_charset.py │ ├── lint.py │ ├── optionaltags.py │ ├── sanitizer.py │ └── whitespace.py ├── html5parser.py ├── serializer.py ├── treeadapters │ ├── __init__.py │ ├── genshi.py │ └── sax.py ├── treebuilders │ ├── __init__.py │ ├── base.py │ ├── dom.py │ ├── etree.py │ └── etree_lxml.py └── treewalkers │ ├── __init__.py │ ├── base.py │ ├── dom.py │ ├── etree.py │ ├── etree_lxml.py │ └── genshi.py ├── idna ├── __init__.py ├── codec.py ├── compat.py ├── core.py ├── idnadata.py ├── intranges.py ├── package_data.py └── uts46data.py ├── ipaddress.py ├── msgpack ├── __init__.py ├── _version.py ├── exceptions.py ├── ext.py └── fallback.py ├── packaging ├── __about__.py ├── __init__.py ├── _compat.py ├── _structures.py ├── _typing.py ├── markers.py ├── requirements.py ├── specifiers.py ├── tags.py ├── utils.py └── version.py ├── pep517 ├── __init__.py ├── _in_process.py ├── build.py ├── check.py ├── colorlog.py ├── compat.py ├── dirtools.py ├── envbuild.py ├── meta.py └── wrappers.py ├── pkg_resources ├── __init__.py └── py31compat.py ├── progress ├── __init__.py ├── bar.py ├── counter.py └── spinner.py ├── pyparsing.py ├── requests ├── __init__.py ├── __version__.py ├── _internal_utils.py ├── adapters.py ├── api.py ├── auth.py ├── certs.py ├── compat.py ├── cookies.py ├── exceptions.py ├── help.py ├── hooks.py ├── models.py ├── packages.py ├── sessions.py ├── status_codes.py ├── structures.py └── utils.py ├── resolvelib ├── __init__.py ├── providers.py ├── reporters.py ├── resolvers.py └── structs.py ├── retrying.py ├── six.py ├── toml.py ├── toml ├── __init__.py ├── decoder.py ├── encoder.py ├── ordered.py └── tz.py ├── urllib3 ├── __init__.py ├── _collections.py ├── connection.py ├── connectionpool.py ├── contrib │ ├── __init__.py │ ├── _appengine_environ.py │ ├── _securetransport │ │ ├── __init__.py │ │ ├── bindings.py │ │ └── low_level.py │ ├── appengine.py │ ├── ntlmpool.py │ ├── pyopenssl.py │ ├── securetransport.py │ └── socks.py ├── exceptions.py ├── fields.py ├── filepost.py ├── packages │ ├── __init__.py │ ├── backports │ │ ├── __init__.py │ │ └── makefile.py │ ├── six.py │ └── ssl_match_hostname │ │ ├── __init__.py │ │ └── _implementation.py ├── poolmanager.py ├── request.py ├── response.py └── util │ ├── __init__.py │ ├── connection.py │ ├── queue.py │ ├── request.py │ ├── response.py │ ├── retry.py │ ├── ssl_.py │ ├── timeout.py │ ├── url.py │ └── wait.py ├── vendor.txt └── webencodings ├── __init__.py ├── labels.py ├── mklabels.py ├── tests.py └── x_user_defined.py /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. 4 | 5 | --- 6 | 7 | **How to post a meaningful bug report** 8 | 1. *Read this whole template first.* 9 | 2. *Determine if you are on the right place:* 10 | - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* 11 | - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* 12 | - *When in doubt, post here and we will figure it out together.* 13 | 3. *Delete the italic comments as you write over them below, and remove this guide.* 14 | --- 15 | 16 | ### Describe the bug 17 | 18 | *A clear and concise description of what the bug is.* 19 | 20 | ### Context 21 | 22 | - Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* 23 | - YunoHost version: x.x.x 24 | - I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* 25 | - Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* 26 | - If yes, please explain: 27 | - Using, or trying to install package version/branch: 28 | - If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* 29 | 30 | ### Steps to reproduce 31 | 32 | - *If you performed a command from the CLI, the command itself is enough. For example:* 33 | ```sh 34 | sudo yunohost app install the_app 35 | ``` 36 | - *If you used the webadmin, please perform the equivalent command from the CLI first.* 37 | - *If the error occurs in your browser, explain what you did:* 38 | 1. *Go to '...'* 39 | 2. *Click on '...'* 40 | 3. *Scroll down to '...'* 41 | 4. *See error* 42 | 43 | ### Expected behavior 44 | 45 | *A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* 46 | 47 | ### Logs 48 | 49 | *When an operation fails, YunoHost provides a simple way to share the logs.* 50 | - *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* 51 | - *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* 52 | 53 | *After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* 54 | 55 | *If applicable and useful, add screenshots to help explain your problem.* 56 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Problem 2 | 3 | - *Description of why you made this PR* 4 | 5 | ## Solution 6 | 7 | - *And how do you fix that problem* 8 | 9 | ## PR Status 10 | 11 | - [ ] Code finished and ready to be reviewed/tested 12 | - [ ] The fix/enhancement were manually tested (if applicable) 13 | 14 | ## Automatic tests 15 | 16 | Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # From kateproject 2 | .kateproject 3 | .kateproject.d 4 | .directory 5 | 6 | -------------------------------------------------------------------------------- /ALL_README.md: -------------------------------------------------------------------------------- 1 | # All available README files by language 2 | 3 | - [Read the README in English](README.md) 4 | - [Lire le README en français](README_fr.md) 5 | -------------------------------------------------------------------------------- /README_fr.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Firefox Sync Server pour YunoHost 7 | 8 | [![Niveau d’intégration](https://dash.yunohost.org/integration/ffsync.svg)](https://dash.yunohost.org/appci/app/ffsync) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/ffsync.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/ffsync.maintain.svg) 9 | 10 | [![Installer Firefox Sync Server avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=ffsync) 11 | 12 | *[Lire le README dans d'autres langues.](./ALL_README.md)* 13 | 14 | > *Ce package vous permet d’installer Firefox Sync Server rapidement et simplement sur un serveur YunoHost.* 15 | > *Si vous n’avez pas YunoHost, consultez [ce guide](https://yunohost.org/install) pour savoir comment l’installer et en profiter.* 16 | 17 | ## Vue d’ensemble 18 | 19 | Le serveur de synchronisation permet un remplacement du serveur par défaut de Firefox (hébergé par Mozilla). 20 | 21 | Par défaut, le serveur reporte l'authentification aux serveurs de comptes de Mozilla à https://accounts.firefox.com. vous vous authentifierez donc sur les serveurs de Mozilla, mais _le stockage de vos informations se fera sur votre serveur_. 22 | 23 | ⚠️ Cette app est **obsolète et remplacée** par [syncstorage-rs](https://apps.yunohost.org/app/syncserver-rs). 24 | 25 | 26 | **Version incluse :** 1.9.1~ynh6 27 | ## Avertissements / informations importantes 28 | 29 | ## Configuration 30 | 31 | Une fois installé, la page `http://domain.tld/path` vous explique comment l'utiliser. 32 | ## :red_circle: Anti-fonctionnalités 33 | 34 | - **Application non maintenue**: Ce logiciel n'est plus maintenu. Attendez-vous à ce qu'il ne fonctionne plus avec le temps, et que l'on découvre des failles de sécurité qui ne seront pas corrigées, etc. 35 | 36 | ## Documentations et ressources 37 | 38 | - Documentation officielle de l’admin : 39 | - Dépôt de code officiel de l’app : 40 | - YunoHost Store : 41 | - Signaler un bug : 42 | 43 | ## Informations pour les développeurs 44 | 45 | Merci de faire vos pull request sur la [branche `testing`](https://github.com/YunoHost-Apps/ffsync_ynh/tree/testing). 46 | 47 | Pour essayer la branche `testing`, procédez comme suit : 48 | 49 | ```bash 50 | sudo yunohost app install https://github.com/YunoHost-Apps/ffsync_ynh/tree/testing --debug 51 | ou 52 | sudo yunohost app upgrade ffsync -u https://github.com/YunoHost-Apps/ffsync_ynh/tree/testing --debug 53 | ``` 54 | 55 | **Plus d’infos sur le packaging d’applications :** 56 | -------------------------------------------------------------------------------- /check_process: -------------------------------------------------------------------------------- 1 | ;; Test name 2 | ; Manifest 3 | domain="domain.tld" 4 | path="/path" 5 | ; Checks 6 | pkg_linter=1 7 | setup_sub_dir=1 8 | setup_root=1 9 | setup_nourl=0 10 | setup_private=0 11 | setup_public=1 12 | upgrade=1 13 | backup_restore=1 14 | multi_instance=1 15 | port_already_use=0 16 | change_url=0 17 | ;;; Upgrade options 18 | name=Before migration to pypy 19 | -------------------------------------------------------------------------------- /conf/app.src: -------------------------------------------------------------------------------- 1 | SOURCE_URL=https://github.com/mozilla-services/syncserver/archive/bfbc3abd36ee4db70df13a9c43f7758a1528c965.zip 2 | SOURCE_SUM=6f8fe5c039354a521c2697c547d89c56e030f7b780fcc1d96377708cd734ea53 3 | SOURCE_SUM_PRG=sha256sum 4 | SOURCE_FORMAT=zip 5 | -------------------------------------------------------------------------------- /conf/nginx.conf: -------------------------------------------------------------------------------- 1 | #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; 2 | location __PATH__/ { 3 | 4 | # Path to source 5 | alias __FINALPATH__/ ; 6 | 7 | include uwsgi_params; 8 | # Needed for long running operations in admin interface 9 | proxy_pass http://127.0.0.1:__PORT__/; 10 | proxy_set_header Host $host; 11 | proxy_set_header X-Forwarded-Proto $scheme; 12 | proxy_buffering off; 13 | client_max_body_size 200M; 14 | proxy_set_header X-Real-IP $remote_addr; 15 | } 16 | -------------------------------------------------------------------------------- /conf/requirement.txt: -------------------------------------------------------------------------------- 1 | alembic==1.0.9 2 | asn1crypto==0.24.0 3 | backports.functools-lru-cache==1.6.1 4 | beautifulsoup4==4.6.3 5 | boto==2.49.0 6 | cachetools==3.1.1 7 | certifi==2019.3.9 8 | cffi==1.14.0 9 | Chameleon==3.4 10 | chardet==3.0.4 11 | configparser==3.5.0 12 | cornice==0.16.2 13 | cryptography==2.6.1 14 | enum34==1.1.6 15 | futures==3.0.0 16 | gevent==1.4.0 17 | google-api-core==1.22.4 18 | google-auth==1.22.1 19 | google-cloud-core==1.4.3 20 | google-cloud-spanner==1.18.0 21 | googleapis-common-protos==1.52.0 22 | greenlet==0.4.13 23 | grpc-google-iam-v1==0.12.3 24 | grpcio==1.32.0 25 | grpcio-gcp==0.2.2 26 | gunicorn==19.6.0 27 | hawkauthlib==2.0.0 28 | hupper==1.6.1 29 | idna==2.8 30 | ipaddress==1.0.22 31 | konfig==1.1 32 | linecache2==1.0.0 33 | Mako==1.0.9 34 | MarkupSafe==1.1.1 35 | mozsvc==0.9 36 | mysqlclient==1.4.6 37 | Paste==3.0.8 38 | PasteDeploy==2.0.1 39 | pip==20.2.3 40 | pkg-resources==0.0.0 41 | plaster==1.0 42 | plaster-pastedeploy==0.7 43 | protobuf==3.13.0 44 | pyasn1==0.4.8 45 | pyasn1-modules==0.2.8 46 | PyBrowserID==0.14.0 47 | pycparser==2.19 48 | PyFxA==0.7.7 49 | PyJWT==1.7.1 50 | PyMySQL==0.9.3 51 | pymysql-sa==1.0 52 | pyramid==1.5.3 53 | pyramid-chameleon==0.3 54 | pyramid-hawkauth==2.0.0 55 | python-dateutil==2.8.0 56 | python-editor==1.0.4 57 | pytz==2020.1 58 | repoze.lru==0.7 59 | requests==2.20.0 60 | rsa==4.5 61 | setuptools==44.1.1 62 | simplejson==3.16.0 63 | six==1.14.0 64 | soupsieve==1.9.5 65 | SQLAlchemy==1.3.3 66 | SyncStorage==1.8.0 67 | testfixtures==6.7.0 68 | tokenlib==2.0.0 69 | tokenserver==1.5.11 70 | traceback2==1.4.0 71 | translationstring==1.3 72 | umemcache==1.6.3 73 | unittest2==1.1.0 74 | urllib3==1.24 75 | venusian==1.2.0 76 | waitress==1.1.0 77 | WebOb==1.4.1 78 | WebTest==2.0.30 79 | wheel==0.35.1 80 | WSGIProxy==0.2.2 81 | zope.component==4.2.1 82 | zope.deprecation==4.4.0 83 | zope.event==4.3.0 84 | zope.interface==4.6.0 85 | -------------------------------------------------------------------------------- /conf/syncserver.ini: -------------------------------------------------------------------------------- 1 | [server:main] 2 | use = egg:gunicorn 3 | host = 127.0.0.1 4 | port = __PORT__ 5 | workers = 1 6 | timeout = 30 7 | 8 | [app:main] 9 | use = egg:syncserver 10 | 11 | [syncserver] 12 | # This must be edited to point to the public URL of your server, 13 | # i.e. the URL as seen by Firefox. 14 | public_url = https://__DOMAIN____PATH__ 15 | 16 | # This defines the database in which to store all server data. 17 | sqluri = pymysql://__DB_USER__:__DB_PWD__@localhost/__DB_NAME__ 18 | 19 | # This is a secret key used for signing authentication tokens. 20 | # It should be long and randomly-generated. 21 | # The following command will give a suitable value on *nix systems: 22 | # 23 | # head -c 20 /dev/urandom | sha1sum 24 | # 25 | # If not specified then the server will generate a temporary one at startup. 26 | secret = __SECRET__ 27 | 28 | # Set this to "false" to disable new-user signups on the server. 29 | # Only request by existing accounts will be honoured. 30 | allow_new_users = true 31 | 32 | # Set this to "true" to work around a mismatch between public_url and 33 | # the application URL as seen by python, which can happen in certain reverse- 34 | # proxy hosting setups. It will overwrite the WSGI environ dict with the 35 | # details from public_url. This could have security implications if e.g. 36 | # you tell the app that it's on HTTPS but it's really on HTTP, so it should 37 | # only be used as a last resort and after careful checking of server config. 38 | force_wsgi_environ = false 39 | 40 | # Uncomment and edit the following to use a local BrowserID verifier 41 | # rather than posting assertions to the mozilla-hosted verifier. 42 | # Audiences should be set to your public_url without a trailing slash. 43 | #[browserid] 44 | #backend = tokenserver.verifiers.LocalVerifier 45 | -------------------------------------------------------------------------------- /conf/systemd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Firefox sync server 3 | After=network.target 4 | After=mysql.service 5 | 6 | [Service] 7 | # Modify these two values and uncomment them if you have 8 | # repos with lots of files and get an HTTP error 500 because 9 | # of that 10 | ### 11 | #LimitMEMLOCK=infinity 12 | #LimitNOFILE=65535 13 | Type=simple 14 | User=__APP__ 15 | Group=__APP__ 16 | WorkingDirectory=/opt/yunohost/__APP__ 17 | ExecStart=/opt/yunohost/__APP__/local/bin/gunicorn --paste /opt/yunohost/__APP__/syncserver.ini 18 | Restart=always 19 | 20 | # Sandboxing options to harden security 21 | # Depending on specificities of your service/app, you may need to tweak these 22 | # .. but this should be a good baseline 23 | # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html 24 | NoNewPrivileges=yes 25 | PrivateTmp=yes 26 | PrivateDevices=yes 27 | RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 28 | RestrictNamespaces=yes 29 | RestrictRealtime=yes 30 | DevicePolicy=closed 31 | ProtectSystem=full 32 | ProtectControlGroups=yes 33 | ProtectKernelModules=yes 34 | ProtectKernelTunables=yes 35 | LockPersonality=yes 36 | SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @swap 37 | 38 | # Denying access to capabilities that should not be relevant for webapps 39 | # Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html 40 | CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD 41 | CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE 42 | CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT 43 | CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK 44 | CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM 45 | CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG 46 | CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE 47 | CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW 48 | CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG 49 | 50 | [Install] 51 | WantedBy=multi-user.target 52 | -------------------------------------------------------------------------------- /doc/DESCRIPTION.md: -------------------------------------------------------------------------------- 1 | The Sync Server provides a replacement for Firefox’s default server (hosted at Mozilla). 2 | 3 | By default, a server set up will defer authentication to the Mozilla-hosted accounts server at [https://accounts.firefox.com](https://accounts.firefox.com). So you will still have to authenticate at Mozilla, but _the storage of your information will be done on your host_. 4 | 5 | ⚠️ This app is **deprecated and replaced** by [syncstorage-rs](https://apps.yunohost.org/app/syncserver-rs). 6 | -------------------------------------------------------------------------------- /doc/DESCRIPTION_fr.md: -------------------------------------------------------------------------------- 1 | Le serveur de synchronisation permet un remplacement du serveur par défaut de Firefox (hébergé par Mozilla). 2 | 3 | Par défaut, le serveur reporte l'authentification aux serveurs de comptes de Mozilla à https://accounts.firefox.com. vous vous authentifierez donc sur les serveurs de Mozilla, mais _le stockage de vos informations se fera sur votre serveur_. 4 | 5 | ⚠️ Cette app est **obsolète et remplacée** par [syncstorage-rs](https://apps.yunohost.org/app/syncserver-rs). 6 | -------------------------------------------------------------------------------- /doc/DISCLAIMER.md: -------------------------------------------------------------------------------- 1 | ## Configuration 2 | 3 | Once installed, reaching `http://domain.tld/path` should show a page explaining how to configure it. 4 | 5 | ### Solving problems with Android 6 | 7 | The sure-fire way to know what Sync on Android is really doing is to observe the Android device log using adb logcat. You’ll want to bump your log-level: 8 | ``` 9 | adb shell setprop log.tag.FxAccounts VERBOSE 10 | ``` 11 | 12 | Then, you can observe the log using: 13 | ``` 14 | adb logcat | grep FxAccounts 15 | ``` 16 | 17 | It’s best to observe the log while you force a sync from the Android Settings App. You should see output like: 18 | 19 | ``` 20 | D FxAccounts(...) fennec :: BaseResource :: HTTP GET https://token.stage.mozaws.net/1.0/sync/1.5 21 | ... 22 | D FxAccounts(...) fennec :: BaseResource :: HTTP GET https://sync-4-us-east-1.stage.mozaws.net/ 23 | ``` 24 | -------------------------------------------------------------------------------- /doc/DISCLAIMER_fr.md: -------------------------------------------------------------------------------- 1 | ## Configuration 2 | 3 | Une fois installé, la page `http://domain.tld/path` vous explique comment l'utiliser. -------------------------------------------------------------------------------- /doc/PRE_UPGRADE.md: -------------------------------------------------------------------------------- 1 | ⚠️ This app is **deprecated and replaced** by [syncstorage](https://apps.yunohost.org/app/syncserver-rs). 2 | We strongly encourage you to migrate to syncserver since ffsync will NOT be updated anymore! 3 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Firefox Sync Server", 3 | "id": "ffsync", 4 | "packaging_format": 1, 5 | "description": { 6 | "en": "Mozilla’s Sync-Server to host your Firefox account data", 7 | "fr": "Serveur de synchronisation de Mozilla, pour héberger vos données Firefox" 8 | }, 9 | "version": "1.9.1~ynh6", 10 | "url": "https://github.com/mozilla-services/syncserver", 11 | "upstream": { 12 | "license": "MPL-2.0", 13 | "admindoc": "https://mozilla-services.readthedocs.io/en/latest/howtos/run-sync-1.5.html", 14 | "code": "https://github.com/mozilla-services/syncserver" 15 | }, 16 | "license": "MPL-2.0", 17 | "maintainer": { 18 | "name": "Josué Tille", 19 | "email": "josue@tille.ch" 20 | }, 21 | "previous_maintainers": [{ 22 | "name": "beudbeud", 23 | "email": "beudbeud@beudibox.fr" 24 | }, { 25 | "name": "jibec", 26 | "email": "jean-baptiste@holcroft.fr" 27 | }], 28 | "requirements": { 29 | "yunohost": ">= 11.2" 30 | }, 31 | "multi_instance": true, 32 | "services": [ 33 | "nginx" 34 | ], 35 | "arguments": { 36 | "install" : [ 37 | { 38 | "name": "domain", 39 | "type": "domain" 40 | }, 41 | { 42 | "name": "path", 43 | "type": "path", 44 | "example": "/ffsync", 45 | "default": "/ffsync" 46 | } 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /scripts/_common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #================================================= 4 | # COMMON VARIABLES 5 | #================================================= 6 | 7 | 8 | # Note that we also need some specific pkg_dependencies for build with arm architectures 9 | # dependencies used by the app 10 | pkg_dependencies="pypy pypy-dev python3-virtualenv build-essential libssl-dev libffi-dev libmariadb-dev-compat" 11 | 12 | #================================================= 13 | # PERSONAL HELPERS 14 | #================================================= 15 | 16 | call_pip() { 17 | ynh_exec_warn_less pip $@ 18 | } 19 | 20 | install_sources() { 21 | ynh_setup_source --dest_dir "$final_path" 22 | 23 | # pip installation 24 | python3 -m virtualenv --python=$(which pypy | head -n 1) "$final_path/local" 25 | # Install manually pip v20.1 because the installed version from the system don't work any more with pyp v2.7 26 | cp -r ../sources/pip_20.1/. $final_path/local/site-packages/pip 27 | 28 | # Init virtualenv 29 | set +o nounset 30 | source "$final_path/local/bin/activate" 31 | set -o nounset 32 | pushd "$final_path" 33 | call_pip install --upgrade 'pip<20.2' 34 | call_pip install setuptools==44.1.1 35 | call_pip install --upgrade pyramid_chameleon 'soupsieve<2.0' 36 | CFLAGS="-Wno-error -Wno-error=format-security" \ 37 | ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" \ 38 | call_pip install --upgrade --requirement "$final_path/requirements.txt" 39 | pypy "$final_path/setup.py" develop 40 | test -e $final_path/local/lib_pypy/_sysconfigdata.py || ln -s /usr/lib/pypy/lib_pypy/_sysconfigdata.py $final_path/local/lib_pypy/_sysconfigdata.py 41 | test -e $final_path/local/lib_pypy/cffi || ln -s /usr/lib/pypy/lib_pypy/cffi $final_path/local/lib_pypy/cffi 42 | popd 43 | 44 | # Add nice homepage 45 | cp -r ../sources/page $final_path/syncserver/ 46 | (cd "$final_path/syncserver" && patch -p1 < $YNH_CWD/../sources/homepage.patch) || echo "Unable to apply patches" 47 | } 48 | 49 | set_permissions() { 50 | chown $app -R $final_path 51 | chmod u=rwX,g=rX,o= -R $final_path 52 | } 53 | 54 | #================================================= 55 | # EXPERIMENTAL HELPERS 56 | #================================================= 57 | 58 | #================================================= 59 | # FUTURE OFFICIAL HELPERS 60 | #================================================= 61 | -------------------------------------------------------------------------------- /scripts/backup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #================================================= 4 | # GENERIC START 5 | #================================================= 6 | # IMPORT GENERIC HELPERS 7 | #================================================= 8 | 9 | #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts 10 | source ../settings/scripts/_common.sh 11 | source /usr/share/yunohost/helpers 12 | 13 | #================================================= 14 | # MANAGE SCRIPT FAILURE 15 | #================================================= 16 | # Exit if an error occurs during the execution of the script 17 | ynh_abort_if_errors 18 | 19 | #================================================= 20 | # LOAD SETTINGS 21 | #================================================= 22 | ynh_print_info --message="Loading installation settings..." 23 | 24 | app=$YNH_APP_INSTANCE_NAME 25 | 26 | final_path=$(ynh_app_setting_get --app=$app --key=final_path) 27 | domain=$(ynh_app_setting_get --app=$app --key=domain) 28 | db_name=$(ynh_app_setting_get --app=$app --key=db_name) 29 | 30 | #================================================= 31 | # STANDARD BACKUP STEPS 32 | #================================================= 33 | # BACKUP THE APP MAIN DIR 34 | #================================================= 35 | 36 | ynh_backup --src_path="$final_path" 37 | 38 | #================================================= 39 | # BACKUP THE NGINX CONFIGURATION 40 | #================================================= 41 | 42 | ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" 43 | 44 | #================================================= 45 | # SPECIFIC BACKUP 46 | #================================================= 47 | 48 | ynh_backup --src_path="/etc/systemd/system/$app.service" 49 | 50 | #================================================= 51 | # BACKUP THE MYSQL DATABASE 52 | #================================================= 53 | ynh_print_info --message="Backing up the MySQL database..." 54 | 55 | ynh_mysql_dump_db --database="$db_name" > db.sql 56 | 57 | #================================================= 58 | # END OF SCRIPT 59 | #================================================= 60 | 61 | ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." 62 | -------------------------------------------------------------------------------- /sources/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.mako.py 3 | local 4 | *.egg-info 5 | *.swp 6 | \.coverage 7 | *~ 8 | nosetests.xml 9 | syncserver.db 10 | -------------------------------------------------------------------------------- /sources/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | python: 4 | - "2.6" 5 | - "2.7" 6 | 7 | notifications: 8 | email: 9 | - rfkelly@mozilla.com 10 | irc: 11 | channels: 12 | - "irc.mozilla.org#services-dev" 13 | use_notice: false 14 | skip_join: false 15 | 16 | install: 17 | - make build 18 | 19 | script: 20 | - make test 21 | -------------------------------------------------------------------------------- /sources/homepage.patch: -------------------------------------------------------------------------------- 1 | diff -Naur a/__init__.py b/__init__.py 2 | --- a/__init__.py 2018-08-22 17:54:00.369070610 +0200 3 | +++ b/__init__.py 2018-08-22 20:11:39.861463512 +0200 4 | @@ -11,6 +11,10 @@ 5 | from pyramid.response import Response 6 | from pyramid.events import NewRequest, subscriber 7 | 8 | +from pyramid.static import static_view 9 | +from pyramid.view import view_config 10 | +from pyramid.renderers import render, render_to_response 11 | + 12 | try: 13 | import requests.packages.urllib3.contrib.pyopenssl 14 | HAS_PYOPENSSL = True 15 | @@ -135,13 +139,27 @@ 16 | config.scan("syncserver", ignore=["syncserver.wsgi_app"]) 17 | config.include("syncstorage", route_prefix="/storage") 18 | config.include("tokenserver", route_prefix="/token") 19 | + config.include('pyramid_chameleon') 20 | 21 | - # Add a top-level "it works!" view. 22 | - def itworks(request): 23 | - return Response("it works!") 24 | - 25 | - config.add_route('itworks', '/') 26 | - config.add_view(itworks, route_name='itworks') 27 | + # Add a top-level explaination view. 28 | + # First view, available at http://localhost:6543/ 29 | + def page(request): 30 | + result = render('page/index.pt', 31 | + {'public_url':public_url}, 32 | + request=request) 33 | + response = Response(result) 34 | + return response 35 | + config.add_route('page', '/') 36 | + config.add_view(page, route_name='page') 37 | + 38 | + www = static_view( 39 | + os.path.realpath(os.path.dirname(__file__)+"/page/"), 40 | + use_subpath=True 41 | + ) 42 | + # Documentation for Hybrid routing can be found here 43 | + # http://docs.pylonsproject.org/projects/pyramid/en/1.0-branch/narr/hybrid.html#using-subpath-in-a-route-pattern 44 | + config.add_route('index', '/*subpath', 'www') # subpath is a reserved word 45 | + config.add_view(www, route_name='index') 46 | 47 | 48 | def import_settings_from_environment_variables(settings, environ=None): 49 | -------------------------------------------------------------------------------- /sources/page/media/fonts/opensans-bold.5cf854f3d1c0.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/fonts/opensans-bold.5cf854f3d1c0.woff2 -------------------------------------------------------------------------------- /sources/page/media/fonts/opensans-italic.c86748d08341.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/fonts/opensans-italic.c86748d08341.woff2 -------------------------------------------------------------------------------- /sources/page/media/fonts/opensans-light.2120033991a4.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/fonts/opensans-light.2120033991a4.woff2 -------------------------------------------------------------------------------- /sources/page/media/fonts/opensans-lightitalic.580ce2d5ac1d.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/fonts/opensans-lightitalic.580ce2d5ac1d.woff2 -------------------------------------------------------------------------------- /sources/page/media/fonts/opensans-regular.668362de763a.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/fonts/opensans-regular.668362de763a.woff2 -------------------------------------------------------------------------------- /sources/page/media/img/firefox/family/nav-sprite.56fbf5a8d218.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/img/firefox/family/nav-sprite.56fbf5a8d218.png -------------------------------------------------------------------------------- /sources/page/media/img/firefox/sync/device-lineup.a60618c7dacb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/img/firefox/sync/device-lineup.a60618c7dacb.png -------------------------------------------------------------------------------- /sources/page/media/img/firefox/sync/icons.b80c6430793b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/img/firefox/sync/icons.b80c6430793b.png -------------------------------------------------------------------------------- /sources/page/media/img/sandstone/bg-gradient-sky.7ea325995978.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/img/sandstone/bg-gradient-sky.7ea325995978.png -------------------------------------------------------------------------------- /sources/page/media/img/sandstone/footer-mozilla.fafef0912042.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/img/sandstone/footer-mozilla.fafef0912042.png -------------------------------------------------------------------------------- /sources/page/media/img/sandstone/grain.855f29e0c686.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/img/sandstone/grain.855f29e0c686.png -------------------------------------------------------------------------------- /sources/page/media/img/tabzilla/tabzilla-static.953a65a1f4a4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/media/img/tabzilla/tabzilla-static.953a65a1f4a4.png -------------------------------------------------------------------------------- /sources/page/sync_files/btn-google-play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/page/sync_files/btn-google-play.png -------------------------------------------------------------------------------- /sources/page/sync_files/gtm-snippet-bundle.js: -------------------------------------------------------------------------------- 1 | (function(){var e=document.getElementsByTagName("html")[0].getAttribute("data-gtm-container-id");typeof window._dntEnabled=="function"&&!window._dntEnabled()&&e&&function(e,t,n,r,i,s,o,u,a,f){e[r]=e[r]||[],e[r].push({"gtm.start":(new Date).getTime(),event:"gtm.js"}),o=t.getElementsByTagName(n)[0],a=i.length,f="//www.googletagmanager.com/gtm.js?id=@&l="+(r||"dataLayer");while(a--)s=t.createElement(n),s.async=!0,s.src=f.replace("@",i[a]),o.parentNode.insertBefore(s,o)}(window,document,"script","dataLayer",[e])})(); 2 | -------------------------------------------------------------------------------- /sources/pip_20.1/__init__.py: -------------------------------------------------------------------------------- 1 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 2 | 3 | if MYPY_CHECK_RUNNING: 4 | from typing import List, Optional 5 | 6 | 7 | __version__ = "20.1.1" 8 | 9 | 10 | def main(args=None): 11 | # type: (Optional[List[str]]) -> int 12 | """This is an internal API only meant for use by pip's own console scripts. 13 | 14 | For additional details, see https://github.com/pypa/pip/issues/7498. 15 | """ 16 | from pip._internal.utils.entrypoints import _wrapper 17 | 18 | return _wrapper(args) 19 | -------------------------------------------------------------------------------- /sources/pip_20.1/__main__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | import sys 5 | 6 | # Remove '' and current working directory from the first entry 7 | # of sys.path, if present to avoid using current directory 8 | # in pip commands check, freeze, install, list and show, 9 | # when invoked as python -m pip 10 | if sys.path[0] in ('', os.getcwd()): 11 | sys.path.pop(0) 12 | 13 | # If we are running from a wheel, add the wheel to sys.path 14 | # This allows the usage python pip-*.whl/pip install pip-*.whl 15 | if __package__ == '': 16 | # __file__ is pip-*.whl/pip/__main__.py 17 | # first dirname call strips of '/__main__.py', second strips off '/pip' 18 | # Resulting path is the name of the wheel itself 19 | # Add that to sys.path so we can import pip 20 | path = os.path.dirname(os.path.dirname(__file__)) 21 | sys.path.insert(0, path) 22 | 23 | from pip._internal.cli.main import main as _main # isort:skip # noqa 24 | 25 | if __name__ == '__main__': 26 | sys.exit(_main()) 27 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/__init__.py: -------------------------------------------------------------------------------- 1 | import pip._internal.utils.inject_securetransport # noqa 2 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 3 | 4 | if MYPY_CHECK_RUNNING: 5 | from typing import Optional, List 6 | 7 | 8 | def main(args=None): 9 | # type: (Optional[List[str]]) -> int 10 | """This is preserved for old console scripts that may still be referencing 11 | it. 12 | 13 | For additional details, see https://github.com/pypa/pip/issues/7498. 14 | """ 15 | from pip._internal.utils.entrypoints import _wrapper 16 | 17 | return _wrapper(args) 18 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/cli/__init__.py: -------------------------------------------------------------------------------- 1 | """Subpackage containing all of pip's command line interface related code 2 | """ 3 | 4 | # This file intentionally does not import submodules 5 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/cli/command_context.py: -------------------------------------------------------------------------------- 1 | from contextlib import contextmanager 2 | 3 | from pip._vendor.contextlib2 import ExitStack 4 | 5 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 6 | 7 | if MYPY_CHECK_RUNNING: 8 | from typing import Iterator, ContextManager, TypeVar 9 | 10 | _T = TypeVar('_T', covariant=True) 11 | 12 | 13 | class CommandContextMixIn(object): 14 | def __init__(self): 15 | # type: () -> None 16 | super(CommandContextMixIn, self).__init__() 17 | self._in_main_context = False 18 | self._main_context = ExitStack() 19 | 20 | @contextmanager 21 | def main_context(self): 22 | # type: () -> Iterator[None] 23 | assert not self._in_main_context 24 | 25 | self._in_main_context = True 26 | try: 27 | with self._main_context: 28 | yield 29 | finally: 30 | self._in_main_context = False 31 | 32 | def enter_context(self, context_provider): 33 | # type: (ContextManager[_T]) -> _T 34 | assert self._in_main_context 35 | 36 | return self._main_context.enter_context(context_provider) 37 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/cli/main.py: -------------------------------------------------------------------------------- 1 | """Primary application entrypoint. 2 | """ 3 | from __future__ import absolute_import 4 | 5 | import locale 6 | import logging 7 | import os 8 | import sys 9 | 10 | from pip._internal.cli.autocompletion import autocomplete 11 | from pip._internal.cli.main_parser import parse_command 12 | from pip._internal.commands import create_command 13 | from pip._internal.exceptions import PipError 14 | from pip._internal.utils import deprecation 15 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 16 | 17 | if MYPY_CHECK_RUNNING: 18 | from typing import List, Optional 19 | 20 | logger = logging.getLogger(__name__) 21 | 22 | 23 | # Do not import and use main() directly! Using it directly is actively 24 | # discouraged by pip's maintainers. The name, location and behavior of 25 | # this function is subject to change, so calling it directly is not 26 | # portable across different pip versions. 27 | 28 | # In addition, running pip in-process is unsupported and unsafe. This is 29 | # elaborated in detail at 30 | # https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program. 31 | # That document also provides suggestions that should work for nearly 32 | # all users that are considering importing and using main() directly. 33 | 34 | # However, we know that certain users will still want to invoke pip 35 | # in-process. If you understand and accept the implications of using pip 36 | # in an unsupported manner, the best approach is to use runpy to avoid 37 | # depending on the exact location of this entry point. 38 | 39 | # The following example shows how to use runpy to invoke pip in that 40 | # case: 41 | # 42 | # sys.argv = ["pip", your, args, here] 43 | # runpy.run_module("pip", run_name="__main__") 44 | # 45 | # Note that this will exit the process after running, unlike a direct 46 | # call to main. As it is not safe to do any processing after calling 47 | # main, this should not be an issue in practice. 48 | 49 | def main(args=None): 50 | # type: (Optional[List[str]]) -> int 51 | if args is None: 52 | args = sys.argv[1:] 53 | 54 | # Configure our deprecation warnings to be sent through loggers 55 | deprecation.install_warning_logger() 56 | 57 | autocomplete() 58 | 59 | try: 60 | cmd_name, cmd_args = parse_command(args) 61 | except PipError as exc: 62 | sys.stderr.write("ERROR: {}".format(exc)) 63 | sys.stderr.write(os.linesep) 64 | sys.exit(1) 65 | 66 | # Needed for locale.getpreferredencoding(False) to work 67 | # in pip._internal.utils.encoding.auto_decode 68 | try: 69 | locale.setlocale(locale.LC_ALL, '') 70 | except locale.Error as e: 71 | # setlocale can apparently crash if locale are uninitialized 72 | logger.debug("Ignoring error %s when setting locale", e) 73 | command = create_command(cmd_name, isolated=("--isolated" in cmd_args)) 74 | 75 | return command.main(cmd_args) 76 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/cli/status_codes.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | SUCCESS = 0 4 | ERROR = 1 5 | UNKNOWN_ERROR = 2 6 | VIRTUALENV_NOT_FOUND = 3 7 | PREVIOUS_BUILD_DIR_ERROR = 4 8 | NO_MATCHES_FOUND = 23 9 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/commands/check.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from pip._internal.cli.base_command import Command 4 | from pip._internal.cli.status_codes import ERROR, SUCCESS 5 | from pip._internal.operations.check import ( 6 | check_package_set, 7 | create_package_set_from_installed, 8 | ) 9 | from pip._internal.utils.misc import write_output 10 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 11 | 12 | logger = logging.getLogger(__name__) 13 | 14 | if MYPY_CHECK_RUNNING: 15 | from typing import List, Any 16 | from optparse import Values 17 | 18 | 19 | class CheckCommand(Command): 20 | """Verify installed packages have compatible dependencies.""" 21 | 22 | usage = """ 23 | %prog [options]""" 24 | 25 | def run(self, options, args): 26 | # type: (Values, List[Any]) -> int 27 | 28 | package_set, parsing_probs = create_package_set_from_installed() 29 | missing, conflicting = check_package_set(package_set) 30 | 31 | for project_name in missing: 32 | version = package_set[project_name].version 33 | for dependency in missing[project_name]: 34 | write_output( 35 | "%s %s requires %s, which is not installed.", 36 | project_name, version, dependency[0], 37 | ) 38 | 39 | for project_name in conflicting: 40 | version = package_set[project_name].version 41 | for dep_name, dep_version, req in conflicting[project_name]: 42 | write_output( 43 | "%s %s has requirement %s, but you have %s %s.", 44 | project_name, version, req, dep_name, dep_version, 45 | ) 46 | 47 | if missing or conflicting or parsing_probs: 48 | return ERROR 49 | else: 50 | write_output("No broken requirements found.") 51 | return SUCCESS 52 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/commands/hash.py: -------------------------------------------------------------------------------- 1 | # The following comment should be removed at some point in the future. 2 | # mypy: disallow-untyped-defs=False 3 | 4 | from __future__ import absolute_import 5 | 6 | import hashlib 7 | import logging 8 | import sys 9 | 10 | from pip._internal.cli.base_command import Command 11 | from pip._internal.cli.status_codes import ERROR 12 | from pip._internal.utils.hashes import FAVORITE_HASH, STRONG_HASHES 13 | from pip._internal.utils.misc import read_chunks, write_output 14 | 15 | logger = logging.getLogger(__name__) 16 | 17 | 18 | class HashCommand(Command): 19 | """ 20 | Compute a hash of a local package archive. 21 | 22 | These can be used with --hash in a requirements file to do repeatable 23 | installs. 24 | """ 25 | 26 | usage = '%prog [options] ...' 27 | ignore_require_venv = True 28 | 29 | def __init__(self, *args, **kw): 30 | super(HashCommand, self).__init__(*args, **kw) 31 | self.cmd_opts.add_option( 32 | '-a', '--algorithm', 33 | dest='algorithm', 34 | choices=STRONG_HASHES, 35 | action='store', 36 | default=FAVORITE_HASH, 37 | help='The hash algorithm to use: one of {}'.format( 38 | ', '.join(STRONG_HASHES))) 39 | self.parser.insert_option_group(0, self.cmd_opts) 40 | 41 | def run(self, options, args): 42 | if not args: 43 | self.parser.print_usage(sys.stderr) 44 | return ERROR 45 | 46 | algorithm = options.algorithm 47 | for path in args: 48 | write_output('%s:\n--hash=%s:%s', 49 | path, algorithm, _hash_of_file(path, algorithm)) 50 | 51 | 52 | def _hash_of_file(path, algorithm): 53 | """Return the hash digest of a file.""" 54 | with open(path, 'rb') as archive: 55 | hash = hashlib.new(algorithm) 56 | for chunk in read_chunks(archive): 57 | hash.update(chunk) 58 | return hash.hexdigest() 59 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/commands/help.py: -------------------------------------------------------------------------------- 1 | # The following comment should be removed at some point in the future. 2 | # mypy: disallow-untyped-defs=False 3 | 4 | from __future__ import absolute_import 5 | 6 | from pip._internal.cli.base_command import Command 7 | from pip._internal.cli.status_codes import SUCCESS 8 | from pip._internal.exceptions import CommandError 9 | 10 | 11 | class HelpCommand(Command): 12 | """Show help for commands""" 13 | 14 | usage = """ 15 | %prog """ 16 | ignore_require_venv = True 17 | 18 | def run(self, options, args): 19 | from pip._internal.commands import ( 20 | commands_dict, create_command, get_similar_commands, 21 | ) 22 | 23 | try: 24 | # 'pip help' with no args is handled by pip.__init__.parseopt() 25 | cmd_name = args[0] # the command we need help for 26 | except IndexError: 27 | return SUCCESS 28 | 29 | if cmd_name not in commands_dict: 30 | guess = get_similar_commands(cmd_name) 31 | 32 | msg = ['unknown command "{}"'.format(cmd_name)] 33 | if guess: 34 | msg.append('maybe you meant "{}"'.format(guess)) 35 | 36 | raise CommandError(' - '.join(msg)) 37 | 38 | command = create_command(cmd_name) 39 | command.parser.print_help() 40 | 41 | return SUCCESS 42 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/distributions/__init__.py: -------------------------------------------------------------------------------- 1 | from pip._internal.distributions.sdist import SourceDistribution 2 | from pip._internal.distributions.wheel import WheelDistribution 3 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 4 | 5 | if MYPY_CHECK_RUNNING: 6 | from pip._internal.distributions.base import AbstractDistribution 7 | from pip._internal.req.req_install import InstallRequirement 8 | 9 | 10 | def make_distribution_for_install_requirement(install_req): 11 | # type: (InstallRequirement) -> AbstractDistribution 12 | """Returns a Distribution for the given InstallRequirement 13 | """ 14 | # Editable requirements will always be source distributions. They use the 15 | # legacy logic until we create a modern standard for them. 16 | if install_req.editable: 17 | return SourceDistribution(install_req) 18 | 19 | # If it's a wheel, it's a WheelDistribution 20 | if install_req.is_wheel: 21 | return WheelDistribution(install_req) 22 | 23 | # Otherwise, a SourceDistribution 24 | return SourceDistribution(install_req) 25 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/distributions/base.py: -------------------------------------------------------------------------------- 1 | import abc 2 | 3 | from pip._vendor.six import add_metaclass 4 | 5 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 6 | 7 | if MYPY_CHECK_RUNNING: 8 | from typing import Optional 9 | 10 | from pip._vendor.pkg_resources import Distribution 11 | from pip._internal.req import InstallRequirement 12 | from pip._internal.index.package_finder import PackageFinder 13 | 14 | 15 | @add_metaclass(abc.ABCMeta) 16 | class AbstractDistribution(object): 17 | """A base class for handling installable artifacts. 18 | 19 | The requirements for anything installable are as follows: 20 | 21 | - we must be able to determine the requirement name 22 | (or we can't correctly handle the non-upgrade case). 23 | 24 | - for packages with setup requirements, we must also be able 25 | to determine their requirements without installing additional 26 | packages (for the same reason as run-time dependencies) 27 | 28 | - we must be able to create a Distribution object exposing the 29 | above metadata. 30 | """ 31 | 32 | def __init__(self, req): 33 | # type: (InstallRequirement) -> None 34 | super(AbstractDistribution, self).__init__() 35 | self.req = req 36 | 37 | @abc.abstractmethod 38 | def get_pkg_resources_distribution(self): 39 | # type: () -> Optional[Distribution] 40 | raise NotImplementedError() 41 | 42 | @abc.abstractmethod 43 | def prepare_distribution_metadata(self, finder, build_isolation): 44 | # type: (PackageFinder, bool) -> None 45 | raise NotImplementedError() 46 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/distributions/installed.py: -------------------------------------------------------------------------------- 1 | from pip._internal.distributions.base import AbstractDistribution 2 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 3 | 4 | if MYPY_CHECK_RUNNING: 5 | from typing import Optional 6 | 7 | from pip._vendor.pkg_resources import Distribution 8 | from pip._internal.index.package_finder import PackageFinder 9 | 10 | 11 | class InstalledDistribution(AbstractDistribution): 12 | """Represents an installed package. 13 | 14 | This does not need any preparation as the required information has already 15 | been computed. 16 | """ 17 | 18 | def get_pkg_resources_distribution(self): 19 | # type: () -> Optional[Distribution] 20 | return self.req.satisfied_by 21 | 22 | def prepare_distribution_metadata(self, finder, build_isolation): 23 | # type: (PackageFinder, bool) -> None 24 | pass 25 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/distributions/wheel.py: -------------------------------------------------------------------------------- 1 | from zipfile import ZipFile 2 | 3 | from pip._internal.distributions.base import AbstractDistribution 4 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 5 | from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel 6 | 7 | if MYPY_CHECK_RUNNING: 8 | from pip._vendor.pkg_resources import Distribution 9 | from pip._internal.index.package_finder import PackageFinder 10 | 11 | 12 | class WheelDistribution(AbstractDistribution): 13 | """Represents a wheel distribution. 14 | 15 | This does not need any preparation as wheels can be directly unpacked. 16 | """ 17 | 18 | def get_pkg_resources_distribution(self): 19 | # type: () -> Distribution 20 | """Loads the metadata from the wheel file into memory and returns a 21 | Distribution that uses it, not relying on the wheel file or 22 | requirement. 23 | """ 24 | # Set as part of preparation during download. 25 | assert self.req.local_file_path 26 | # Wheels are never unnamed. 27 | assert self.req.name 28 | 29 | with ZipFile(self.req.local_file_path, allowZip64=True) as z: 30 | return pkg_resources_distribution_for_wheel( 31 | z, self.req.name, self.req.local_file_path 32 | ) 33 | 34 | def prepare_distribution_metadata(self, finder, build_isolation): 35 | # type: (PackageFinder, bool) -> None 36 | pass 37 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/index/__init__.py: -------------------------------------------------------------------------------- 1 | """Index interaction code 2 | """ 3 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/main.py: -------------------------------------------------------------------------------- 1 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 2 | 3 | if MYPY_CHECK_RUNNING: 4 | from typing import Optional, List 5 | 6 | 7 | def main(args=None): 8 | # type: (Optional[List[str]]) -> int 9 | """This is preserved for old console scripts that may still be referencing 10 | it. 11 | 12 | For additional details, see https://github.com/pypa/pip/issues/7498. 13 | """ 14 | from pip._internal.utils.entrypoints import _wrapper 15 | 16 | return _wrapper(args) 17 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/models/__init__.py: -------------------------------------------------------------------------------- 1 | """A package that contains models that represent entities. 2 | """ 3 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/models/candidate.py: -------------------------------------------------------------------------------- 1 | from pip._vendor.packaging.version import parse as parse_version 2 | 3 | from pip._internal.utils.models import KeyBasedCompareMixin 4 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 5 | 6 | if MYPY_CHECK_RUNNING: 7 | from pip._vendor.packaging.version import _BaseVersion 8 | from pip._internal.models.link import Link 9 | 10 | 11 | class InstallationCandidate(KeyBasedCompareMixin): 12 | """Represents a potential "candidate" for installation. 13 | """ 14 | 15 | def __init__(self, name, version, link): 16 | # type: (str, str, Link) -> None 17 | self.name = name 18 | self.version = parse_version(version) # type: _BaseVersion 19 | self.link = link 20 | 21 | super(InstallationCandidate, self).__init__( 22 | key=(self.name, self.version, self.link), 23 | defining_class=InstallationCandidate 24 | ) 25 | 26 | def __repr__(self): 27 | # type: () -> str 28 | return "".format( 29 | self.name, self.version, self.link, 30 | ) 31 | 32 | def __str__(self): 33 | # type: () -> str 34 | return '{!r} candidate (version {} at {})'.format( 35 | self.name, self.version, self.link, 36 | ) 37 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/models/format_control.py: -------------------------------------------------------------------------------- 1 | # The following comment should be removed at some point in the future. 2 | # mypy: strict-optional=False 3 | 4 | from pip._vendor.packaging.utils import canonicalize_name 5 | 6 | from pip._internal.exceptions import CommandError 7 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 8 | 9 | if MYPY_CHECK_RUNNING: 10 | from typing import Optional, Set, FrozenSet 11 | 12 | 13 | class FormatControl(object): 14 | """Helper for managing formats from which a package can be installed. 15 | """ 16 | 17 | def __init__(self, no_binary=None, only_binary=None): 18 | # type: (Optional[Set[str]], Optional[Set[str]]) -> None 19 | if no_binary is None: 20 | no_binary = set() 21 | if only_binary is None: 22 | only_binary = set() 23 | 24 | self.no_binary = no_binary 25 | self.only_binary = only_binary 26 | 27 | def __eq__(self, other): 28 | # type: (object) -> bool 29 | return self.__dict__ == other.__dict__ 30 | 31 | def __ne__(self, other): 32 | # type: (object) -> bool 33 | return not self.__eq__(other) 34 | 35 | def __repr__(self): 36 | # type: () -> str 37 | return "{}({}, {})".format( 38 | self.__class__.__name__, 39 | self.no_binary, 40 | self.only_binary 41 | ) 42 | 43 | @staticmethod 44 | def handle_mutual_excludes(value, target, other): 45 | # type: (str, Optional[Set[str]], Optional[Set[str]]) -> None 46 | if value.startswith('-'): 47 | raise CommandError( 48 | "--no-binary / --only-binary option requires 1 argument." 49 | ) 50 | new = value.split(',') 51 | while ':all:' in new: 52 | other.clear() 53 | target.clear() 54 | target.add(':all:') 55 | del new[:new.index(':all:') + 1] 56 | # Without a none, we want to discard everything as :all: covers it 57 | if ':none:' not in new: 58 | return 59 | for name in new: 60 | if name == ':none:': 61 | target.clear() 62 | continue 63 | name = canonicalize_name(name) 64 | other.discard(name) 65 | target.add(name) 66 | 67 | def get_allowed_formats(self, canonical_name): 68 | # type: (str) -> FrozenSet[str] 69 | result = {"binary", "source"} 70 | if canonical_name in self.only_binary: 71 | result.discard('source') 72 | elif canonical_name in self.no_binary: 73 | result.discard('binary') 74 | elif ':all:' in self.only_binary: 75 | result.discard('source') 76 | elif ':all:' in self.no_binary: 77 | result.discard('binary') 78 | return frozenset(result) 79 | 80 | def disallow_binaries(self): 81 | # type: () -> None 82 | self.handle_mutual_excludes( 83 | ':all:', self.no_binary, self.only_binary, 84 | ) 85 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/models/index.py: -------------------------------------------------------------------------------- 1 | from pip._vendor.six.moves.urllib import parse as urllib_parse 2 | 3 | 4 | class PackageIndex(object): 5 | """Represents a Package Index and provides easier access to endpoints 6 | """ 7 | 8 | def __init__(self, url, file_storage_domain): 9 | # type: (str, str) -> None 10 | super(PackageIndex, self).__init__() 11 | self.url = url 12 | self.netloc = urllib_parse.urlsplit(url).netloc 13 | self.simple_url = self._url_for_path('simple') 14 | self.pypi_url = self._url_for_path('pypi') 15 | 16 | # This is part of a temporary hack used to block installs of PyPI 17 | # packages which depend on external urls only necessary until PyPI can 18 | # block such packages themselves 19 | self.file_storage_domain = file_storage_domain 20 | 21 | def _url_for_path(self, path): 22 | # type: (str) -> str 23 | return urllib_parse.urljoin(self.url, path) 24 | 25 | 26 | PyPI = PackageIndex( 27 | 'https://pypi.org/', file_storage_domain='files.pythonhosted.org' 28 | ) 29 | TestPyPI = PackageIndex( 30 | 'https://test.pypi.org/', file_storage_domain='test-files.pythonhosted.org' 31 | ) 32 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/models/scheme.py: -------------------------------------------------------------------------------- 1 | """ 2 | For types associated with installation schemes. 3 | 4 | For a general overview of available schemes and their context, see 5 | https://docs.python.org/3/install/index.html#alternate-installation. 6 | """ 7 | 8 | 9 | class Scheme(object): 10 | """A Scheme holds paths which are used as the base directories for 11 | artifacts associated with a Python package. 12 | """ 13 | def __init__( 14 | self, 15 | platlib, # type: str 16 | purelib, # type: str 17 | headers, # type: str 18 | scripts, # type: str 19 | data, # type: str 20 | ): 21 | self.platlib = platlib 22 | self.purelib = purelib 23 | self.headers = headers 24 | self.scripts = scripts 25 | self.data = data 26 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/models/selection_prefs.py: -------------------------------------------------------------------------------- 1 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 2 | 3 | if MYPY_CHECK_RUNNING: 4 | from typing import Optional 5 | from pip._internal.models.format_control import FormatControl 6 | 7 | 8 | class SelectionPreferences(object): 9 | 10 | """ 11 | Encapsulates the candidate selection preferences for downloading 12 | and installing files. 13 | """ 14 | 15 | # Don't include an allow_yanked default value to make sure each call 16 | # site considers whether yanked releases are allowed. This also causes 17 | # that decision to be made explicit in the calling code, which helps 18 | # people when reading the code. 19 | def __init__( 20 | self, 21 | allow_yanked, # type: bool 22 | allow_all_prereleases=False, # type: bool 23 | format_control=None, # type: Optional[FormatControl] 24 | prefer_binary=False, # type: bool 25 | ignore_requires_python=None, # type: Optional[bool] 26 | ): 27 | # type: (...) -> None 28 | """Create a SelectionPreferences object. 29 | 30 | :param allow_yanked: Whether files marked as yanked (in the sense 31 | of PEP 592) are permitted to be candidates for install. 32 | :param format_control: A FormatControl object or None. Used to control 33 | the selection of source packages / binary packages when consulting 34 | the index and links. 35 | :param prefer_binary: Whether to prefer an old, but valid, binary 36 | dist over a new source dist. 37 | :param ignore_requires_python: Whether to ignore incompatible 38 | "Requires-Python" values in links. Defaults to False. 39 | """ 40 | if ignore_requires_python is None: 41 | ignore_requires_python = False 42 | 43 | self.allow_yanked = allow_yanked 44 | self.allow_all_prereleases = allow_all_prereleases 45 | self.format_control = format_control 46 | self.prefer_binary = prefer_binary 47 | self.ignore_requires_python = ignore_requires_python 48 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/models/wheel.py: -------------------------------------------------------------------------------- 1 | """Represents a wheel file and provides access to the various parts of the 2 | name that have meaning. 3 | """ 4 | import re 5 | 6 | from pip._vendor.packaging.tags import Tag 7 | 8 | from pip._internal.exceptions import InvalidWheelFilename 9 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 10 | 11 | if MYPY_CHECK_RUNNING: 12 | from typing import List 13 | 14 | 15 | class Wheel(object): 16 | """A wheel file""" 17 | 18 | wheel_file_re = re.compile( 19 | r"""^(?P(?P.+?)-(?P.*?)) 20 | ((-(?P\d[^-]*?))?-(?P.+?)-(?P.+?)-(?P.+?) 21 | \.whl|\.dist-info)$""", 22 | re.VERBOSE 23 | ) 24 | 25 | def __init__(self, filename): 26 | # type: (str) -> None 27 | """ 28 | :raises InvalidWheelFilename: when the filename is invalid for a wheel 29 | """ 30 | wheel_info = self.wheel_file_re.match(filename) 31 | if not wheel_info: 32 | raise InvalidWheelFilename( 33 | "{} is not a valid wheel filename.".format(filename) 34 | ) 35 | self.filename = filename 36 | self.name = wheel_info.group('name').replace('_', '-') 37 | # we'll assume "_" means "-" due to wheel naming scheme 38 | # (https://github.com/pypa/pip/issues/1150) 39 | self.version = wheel_info.group('ver').replace('_', '-') 40 | self.build_tag = wheel_info.group('build') 41 | self.pyversions = wheel_info.group('pyver').split('.') 42 | self.abis = wheel_info.group('abi').split('.') 43 | self.plats = wheel_info.group('plat').split('.') 44 | 45 | # All the tag combinations from this file 46 | self.file_tags = { 47 | Tag(x, y, z) for x in self.pyversions 48 | for y in self.abis for z in self.plats 49 | } 50 | 51 | def get_formatted_file_tags(self): 52 | # type: () -> List[str] 53 | """Return the wheel's tags as a sorted list of strings.""" 54 | return sorted(str(tag) for tag in self.file_tags) 55 | 56 | def support_index_min(self, tags): 57 | # type: (List[Tag]) -> int 58 | """Return the lowest index that one of the wheel's file_tag combinations 59 | achieves in the given list of supported tags. 60 | 61 | For example, if there are 8 supported tags and one of the file tags 62 | is first in the list, then return 0. 63 | 64 | :param tags: the PEP 425 tags to check the wheel against, in order 65 | with most preferred first. 66 | 67 | :raises ValueError: If none of the wheel's file tags match one of 68 | the supported tags. 69 | """ 70 | return min(tags.index(tag) for tag in self.file_tags if tag in tags) 71 | 72 | def supported(self, tags): 73 | # type: (List[Tag]) -> bool 74 | """Return whether the wheel is compatible with one of the given tags. 75 | 76 | :param tags: the PEP 425 tags to check the wheel against. 77 | """ 78 | return not self.file_tags.isdisjoint(tags) 79 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/network/__init__.py: -------------------------------------------------------------------------------- 1 | """Contains purely network-related utilities. 2 | """ 3 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/network/cache.py: -------------------------------------------------------------------------------- 1 | """HTTP cache implementation. 2 | """ 3 | 4 | # The following comment should be removed at some point in the future. 5 | # mypy: disallow-untyped-defs=False 6 | 7 | import os 8 | from contextlib import contextmanager 9 | 10 | from pip._vendor.cachecontrol.cache import BaseCache 11 | from pip._vendor.cachecontrol.caches import FileCache 12 | from pip._vendor.requests.models import Response 13 | 14 | from pip._internal.utils.filesystem import adjacent_tmp_file, replace 15 | from pip._internal.utils.misc import ensure_dir 16 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 17 | 18 | if MYPY_CHECK_RUNNING: 19 | from typing import Optional 20 | 21 | 22 | def is_from_cache(response): 23 | # type: (Response) -> bool 24 | return getattr(response, "from_cache", False) 25 | 26 | 27 | @contextmanager 28 | def suppressed_cache_errors(): 29 | """If we can't access the cache then we can just skip caching and process 30 | requests as if caching wasn't enabled. 31 | """ 32 | try: 33 | yield 34 | except (OSError, IOError): 35 | pass 36 | 37 | 38 | class SafeFileCache(BaseCache): 39 | """ 40 | A file based cache which is safe to use even when the target directory may 41 | not be accessible or writable. 42 | """ 43 | 44 | def __init__(self, directory): 45 | # type: (str) -> None 46 | assert directory is not None, "Cache directory must not be None." 47 | super(SafeFileCache, self).__init__() 48 | self.directory = directory 49 | 50 | def _get_cache_path(self, name): 51 | # type: (str) -> str 52 | # From cachecontrol.caches.file_cache.FileCache._fn, brought into our 53 | # class for backwards-compatibility and to avoid using a non-public 54 | # method. 55 | hashed = FileCache.encode(name) 56 | parts = list(hashed[:5]) + [hashed] 57 | return os.path.join(self.directory, *parts) 58 | 59 | def get(self, key): 60 | # type: (str) -> Optional[bytes] 61 | path = self._get_cache_path(key) 62 | with suppressed_cache_errors(): 63 | with open(path, 'rb') as f: 64 | return f.read() 65 | 66 | def set(self, key, value): 67 | # type: (str, bytes) -> None 68 | path = self._get_cache_path(key) 69 | with suppressed_cache_errors(): 70 | ensure_dir(os.path.dirname(path)) 71 | 72 | with adjacent_tmp_file(path) as f: 73 | f.write(value) 74 | 75 | replace(f.name, path) 76 | 77 | def delete(self, key): 78 | # type: (str) -> None 79 | path = self._get_cache_path(key) 80 | with suppressed_cache_errors(): 81 | os.remove(path) 82 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/network/utils.py: -------------------------------------------------------------------------------- 1 | from pip._vendor.requests.models import CONTENT_CHUNK_SIZE, Response 2 | 3 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 4 | 5 | if MYPY_CHECK_RUNNING: 6 | from typing import Iterator 7 | 8 | 9 | def response_chunks(response, chunk_size=CONTENT_CHUNK_SIZE): 10 | # type: (Response, int) -> Iterator[bytes] 11 | """Given a requests Response, provide the data chunks. 12 | """ 13 | try: 14 | # Special case for urllib3. 15 | for chunk in response.raw.stream( 16 | chunk_size, 17 | # We use decode_content=False here because we don't 18 | # want urllib3 to mess with the raw bytes we get 19 | # from the server. If we decompress inside of 20 | # urllib3 then we cannot verify the checksum 21 | # because the checksum will be of the compressed 22 | # file. This breakage will only occur if the 23 | # server adds a Content-Encoding header, which 24 | # depends on how the server was configured: 25 | # - Some servers will notice that the file isn't a 26 | # compressible file and will leave the file alone 27 | # and with an empty Content-Encoding 28 | # - Some servers will notice that the file is 29 | # already compressed and will leave the file 30 | # alone and will add a Content-Encoding: gzip 31 | # header 32 | # - Some servers won't notice anything at all and 33 | # will take a file that's already been compressed 34 | # and compress it again and set the 35 | # Content-Encoding: gzip header 36 | # 37 | # By setting this not to decode automatically we 38 | # hope to eliminate problems with the second case. 39 | decode_content=False, 40 | ): 41 | yield chunk 42 | except AttributeError: 43 | # Standard file-like object. 44 | while True: 45 | chunk = response.raw.read(chunk_size) 46 | if not chunk: 47 | break 48 | yield chunk 49 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/network/xmlrpc.py: -------------------------------------------------------------------------------- 1 | """xmlrpclib.Transport implementation 2 | """ 3 | 4 | # The following comment should be removed at some point in the future. 5 | # mypy: disallow-untyped-defs=False 6 | 7 | import logging 8 | 9 | from pip._vendor import requests 10 | # NOTE: XMLRPC Client is not annotated in typeshed as on 2017-07-17, which is 11 | # why we ignore the type on this import 12 | from pip._vendor.six.moves import xmlrpc_client # type: ignore 13 | from pip._vendor.six.moves.urllib import parse as urllib_parse 14 | 15 | logger = logging.getLogger(__name__) 16 | 17 | 18 | class PipXmlrpcTransport(xmlrpc_client.Transport): 19 | """Provide a `xmlrpclib.Transport` implementation via a `PipSession` 20 | object. 21 | """ 22 | 23 | def __init__(self, index_url, session, use_datetime=False): 24 | xmlrpc_client.Transport.__init__(self, use_datetime) 25 | index_parts = urllib_parse.urlparse(index_url) 26 | self._scheme = index_parts.scheme 27 | self._session = session 28 | 29 | def request(self, host, handler, request_body, verbose=False): 30 | parts = (self._scheme, host, handler, None, None, None) 31 | url = urllib_parse.urlunparse(parts) 32 | try: 33 | headers = {'Content-Type': 'text/xml'} 34 | response = self._session.post(url, data=request_body, 35 | headers=headers, stream=True) 36 | response.raise_for_status() 37 | self.verbose = verbose 38 | return self.parse_response(response.raw) 39 | except requests.HTTPError as exc: 40 | logger.critical( 41 | "HTTP error %s while getting %s", 42 | exc.response.status_code, url, 43 | ) 44 | raise 45 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/operations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_internal/operations/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/operations/build/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_internal/operations/build/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/operations/build/metadata.py: -------------------------------------------------------------------------------- 1 | """Metadata generation logic for source distributions. 2 | """ 3 | 4 | import logging 5 | import os 6 | 7 | from pip._internal.utils.subprocess import runner_with_spinner_message 8 | from pip._internal.utils.temp_dir import TempDirectory 9 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 10 | 11 | if MYPY_CHECK_RUNNING: 12 | from pip._internal.build_env import BuildEnvironment 13 | from pip._vendor.pep517.wrappers import Pep517HookCaller 14 | 15 | logger = logging.getLogger(__name__) 16 | 17 | 18 | def generate_metadata(build_env, backend): 19 | # type: (BuildEnvironment, Pep517HookCaller) -> str 20 | """Generate metadata using mechanisms described in PEP 517. 21 | 22 | Returns the generated metadata directory. 23 | """ 24 | metadata_tmpdir = TempDirectory( 25 | kind="modern-metadata", globally_managed=True 26 | ) 27 | 28 | metadata_dir = metadata_tmpdir.path 29 | 30 | with build_env: 31 | # Note that Pep517HookCaller implements a fallback for 32 | # prepare_metadata_for_build_wheel, so we don't have to 33 | # consider the possibility that this hook doesn't exist. 34 | runner = runner_with_spinner_message("Preparing wheel metadata") 35 | with backend.subprocess_runner(runner): 36 | distinfo_dir = backend.prepare_metadata_for_build_wheel( 37 | metadata_dir 38 | ) 39 | 40 | return os.path.join(metadata_dir, distinfo_dir) 41 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/operations/build/metadata_legacy.py: -------------------------------------------------------------------------------- 1 | """Metadata generation logic for legacy source distributions. 2 | """ 3 | 4 | import logging 5 | import os 6 | 7 | from pip._internal.exceptions import InstallationError 8 | from pip._internal.utils.setuptools_build import make_setuptools_egg_info_args 9 | from pip._internal.utils.subprocess import call_subprocess 10 | from pip._internal.utils.temp_dir import TempDirectory 11 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 12 | 13 | if MYPY_CHECK_RUNNING: 14 | from pip._internal.build_env import BuildEnvironment 15 | 16 | logger = logging.getLogger(__name__) 17 | 18 | 19 | def _find_egg_info(directory): 20 | # type: (str) -> str 21 | """Find an .egg-info subdirectory in `directory`. 22 | """ 23 | filenames = [ 24 | f for f in os.listdir(directory) if f.endswith(".egg-info") 25 | ] 26 | 27 | if not filenames: 28 | raise InstallationError( 29 | "No .egg-info directory found in {}".format(directory) 30 | ) 31 | 32 | if len(filenames) > 1: 33 | raise InstallationError( 34 | "More than one .egg-info directory found in {}".format( 35 | directory 36 | ) 37 | ) 38 | 39 | return os.path.join(directory, filenames[0]) 40 | 41 | 42 | def generate_metadata( 43 | build_env, # type: BuildEnvironment 44 | setup_py_path, # type: str 45 | source_dir, # type: str 46 | isolated, # type: bool 47 | details, # type: str 48 | ): 49 | # type: (...) -> str 50 | """Generate metadata using setup.py-based defacto mechanisms. 51 | 52 | Returns the generated metadata directory. 53 | """ 54 | logger.debug( 55 | 'Running setup.py (path:%s) egg_info for package %s', 56 | setup_py_path, details, 57 | ) 58 | 59 | egg_info_dir = TempDirectory( 60 | kind="pip-egg-info", globally_managed=True 61 | ).path 62 | 63 | args = make_setuptools_egg_info_args( 64 | setup_py_path, 65 | egg_info_dir=egg_info_dir, 66 | no_user_config=isolated, 67 | ) 68 | 69 | with build_env: 70 | call_subprocess( 71 | args, 72 | cwd=source_dir, 73 | command_desc='python setup.py egg_info', 74 | ) 75 | 76 | # Return the .egg-info directory. 77 | return _find_egg_info(egg_info_dir) 78 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/operations/build/wheel.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | 4 | from pip._internal.utils.subprocess import runner_with_spinner_message 5 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 6 | 7 | if MYPY_CHECK_RUNNING: 8 | from typing import List, Optional 9 | from pip._vendor.pep517.wrappers import Pep517HookCaller 10 | 11 | logger = logging.getLogger(__name__) 12 | 13 | 14 | def build_wheel_pep517( 15 | name, # type: str 16 | backend, # type: Pep517HookCaller 17 | metadata_directory, # type: str 18 | build_options, # type: List[str] 19 | tempd, # type: str 20 | ): 21 | # type: (...) -> Optional[str] 22 | """Build one InstallRequirement using the PEP 517 build process. 23 | 24 | Returns path to wheel if successfully built. Otherwise, returns None. 25 | """ 26 | assert metadata_directory is not None 27 | if build_options: 28 | # PEP 517 does not support --build-options 29 | logger.error('Cannot build wheel for %s using PEP 517 when ' 30 | '--build-option is present' % (name,)) 31 | return None 32 | try: 33 | logger.debug('Destination directory: %s', tempd) 34 | 35 | runner = runner_with_spinner_message( 36 | 'Building wheel for {} (PEP 517)'.format(name) 37 | ) 38 | with backend.subprocess_runner(runner): 39 | wheel_name = backend.build_wheel( 40 | tempd, 41 | metadata_directory=metadata_directory, 42 | ) 43 | except Exception: 44 | logger.error('Failed building wheel for %s', name) 45 | return None 46 | return os.path.join(tempd, wheel_name) 47 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/operations/install/__init__.py: -------------------------------------------------------------------------------- 1 | """For modules related to installing packages. 2 | """ 3 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/operations/install/editable_legacy.py: -------------------------------------------------------------------------------- 1 | """Legacy editable installation process, i.e. `setup.py develop`. 2 | """ 3 | import logging 4 | 5 | from pip._internal.utils.logging import indent_log 6 | from pip._internal.utils.setuptools_build import make_setuptools_develop_args 7 | from pip._internal.utils.subprocess import call_subprocess 8 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 9 | 10 | if MYPY_CHECK_RUNNING: 11 | from typing import List, Optional, Sequence 12 | 13 | from pip._internal.build_env import BuildEnvironment 14 | 15 | 16 | logger = logging.getLogger(__name__) 17 | 18 | 19 | def install_editable( 20 | install_options, # type: List[str] 21 | global_options, # type: Sequence[str] 22 | prefix, # type: Optional[str] 23 | home, # type: Optional[str] 24 | use_user_site, # type: bool 25 | name, # type: str 26 | setup_py_path, # type: str 27 | isolated, # type: bool 28 | build_env, # type: BuildEnvironment 29 | unpacked_source_directory, # type: str 30 | ): 31 | # type: (...) -> None 32 | """Install a package in editable mode. Most arguments are pass-through 33 | to setuptools. 34 | """ 35 | logger.info('Running setup.py develop for %s', name) 36 | 37 | args = make_setuptools_develop_args( 38 | setup_py_path, 39 | global_options=global_options, 40 | install_options=install_options, 41 | no_user_config=isolated, 42 | prefix=prefix, 43 | home=home, 44 | use_user_site=use_user_site, 45 | ) 46 | 47 | with indent_log(): 48 | with build_env: 49 | call_subprocess( 50 | args, 51 | cwd=unpacked_source_directory, 52 | ) 53 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/req/__init__.py: -------------------------------------------------------------------------------- 1 | # The following comment should be removed at some point in the future. 2 | # mypy: strict-optional=False 3 | 4 | from __future__ import absolute_import 5 | 6 | import logging 7 | 8 | from pip._internal.utils.logging import indent_log 9 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 10 | 11 | from .req_file import parse_requirements 12 | from .req_install import InstallRequirement 13 | from .req_set import RequirementSet 14 | 15 | if MYPY_CHECK_RUNNING: 16 | from typing import Any, List, Sequence 17 | 18 | __all__ = [ 19 | "RequirementSet", "InstallRequirement", 20 | "parse_requirements", "install_given_reqs", 21 | ] 22 | 23 | logger = logging.getLogger(__name__) 24 | 25 | 26 | class InstallationResult(object): 27 | def __init__(self, name): 28 | # type: (str) -> None 29 | self.name = name 30 | 31 | def __repr__(self): 32 | # type: () -> str 33 | return "InstallationResult(name={!r})".format(self.name) 34 | 35 | 36 | def install_given_reqs( 37 | to_install, # type: List[InstallRequirement] 38 | install_options, # type: List[str] 39 | global_options=(), # type: Sequence[str] 40 | *args, # type: Any 41 | **kwargs # type: Any 42 | ): 43 | # type: (...) -> List[InstallationResult] 44 | """ 45 | Install everything in the given list. 46 | 47 | (to be called after having downloaded and unpacked the packages) 48 | """ 49 | 50 | if to_install: 51 | logger.info( 52 | 'Installing collected packages: %s', 53 | ', '.join([req.name for req in to_install]), 54 | ) 55 | 56 | installed = [] 57 | 58 | with indent_log(): 59 | for requirement in to_install: 60 | if requirement.should_reinstall: 61 | logger.info('Attempting uninstall: %s', requirement.name) 62 | with indent_log(): 63 | uninstalled_pathset = requirement.uninstall( 64 | auto_confirm=True 65 | ) 66 | try: 67 | requirement.install( 68 | install_options, 69 | global_options, 70 | *args, 71 | **kwargs 72 | ) 73 | except Exception: 74 | should_rollback = ( 75 | requirement.should_reinstall and 76 | not requirement.install_succeeded 77 | ) 78 | # if install did not succeed, rollback previous uninstall 79 | if should_rollback: 80 | uninstalled_pathset.rollback() 81 | raise 82 | else: 83 | should_commit = ( 84 | requirement.should_reinstall and 85 | requirement.install_succeeded 86 | ) 87 | if should_commit: 88 | uninstalled_pathset.commit() 89 | 90 | installed.append(InstallationResult(requirement.name)) 91 | 92 | return installed 93 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/resolution/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_internal/resolution/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/resolution/base.py: -------------------------------------------------------------------------------- 1 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 2 | 3 | if MYPY_CHECK_RUNNING: 4 | from typing import Callable, List 5 | from pip._internal.req.req_install import InstallRequirement 6 | from pip._internal.req.req_set import RequirementSet 7 | 8 | InstallRequirementProvider = Callable[ 9 | [str, InstallRequirement], InstallRequirement 10 | ] 11 | 12 | 13 | class BaseResolver(object): 14 | def resolve(self, root_reqs, check_supported_wheels): 15 | # type: (List[InstallRequirement], bool) -> RequirementSet 16 | raise NotImplementedError() 17 | 18 | def get_installation_order(self, req_set): 19 | # type: (RequirementSet) -> List[InstallRequirement] 20 | raise NotImplementedError() 21 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/resolution/legacy/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_internal/resolution/legacy/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/resolution/resolvelib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_internal/resolution/resolvelib/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/resolution/resolvelib/base.py: -------------------------------------------------------------------------------- 1 | from pip._vendor.packaging.utils import canonicalize_name 2 | 3 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 4 | 5 | if MYPY_CHECK_RUNNING: 6 | from typing import Optional, Sequence, Set 7 | 8 | from pip._internal.req.req_install import InstallRequirement 9 | from pip._vendor.packaging.version import _BaseVersion 10 | 11 | 12 | def format_name(project, extras): 13 | # type: (str, Set[str]) -> str 14 | if not extras: 15 | return project 16 | canonical_extras = sorted(canonicalize_name(e) for e in extras) 17 | return "{}[{}]".format(project, ",".join(canonical_extras)) 18 | 19 | 20 | class Requirement(object): 21 | @property 22 | def name(self): 23 | # type: () -> str 24 | raise NotImplementedError("Subclass should override") 25 | 26 | def find_matches(self): 27 | # type: () -> Sequence[Candidate] 28 | raise NotImplementedError("Subclass should override") 29 | 30 | def is_satisfied_by(self, candidate): 31 | # type: (Candidate) -> bool 32 | return False 33 | 34 | 35 | class Candidate(object): 36 | @property 37 | def name(self): 38 | # type: () -> str 39 | raise NotImplementedError("Override in subclass") 40 | 41 | @property 42 | def version(self): 43 | # type: () -> _BaseVersion 44 | raise NotImplementedError("Override in subclass") 45 | 46 | def get_dependencies(self): 47 | # type: () -> Sequence[Requirement] 48 | raise NotImplementedError("Override in subclass") 49 | 50 | def get_install_requirement(self): 51 | # type: () -> Optional[InstallRequirement] 52 | raise NotImplementedError("Override in subclass") 53 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/resolution/resolvelib/provider.py: -------------------------------------------------------------------------------- 1 | from pip._vendor.resolvelib.providers import AbstractProvider 2 | 3 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 4 | 5 | if MYPY_CHECK_RUNNING: 6 | from typing import Any, Optional, Sequence, Tuple, Union 7 | 8 | from pip._internal.req.req_install import InstallRequirement 9 | 10 | from .base import Requirement, Candidate 11 | from .factory import Factory 12 | 13 | 14 | class PipProvider(AbstractProvider): 15 | def __init__( 16 | self, 17 | factory, # type: Factory 18 | ignore_dependencies, # type: bool 19 | ): 20 | # type: (...) -> None 21 | self._factory = factory 22 | self._ignore_dependencies = ignore_dependencies 23 | 24 | def get_install_requirement(self, c): 25 | # type: (Candidate) -> Optional[InstallRequirement] 26 | return c.get_install_requirement() 27 | 28 | def identify(self, dependency): 29 | # type: (Union[Requirement, Candidate]) -> str 30 | return dependency.name 31 | 32 | def get_preference( 33 | self, 34 | resolution, # type: Optional[Candidate] 35 | candidates, # type: Sequence[Candidate] 36 | information # type: Sequence[Tuple[Requirement, Candidate]] 37 | ): 38 | # type: (...) -> Any 39 | # Use the "usual" value for now 40 | return len(candidates) 41 | 42 | def find_matches(self, requirement): 43 | # type: (Requirement) -> Sequence[Candidate] 44 | return requirement.find_matches() 45 | 46 | def is_satisfied_by(self, requirement, candidate): 47 | # type: (Requirement, Candidate) -> bool 48 | return requirement.is_satisfied_by(candidate) 49 | 50 | def get_dependencies(self, candidate): 51 | # type: (Candidate) -> Sequence[Requirement] 52 | if self._ignore_dependencies: 53 | return [] 54 | return candidate.get_dependencies() 55 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_internal/utils/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/appdirs.py: -------------------------------------------------------------------------------- 1 | """ 2 | This code wraps the vendored appdirs module to so the return values are 3 | compatible for the current pip code base. 4 | 5 | The intention is to rewrite current usages gradually, keeping the tests pass, 6 | and eventually drop this after all usages are changed. 7 | """ 8 | 9 | from __future__ import absolute_import 10 | 11 | import os 12 | 13 | from pip._vendor import appdirs as _appdirs 14 | 15 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 16 | 17 | if MYPY_CHECK_RUNNING: 18 | from typing import List 19 | 20 | 21 | def user_cache_dir(appname): 22 | # type: (str) -> str 23 | return _appdirs.user_cache_dir(appname, appauthor=False) 24 | 25 | 26 | def user_config_dir(appname, roaming=True): 27 | # type: (str, bool) -> str 28 | path = _appdirs.user_config_dir(appname, appauthor=False, roaming=roaming) 29 | if _appdirs.system == "darwin" and not os.path.isdir(path): 30 | path = os.path.expanduser('~/.config/') 31 | if appname: 32 | path = os.path.join(path, appname) 33 | return path 34 | 35 | 36 | # for the discussion regarding site_config_dir locations 37 | # see 38 | def site_config_dirs(appname): 39 | # type: (str) -> List[str] 40 | dirval = _appdirs.site_config_dir(appname, appauthor=False, multipath=True) 41 | if _appdirs.system not in ["win32", "darwin"]: 42 | # always look in /etc directly as well 43 | return dirval.split(os.pathsep) + ['/etc'] 44 | return [dirval] 45 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/distutils_args.py: -------------------------------------------------------------------------------- 1 | from distutils.errors import DistutilsArgError 2 | from distutils.fancy_getopt import FancyGetopt 3 | 4 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 5 | 6 | if MYPY_CHECK_RUNNING: 7 | from typing import Dict, List 8 | 9 | 10 | _options = [ 11 | ("exec-prefix=", None, ""), 12 | ("home=", None, ""), 13 | ("install-base=", None, ""), 14 | ("install-data=", None, ""), 15 | ("install-headers=", None, ""), 16 | ("install-lib=", None, ""), 17 | ("install-platlib=", None, ""), 18 | ("install-purelib=", None, ""), 19 | ("install-scripts=", None, ""), 20 | ("prefix=", None, ""), 21 | ("root=", None, ""), 22 | ("user", None, ""), 23 | ] 24 | 25 | 26 | # typeshed doesn't permit Tuple[str, None, str], see python/typeshed#3469. 27 | _distutils_getopt = FancyGetopt(_options) # type: ignore 28 | 29 | 30 | def parse_distutils_args(args): 31 | # type: (List[str]) -> Dict[str, str] 32 | """Parse provided arguments, returning an object that has the 33 | matched arguments. 34 | 35 | Any unknown arguments are ignored. 36 | """ 37 | result = {} 38 | for arg in args: 39 | try: 40 | _, match = _distutils_getopt.getopt(args=[arg]) 41 | except DistutilsArgError: 42 | # We don't care about any other options, which here may be 43 | # considered unrecognized since our option list is not 44 | # exhaustive. 45 | pass 46 | else: 47 | result.update(match.__dict__) 48 | return result 49 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/encoding.py: -------------------------------------------------------------------------------- 1 | # The following comment should be removed at some point in the future. 2 | # mypy: strict-optional=False 3 | 4 | import codecs 5 | import locale 6 | import re 7 | import sys 8 | 9 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 10 | 11 | if MYPY_CHECK_RUNNING: 12 | from typing import List, Tuple, Text 13 | 14 | BOMS = [ 15 | (codecs.BOM_UTF8, 'utf-8'), 16 | (codecs.BOM_UTF16, 'utf-16'), 17 | (codecs.BOM_UTF16_BE, 'utf-16-be'), 18 | (codecs.BOM_UTF16_LE, 'utf-16-le'), 19 | (codecs.BOM_UTF32, 'utf-32'), 20 | (codecs.BOM_UTF32_BE, 'utf-32-be'), 21 | (codecs.BOM_UTF32_LE, 'utf-32-le'), 22 | ] # type: List[Tuple[bytes, Text]] 23 | 24 | ENCODING_RE = re.compile(br'coding[:=]\s*([-\w.]+)') 25 | 26 | 27 | def auto_decode(data): 28 | # type: (bytes) -> Text 29 | """Check a bytes string for a BOM to correctly detect the encoding 30 | 31 | Fallback to locale.getpreferredencoding(False) like open() on Python3""" 32 | for bom, encoding in BOMS: 33 | if data.startswith(bom): 34 | return data[len(bom):].decode(encoding) 35 | # Lets check the first two lines as in PEP263 36 | for line in data.split(b'\n')[:2]: 37 | if line[0:1] == b'#' and ENCODING_RE.search(line): 38 | encoding = ENCODING_RE.search(line).groups()[0].decode('ascii') 39 | return data.decode(encoding) 40 | return data.decode( 41 | locale.getpreferredencoding(False) or sys.getdefaultencoding(), 42 | ) 43 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/entrypoints.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from pip._internal.cli.main import main 4 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 5 | 6 | if MYPY_CHECK_RUNNING: 7 | from typing import Optional, List 8 | 9 | 10 | def _wrapper(args=None): 11 | # type: (Optional[List[str]]) -> int 12 | """Central wrapper for all old entrypoints. 13 | 14 | Historically pip has had several entrypoints defined. Because of issues 15 | arising from PATH, sys.path, multiple Pythons, their interactions, and most 16 | of them having a pip installed, users suffer every time an entrypoint gets 17 | moved. 18 | 19 | To alleviate this pain, and provide a mechanism for warning users and 20 | directing them to an appropriate place for help, we now define all of 21 | our old entrypoints as wrappers for the current one. 22 | """ 23 | sys.stderr.write( 24 | "WARNING: pip is being invoked by an old script wrapper. This will " 25 | "fail in a future version of pip.\n" 26 | "Please see https://github.com/pypa/pip/issues/5599 for advice on " 27 | "fixing the underlying issue.\n" 28 | "To avoid this problem you can invoke Python with '-m pip' instead of " 29 | "running pip directly.\n" 30 | ) 31 | return main(args) 32 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/filetypes.py: -------------------------------------------------------------------------------- 1 | """Filetype information. 2 | """ 3 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 4 | 5 | if MYPY_CHECK_RUNNING: 6 | from typing import Tuple 7 | 8 | WHEEL_EXTENSION = '.whl' 9 | BZ2_EXTENSIONS = ('.tar.bz2', '.tbz') # type: Tuple[str, ...] 10 | XZ_EXTENSIONS = ('.tar.xz', '.txz', '.tlz', 11 | '.tar.lz', '.tar.lzma') # type: Tuple[str, ...] 12 | ZIP_EXTENSIONS = ('.zip', WHEEL_EXTENSION) # type: Tuple[str, ...] 13 | TAR_EXTENSIONS = ('.tar.gz', '.tgz', '.tar') # type: Tuple[str, ...] 14 | ARCHIVE_EXTENSIONS = ( 15 | ZIP_EXTENSIONS + BZ2_EXTENSIONS + TAR_EXTENSIONS + XZ_EXTENSIONS 16 | ) 17 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/inject_securetransport.py: -------------------------------------------------------------------------------- 1 | """A helper module that injects SecureTransport, on import. 2 | 3 | The import should be done as early as possible, to ensure all requests and 4 | sessions (or whatever) are created after injecting SecureTransport. 5 | 6 | Note that we only do the injection on macOS, when the linked OpenSSL is too 7 | old to handle TLSv1.2. 8 | """ 9 | 10 | import sys 11 | 12 | 13 | def inject_securetransport(): 14 | # type: () -> None 15 | # Only relevant on macOS 16 | if sys.platform != "darwin": 17 | return 18 | 19 | try: 20 | import ssl 21 | except ImportError: 22 | return 23 | 24 | # Checks for OpenSSL 1.0.1 25 | if ssl.OPENSSL_VERSION_NUMBER >= 0x1000100f: 26 | return 27 | 28 | try: 29 | from pip._vendor.urllib3.contrib import securetransport 30 | except (ImportError, OSError): 31 | return 32 | 33 | securetransport.inject_into_urllib3() 34 | 35 | 36 | inject_securetransport() 37 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/models.py: -------------------------------------------------------------------------------- 1 | """Utilities for defining models 2 | """ 3 | # The following comment should be removed at some point in the future. 4 | # mypy: disallow-untyped-defs=False 5 | 6 | import operator 7 | 8 | 9 | class KeyBasedCompareMixin(object): 10 | """Provides comparison capabilities that is based on a key 11 | """ 12 | 13 | def __init__(self, key, defining_class): 14 | self._compare_key = key 15 | self._defining_class = defining_class 16 | 17 | def __hash__(self): 18 | return hash(self._compare_key) 19 | 20 | def __lt__(self, other): 21 | return self._compare(other, operator.__lt__) 22 | 23 | def __le__(self, other): 24 | return self._compare(other, operator.__le__) 25 | 26 | def __gt__(self, other): 27 | return self._compare(other, operator.__gt__) 28 | 29 | def __ge__(self, other): 30 | return self._compare(other, operator.__ge__) 31 | 32 | def __eq__(self, other): 33 | return self._compare(other, operator.__eq__) 34 | 35 | def __ne__(self, other): 36 | return self._compare(other, operator.__ne__) 37 | 38 | def _compare(self, other, method): 39 | if not isinstance(other, self._defining_class): 40 | return NotImplemented 41 | 42 | return method(self._compare_key, other._compare_key) 43 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/pkg_resources.py: -------------------------------------------------------------------------------- 1 | from pip._vendor.pkg_resources import yield_lines 2 | from pip._vendor.six import ensure_str 3 | 4 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 5 | 6 | if MYPY_CHECK_RUNNING: 7 | from typing import Dict, Iterable, List 8 | 9 | 10 | class DictMetadata(object): 11 | """IMetadataProvider that reads metadata files from a dictionary. 12 | """ 13 | def __init__(self, metadata): 14 | # type: (Dict[str, bytes]) -> None 15 | self._metadata = metadata 16 | 17 | def has_metadata(self, name): 18 | # type: (str) -> bool 19 | return name in self._metadata 20 | 21 | def get_metadata(self, name): 22 | # type: (str) -> str 23 | try: 24 | return ensure_str(self._metadata[name]) 25 | except UnicodeDecodeError as e: 26 | # Mirrors handling done in pkg_resources.NullProvider. 27 | e.reason += " in {} file".format(name) 28 | raise 29 | 30 | def get_metadata_lines(self, name): 31 | # type: (str) -> Iterable[str] 32 | return yield_lines(self.get_metadata(name)) 33 | 34 | def metadata_isdir(self, name): 35 | # type: (str) -> bool 36 | return False 37 | 38 | def metadata_listdir(self, name): 39 | # type: (str) -> List[str] 40 | return [] 41 | 42 | def run_script(self, script_name, namespace): 43 | # type: (str, str) -> None 44 | pass 45 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/typing.py: -------------------------------------------------------------------------------- 1 | """For neatly implementing static typing in pip. 2 | 3 | `mypy` - the static type analysis tool we use - uses the `typing` module, which 4 | provides core functionality fundamental to mypy's functioning. 5 | 6 | Generally, `typing` would be imported at runtime and used in that fashion - 7 | it acts as a no-op at runtime and does not have any run-time overhead by 8 | design. 9 | 10 | As it turns out, `typing` is not vendorable - it uses separate sources for 11 | Python 2/Python 3. Thus, this codebase can not expect it to be present. 12 | To work around this, mypy allows the typing import to be behind a False-y 13 | optional to prevent it from running at runtime and type-comments can be used 14 | to remove the need for the types to be accessible directly during runtime. 15 | 16 | This module provides the False-y guard in a nicely named fashion so that a 17 | curious maintainer can reach here to read this. 18 | 19 | In pip, all static-typing related imports should be guarded as follows: 20 | 21 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 22 | 23 | if MYPY_CHECK_RUNNING: 24 | from typing import ... 25 | 26 | Ref: https://github.com/python/mypy/issues/3216 27 | """ 28 | 29 | MYPY_CHECK_RUNNING = False 30 | 31 | 32 | if MYPY_CHECK_RUNNING: 33 | from typing import cast 34 | else: 35 | # typing's cast() is needed at runtime, but we don't want to import typing. 36 | # Thus, we use a dummy no-op version, which we tell mypy to ignore. 37 | def cast(type_, value): # type: ignore 38 | return value 39 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/utils/urls.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from pip._vendor.six.moves.urllib import parse as urllib_parse 5 | from pip._vendor.six.moves.urllib import request as urllib_request 6 | 7 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING 8 | 9 | if MYPY_CHECK_RUNNING: 10 | from typing import Optional, Text, Union 11 | 12 | 13 | def get_url_scheme(url): 14 | # type: (Union[str, Text]) -> Optional[Text] 15 | if ':' not in url: 16 | return None 17 | return url.split(':', 1)[0].lower() 18 | 19 | 20 | def path_to_url(path): 21 | # type: (Union[str, Text]) -> str 22 | """ 23 | Convert a path to a file: URL. The path will be made absolute and have 24 | quoted path parts. 25 | """ 26 | path = os.path.normpath(os.path.abspath(path)) 27 | url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path)) 28 | return url 29 | 30 | 31 | def url_to_path(url): 32 | # type: (str) -> str 33 | """ 34 | Convert a file: URL to a path. 35 | """ 36 | assert url.startswith('file:'), ( 37 | "You can only turn file: urls into filenames (not {url!r})" 38 | .format(**locals())) 39 | 40 | _, netloc, path, _, _ = urllib_parse.urlsplit(url) 41 | 42 | if not netloc or netloc == 'localhost': 43 | # According to RFC 8089, same as empty authority. 44 | netloc = '' 45 | elif sys.platform == 'win32': 46 | # If we have a UNC path, prepend UNC share notation. 47 | netloc = '\\\\' + netloc 48 | else: 49 | raise ValueError( 50 | 'non-local file URIs are not supported on this platform: {url!r}' 51 | .format(**locals()) 52 | ) 53 | 54 | path = urllib_request.url2pathname(netloc + path) 55 | return path 56 | -------------------------------------------------------------------------------- /sources/pip_20.1/_internal/vcs/__init__.py: -------------------------------------------------------------------------------- 1 | # Expose a limited set of classes and functions so callers outside of 2 | # the vcs package don't need to import deeper than `pip._internal.vcs`. 3 | # (The test directory and imports protected by MYPY_CHECK_RUNNING may 4 | # still need to import from a vcs sub-package.) 5 | # Import all vcs modules to register each VCS in the VcsSupport object. 6 | import pip._internal.vcs.bazaar 7 | import pip._internal.vcs.git 8 | import pip._internal.vcs.mercurial 9 | import pip._internal.vcs.subversion # noqa: F401 10 | from pip._internal.vcs.versioncontrol import ( # noqa: F401 11 | RemoteNotFoundError, 12 | is_url, 13 | make_vcs_requirement_url, 14 | vcs, 15 | ) 16 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/cachecontrol/__init__.py: -------------------------------------------------------------------------------- 1 | """CacheControl import Interface. 2 | 3 | Make it easy to import from cachecontrol without long namespaces. 4 | """ 5 | __author__ = "Eric Larson" 6 | __email__ = "eric@ionrock.org" 7 | __version__ = "0.12.6" 8 | 9 | from .wrapper import CacheControl 10 | from .adapter import CacheControlAdapter 11 | from .controller import CacheController 12 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/cachecontrol/_cmd.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from pip._vendor import requests 4 | 5 | from pip._vendor.cachecontrol.adapter import CacheControlAdapter 6 | from pip._vendor.cachecontrol.cache import DictCache 7 | from pip._vendor.cachecontrol.controller import logger 8 | 9 | from argparse import ArgumentParser 10 | 11 | 12 | def setup_logging(): 13 | logger.setLevel(logging.DEBUG) 14 | handler = logging.StreamHandler() 15 | logger.addHandler(handler) 16 | 17 | 18 | def get_session(): 19 | adapter = CacheControlAdapter( 20 | DictCache(), cache_etags=True, serializer=None, heuristic=None 21 | ) 22 | sess = requests.Session() 23 | sess.mount("http://", adapter) 24 | sess.mount("https://", adapter) 25 | 26 | sess.cache_controller = adapter.controller 27 | return sess 28 | 29 | 30 | def get_args(): 31 | parser = ArgumentParser() 32 | parser.add_argument("url", help="The URL to try and cache") 33 | return parser.parse_args() 34 | 35 | 36 | def main(args=None): 37 | args = get_args() 38 | sess = get_session() 39 | 40 | # Make a request to get a response 41 | resp = sess.get(args.url) 42 | 43 | # Turn on logging 44 | setup_logging() 45 | 46 | # try setting the cache 47 | sess.cache_controller.cache_response(resp.request, resp.raw) 48 | 49 | # Now try to get it 50 | if sess.cache_controller.cached_request(resp.request): 51 | print("Cached!") 52 | else: 53 | print("Not cached :(") 54 | 55 | 56 | if __name__ == "__main__": 57 | main() 58 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/cachecontrol/cache.py: -------------------------------------------------------------------------------- 1 | """ 2 | The cache object API for implementing caches. The default is a thread 3 | safe in-memory dictionary. 4 | """ 5 | from threading import Lock 6 | 7 | 8 | class BaseCache(object): 9 | 10 | def get(self, key): 11 | raise NotImplementedError() 12 | 13 | def set(self, key, value): 14 | raise NotImplementedError() 15 | 16 | def delete(self, key): 17 | raise NotImplementedError() 18 | 19 | def close(self): 20 | pass 21 | 22 | 23 | class DictCache(BaseCache): 24 | 25 | def __init__(self, init_dict=None): 26 | self.lock = Lock() 27 | self.data = init_dict or {} 28 | 29 | def get(self, key): 30 | return self.data.get(key, None) 31 | 32 | def set(self, key, value): 33 | with self.lock: 34 | self.data.update({key: value}) 35 | 36 | def delete(self, key): 37 | with self.lock: 38 | if key in self.data: 39 | self.data.pop(key) 40 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/cachecontrol/caches/__init__.py: -------------------------------------------------------------------------------- 1 | from .file_cache import FileCache # noqa 2 | from .redis_cache import RedisCache # noqa 3 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/cachecontrol/caches/redis_cache.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | 3 | from datetime import datetime 4 | from pip._vendor.cachecontrol.cache import BaseCache 5 | 6 | 7 | class RedisCache(BaseCache): 8 | 9 | def __init__(self, conn): 10 | self.conn = conn 11 | 12 | def get(self, key): 13 | return self.conn.get(key) 14 | 15 | def set(self, key, value, expires=None): 16 | if not expires: 17 | self.conn.set(key, value) 18 | else: 19 | expires = expires - datetime.utcnow() 20 | self.conn.setex(key, int(expires.total_seconds()), value) 21 | 22 | def delete(self, key): 23 | self.conn.delete(key) 24 | 25 | def clear(self): 26 | """Helper for clearing all the keys in a database. Use with 27 | caution!""" 28 | for key in self.conn.keys(): 29 | self.conn.delete(key) 30 | 31 | def close(self): 32 | """Redis uses connection pooling, no need to close the connection.""" 33 | pass 34 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/cachecontrol/compat.py: -------------------------------------------------------------------------------- 1 | try: 2 | from urllib.parse import urljoin 3 | except ImportError: 4 | from urlparse import urljoin 5 | 6 | 7 | try: 8 | import cPickle as pickle 9 | except ImportError: 10 | import pickle 11 | 12 | 13 | # Handle the case where the requests module has been patched to not have 14 | # urllib3 bundled as part of its source. 15 | try: 16 | from pip._vendor.requests.packages.urllib3.response import HTTPResponse 17 | except ImportError: 18 | from pip._vendor.urllib3.response import HTTPResponse 19 | 20 | try: 21 | from pip._vendor.requests.packages.urllib3.util import is_fp_closed 22 | except ImportError: 23 | from pip._vendor.urllib3.util import is_fp_closed 24 | 25 | # Replicate some six behaviour 26 | try: 27 | text_type = unicode 28 | except NameError: 29 | text_type = str 30 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/cachecontrol/filewrapper.py: -------------------------------------------------------------------------------- 1 | from io import BytesIO 2 | 3 | 4 | class CallbackFileWrapper(object): 5 | """ 6 | Small wrapper around a fp object which will tee everything read into a 7 | buffer, and when that file is closed it will execute a callback with the 8 | contents of that buffer. 9 | 10 | All attributes are proxied to the underlying file object. 11 | 12 | This class uses members with a double underscore (__) leading prefix so as 13 | not to accidentally shadow an attribute. 14 | """ 15 | 16 | def __init__(self, fp, callback): 17 | self.__buf = BytesIO() 18 | self.__fp = fp 19 | self.__callback = callback 20 | 21 | def __getattr__(self, name): 22 | # The vaguaries of garbage collection means that self.__fp is 23 | # not always set. By using __getattribute__ and the private 24 | # name[0] allows looking up the attribute value and raising an 25 | # AttributeError when it doesn't exist. This stop thigns from 26 | # infinitely recursing calls to getattr in the case where 27 | # self.__fp hasn't been set. 28 | # 29 | # [0] https://docs.python.org/2/reference/expressions.html#atom-identifiers 30 | fp = self.__getattribute__("_CallbackFileWrapper__fp") 31 | return getattr(fp, name) 32 | 33 | def __is_fp_closed(self): 34 | try: 35 | return self.__fp.fp is None 36 | 37 | except AttributeError: 38 | pass 39 | 40 | try: 41 | return self.__fp.closed 42 | 43 | except AttributeError: 44 | pass 45 | 46 | # We just don't cache it then. 47 | # TODO: Add some logging here... 48 | return False 49 | 50 | def _close(self): 51 | if self.__callback: 52 | self.__callback(self.__buf.getvalue()) 53 | 54 | # We assign this to None here, because otherwise we can get into 55 | # really tricky problems where the CPython interpreter dead locks 56 | # because the callback is holding a reference to something which 57 | # has a __del__ method. Setting this to None breaks the cycle 58 | # and allows the garbage collector to do it's thing normally. 59 | self.__callback = None 60 | 61 | def read(self, amt=None): 62 | data = self.__fp.read(amt) 63 | self.__buf.write(data) 64 | if self.__is_fp_closed(): 65 | self._close() 66 | 67 | return data 68 | 69 | def _safe_read(self, amt): 70 | data = self.__fp._safe_read(amt) 71 | if amt == 2 and data == b"\r\n": 72 | # urllib executes this read to toss the CRLF at the end 73 | # of the chunk. 74 | return data 75 | 76 | self.__buf.write(data) 77 | if self.__is_fp_closed(): 78 | self._close() 79 | 80 | return data 81 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/cachecontrol/wrapper.py: -------------------------------------------------------------------------------- 1 | from .adapter import CacheControlAdapter 2 | from .cache import DictCache 3 | 4 | 5 | def CacheControl( 6 | sess, 7 | cache=None, 8 | cache_etags=True, 9 | serializer=None, 10 | heuristic=None, 11 | controller_class=None, 12 | adapter_class=None, 13 | cacheable_methods=None, 14 | ): 15 | 16 | cache = DictCache() if cache is None else cache 17 | adapter_class = adapter_class or CacheControlAdapter 18 | adapter = adapter_class( 19 | cache, 20 | cache_etags=cache_etags, 21 | serializer=serializer, 22 | heuristic=heuristic, 23 | controller_class=controller_class, 24 | cacheable_methods=cacheable_methods, 25 | ) 26 | sess.mount("http://", adapter) 27 | sess.mount("https://", adapter) 28 | 29 | return sess 30 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/certifi/__init__.py: -------------------------------------------------------------------------------- 1 | from .core import contents, where 2 | 3 | __version__ = "2020.04.05.1" 4 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/certifi/__main__.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | from pip._vendor.certifi import contents, where 4 | 5 | parser = argparse.ArgumentParser() 6 | parser.add_argument("-c", "--contents", action="store_true") 7 | args = parser.parse_args() 8 | 9 | if args.contents: 10 | print(contents()) 11 | else: 12 | print(where()) 13 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/certifi/core.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | certifi.py 5 | ~~~~~~~~~~ 6 | 7 | This module returns the installation location of cacert.pem or its contents. 8 | """ 9 | import os 10 | 11 | try: 12 | from importlib.resources import read_text 13 | except ImportError: 14 | # This fallback will work for Python versions prior to 3.7 that lack the 15 | # importlib.resources module but relies on the existing `where` function 16 | # so won't address issues with environments like PyOxidizer that don't set 17 | # __file__ on modules. 18 | def read_text(_module, _path, encoding="ascii"): 19 | with open(where(), "r", encoding=encoding) as data: 20 | return data.read() 21 | 22 | 23 | def where(): 24 | f = os.path.dirname(__file__) 25 | 26 | return os.path.join(f, "cacert.pem") 27 | 28 | 29 | def contents(): 30 | return read_text("certifi", "cacert.pem", encoding="ascii") 31 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/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 | 19 | from .compat import PY2, PY3 20 | from .universaldetector import UniversalDetector 21 | from .version import __version__, VERSION 22 | 23 | 24 | def detect(byte_str): 25 | """ 26 | Detect the encoding of the given byte string. 27 | 28 | :param byte_str: The byte sequence to examine. 29 | :type byte_str: ``bytes`` or ``bytearray`` 30 | """ 31 | if not isinstance(byte_str, bytearray): 32 | if not isinstance(byte_str, bytes): 33 | raise TypeError('Expected object of type bytes or bytearray, got: ' 34 | '{0}'.format(type(byte_str))) 35 | else: 36 | byte_str = bytearray(byte_str) 37 | detector = UniversalDetector() 38 | detector.feed(byte_str) 39 | return detector.close() 40 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/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 BIG5_SM_MODEL 32 | 33 | 34 | class Big5Prober(MultiByteCharSetProber): 35 | def __init__(self): 36 | super(Big5Prober, self).__init__() 37 | self.coding_sm = CodingStateMachine(BIG5_SM_MODEL) 38 | self.distribution_analyzer = Big5DistributionAnalysis() 39 | self.reset() 40 | 41 | @property 42 | def charset_name(self): 43 | return "Big5" 44 | 45 | @property 46 | def language(self): 47 | return "Chinese" 48 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/chardet/cli/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/chardet/compat.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # Contributor(s): 3 | # Dan Blanchard 4 | # Ian Cordasco 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 19 | # 02110-1301 USA 20 | ######################### END LICENSE BLOCK ######################### 21 | 22 | import sys 23 | 24 | 25 | if sys.version_info < (3, 0): 26 | PY2 = True 27 | PY3 = False 28 | base_str = (str, unicode) 29 | text_type = unicode 30 | else: 31 | PY2 = False 32 | PY3 = True 33 | base_str = (bytes, str) 34 | text_type = str 35 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/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 .chardistribution import EUCKRDistributionAnalysis 29 | from .codingstatemachine import CodingStateMachine 30 | from .mbcharsetprober import MultiByteCharSetProber 31 | from .mbcssm import CP949_SM_MODEL 32 | 33 | 34 | class CP949Prober(MultiByteCharSetProber): 35 | def __init__(self): 36 | super(CP949Prober, self).__init__() 37 | self.coding_sm = CodingStateMachine(CP949_SM_MODEL) 38 | # NOTE: CP949 is a superset of EUC-KR, so the distribution should be 39 | # not different. 40 | self.distribution_analyzer = EUCKRDistributionAnalysis() 41 | self.reset() 42 | 43 | @property 44 | def charset_name(self): 45 | return "CP949" 46 | 47 | @property 48 | def language(self): 49 | return "Korean" 50 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/chardet/enums.py: -------------------------------------------------------------------------------- 1 | """ 2 | All of the Enums that are used throughout the chardet package. 3 | 4 | :author: Dan Blanchard (dan.blanchard@gmail.com) 5 | """ 6 | 7 | 8 | class InputState(object): 9 | """ 10 | This enum represents the different states a universal detector can be in. 11 | """ 12 | PURE_ASCII = 0 13 | ESC_ASCII = 1 14 | HIGH_BYTE = 2 15 | 16 | 17 | class LanguageFilter(object): 18 | """ 19 | This enum represents the different language filters we can apply to a 20 | ``UniversalDetector``. 21 | """ 22 | CHINESE_SIMPLIFIED = 0x01 23 | CHINESE_TRADITIONAL = 0x02 24 | JAPANESE = 0x04 25 | KOREAN = 0x08 26 | NON_CJK = 0x10 27 | ALL = 0x1F 28 | CHINESE = CHINESE_SIMPLIFIED | CHINESE_TRADITIONAL 29 | CJK = CHINESE | JAPANESE | KOREAN 30 | 31 | 32 | class ProbingState(object): 33 | """ 34 | This enum represents the different states a prober can be in. 35 | """ 36 | DETECTING = 0 37 | FOUND_IT = 1 38 | NOT_ME = 2 39 | 40 | 41 | class MachineState(object): 42 | """ 43 | This enum represents the different states a state machine can be in. 44 | """ 45 | START = 0 46 | ERROR = 1 47 | ITS_ME = 2 48 | 49 | 50 | class SequenceLikelihood(object): 51 | """ 52 | This enum represents the likelihood of a character following the previous one. 53 | """ 54 | NEGATIVE = 0 55 | UNLIKELY = 1 56 | LIKELY = 2 57 | POSITIVE = 3 58 | 59 | @classmethod 60 | def get_num_categories(cls): 61 | """:returns: The number of likelihood categories in the enum.""" 62 | return 4 63 | 64 | 65 | class CharacterCategory(object): 66 | """ 67 | This enum represents the different categories language models for 68 | ``SingleByteCharsetProber`` put characters into. 69 | 70 | Anything less than CONTROL is considered a letter. 71 | """ 72 | UNDEFINED = 255 73 | LINE_BREAK = 254 74 | SYMBOL = 253 75 | DIGIT = 252 76 | CONTROL = 251 77 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/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 EUCKR_SM_MODEL 32 | 33 | 34 | class EUCKRProber(MultiByteCharSetProber): 35 | def __init__(self): 36 | super(EUCKRProber, self).__init__() 37 | self.coding_sm = CodingStateMachine(EUCKR_SM_MODEL) 38 | self.distribution_analyzer = EUCKRDistributionAnalysis() 39 | self.reset() 40 | 41 | @property 42 | def charset_name(self): 43 | return "EUC-KR" 44 | 45 | @property 46 | def language(self): 47 | return "Korean" 48 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/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 EUCTW_SM_MODEL 32 | 33 | class EUCTWProber(MultiByteCharSetProber): 34 | def __init__(self): 35 | super(EUCTWProber, self).__init__() 36 | self.coding_sm = CodingStateMachine(EUCTW_SM_MODEL) 37 | self.distribution_analyzer = EUCTWDistributionAnalysis() 38 | self.reset() 39 | 40 | @property 41 | def charset_name(self): 42 | return "EUC-TW" 43 | 44 | @property 45 | def language(self): 46 | return "Taiwan" 47 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/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 GB2312_SM_MODEL 32 | 33 | class GB2312Prober(MultiByteCharSetProber): 34 | def __init__(self): 35 | super(GB2312Prober, self).__init__() 36 | self.coding_sm = CodingStateMachine(GB2312_SM_MODEL) 37 | self.distribution_analyzer = GB2312DistributionAnalysis() 38 | self.reset() 39 | 40 | @property 41 | def charset_name(self): 42 | return "GB2312" 43 | 44 | @property 45 | def language(self): 46 | return "Chinese" 47 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/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, lang_filter=None): 43 | super(MBCSGroupProber, self).__init__(lang_filter=lang_filter) 44 | self.probers = [ 45 | UTF8Prober(), 46 | SJISProber(), 47 | EUCJPProber(), 48 | GB2312Prober(), 49 | EUCKRProber(), 50 | CP949Prober(), 51 | Big5Prober(), 52 | EUCTWProber() 53 | ] 54 | self.reset() 55 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/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 .charsetprober import CharSetProber 29 | from .enums import ProbingState, MachineState 30 | from .codingstatemachine import CodingStateMachine 31 | from .mbcssm import UTF8_SM_MODEL 32 | 33 | 34 | 35 | class UTF8Prober(CharSetProber): 36 | ONE_CHAR_PROB = 0.5 37 | 38 | def __init__(self): 39 | super(UTF8Prober, self).__init__() 40 | self.coding_sm = CodingStateMachine(UTF8_SM_MODEL) 41 | self._num_mb_chars = None 42 | self.reset() 43 | 44 | def reset(self): 45 | super(UTF8Prober, self).reset() 46 | self.coding_sm.reset() 47 | self._num_mb_chars = 0 48 | 49 | @property 50 | def charset_name(self): 51 | return "utf-8" 52 | 53 | @property 54 | def language(self): 55 | return "" 56 | 57 | def feed(self, byte_str): 58 | for c in byte_str: 59 | coding_state = self.coding_sm.next_state(c) 60 | if coding_state == MachineState.ERROR: 61 | self._state = ProbingState.NOT_ME 62 | break 63 | elif coding_state == MachineState.ITS_ME: 64 | self._state = ProbingState.FOUND_IT 65 | break 66 | elif coding_state == MachineState.START: 67 | if self.coding_sm.get_current_charlen() >= 2: 68 | self._num_mb_chars += 1 69 | 70 | if self.state == ProbingState.DETECTING: 71 | if self.get_confidence() > self.SHORTCUT_THRESHOLD: 72 | self._state = ProbingState.FOUND_IT 73 | 74 | return self.state 75 | 76 | def get_confidence(self): 77 | unlike = 0.99 78 | if self._num_mb_chars < 6: 79 | unlike *= self.ONE_CHAR_PROB ** self._num_mb_chars 80 | return 1.0 - unlike 81 | else: 82 | return unlike 83 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/chardet/version.py: -------------------------------------------------------------------------------- 1 | """ 2 | This module exists only to simplify retrieving the version number of chardet 3 | from within setup.py and from chardet subpackages. 4 | 5 | :author: Dan Blanchard (dan.blanchard@gmail.com) 6 | """ 7 | 8 | __version__ = "3.0.4" 9 | VERSION = __version__.split('.') 10 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/colorama/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. 2 | from .initialise import init, deinit, reinit, colorama_text 3 | from .ansi import Fore, Back, Style, Cursor 4 | from .ansitowin32 import AnsiToWin32 5 | 6 | __version__ = '0.4.3' 7 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/colorama/ansi.py: -------------------------------------------------------------------------------- 1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. 2 | ''' 3 | This module generates ANSI character codes to printing colors to terminals. 4 | See: http://en.wikipedia.org/wiki/ANSI_escape_code 5 | ''' 6 | 7 | CSI = '\033[' 8 | OSC = '\033]' 9 | BEL = '\007' 10 | 11 | 12 | def code_to_chars(code): 13 | return CSI + str(code) + 'm' 14 | 15 | def set_title(title): 16 | return OSC + '2;' + title + BEL 17 | 18 | def clear_screen(mode=2): 19 | return CSI + str(mode) + 'J' 20 | 21 | def clear_line(mode=2): 22 | return CSI + str(mode) + 'K' 23 | 24 | 25 | class AnsiCodes(object): 26 | def __init__(self): 27 | # the subclasses declare class attributes which are numbers. 28 | # Upon instantiation we define instance attributes, which are the same 29 | # as the class attributes but wrapped with the ANSI escape sequence 30 | for name in dir(self): 31 | if not name.startswith('_'): 32 | value = getattr(self, name) 33 | setattr(self, name, code_to_chars(value)) 34 | 35 | 36 | class AnsiCursor(object): 37 | def UP(self, n=1): 38 | return CSI + str(n) + 'A' 39 | def DOWN(self, n=1): 40 | return CSI + str(n) + 'B' 41 | def FORWARD(self, n=1): 42 | return CSI + str(n) + 'C' 43 | def BACK(self, n=1): 44 | return CSI + str(n) + 'D' 45 | def POS(self, x=1, y=1): 46 | return CSI + str(y) + ';' + str(x) + 'H' 47 | 48 | 49 | class AnsiFore(AnsiCodes): 50 | BLACK = 30 51 | RED = 31 52 | GREEN = 32 53 | YELLOW = 33 54 | BLUE = 34 55 | MAGENTA = 35 56 | CYAN = 36 57 | WHITE = 37 58 | RESET = 39 59 | 60 | # These are fairly well supported, but not part of the standard. 61 | LIGHTBLACK_EX = 90 62 | LIGHTRED_EX = 91 63 | LIGHTGREEN_EX = 92 64 | LIGHTYELLOW_EX = 93 65 | LIGHTBLUE_EX = 94 66 | LIGHTMAGENTA_EX = 95 67 | LIGHTCYAN_EX = 96 68 | LIGHTWHITE_EX = 97 69 | 70 | 71 | class AnsiBack(AnsiCodes): 72 | BLACK = 40 73 | RED = 41 74 | GREEN = 42 75 | YELLOW = 43 76 | BLUE = 44 77 | MAGENTA = 45 78 | CYAN = 46 79 | WHITE = 47 80 | RESET = 49 81 | 82 | # These are fairly well supported, but not part of the standard. 83 | LIGHTBLACK_EX = 100 84 | LIGHTRED_EX = 101 85 | LIGHTGREEN_EX = 102 86 | LIGHTYELLOW_EX = 103 87 | LIGHTBLUE_EX = 104 88 | LIGHTMAGENTA_EX = 105 89 | LIGHTCYAN_EX = 106 90 | LIGHTWHITE_EX = 107 91 | 92 | 93 | class AnsiStyle(AnsiCodes): 94 | BRIGHT = 1 95 | DIM = 2 96 | NORMAL = 22 97 | RESET_ALL = 0 98 | 99 | Fore = AnsiFore() 100 | Back = AnsiBack() 101 | Style = AnsiStyle() 102 | Cursor = AnsiCursor() 103 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/colorama/initialise.py: -------------------------------------------------------------------------------- 1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. 2 | import atexit 3 | import contextlib 4 | import sys 5 | 6 | from .ansitowin32 import AnsiToWin32 7 | 8 | 9 | orig_stdout = None 10 | orig_stderr = None 11 | 12 | wrapped_stdout = None 13 | wrapped_stderr = None 14 | 15 | atexit_done = False 16 | 17 | 18 | def reset_all(): 19 | if AnsiToWin32 is not None: # Issue #74: objects might become None at exit 20 | AnsiToWin32(orig_stdout).reset_all() 21 | 22 | 23 | def init(autoreset=False, convert=None, strip=None, wrap=True): 24 | 25 | if not wrap and any([autoreset, convert, strip]): 26 | raise ValueError('wrap=False conflicts with any other arg=True') 27 | 28 | global wrapped_stdout, wrapped_stderr 29 | global orig_stdout, orig_stderr 30 | 31 | orig_stdout = sys.stdout 32 | orig_stderr = sys.stderr 33 | 34 | if sys.stdout is None: 35 | wrapped_stdout = None 36 | else: 37 | sys.stdout = wrapped_stdout = \ 38 | wrap_stream(orig_stdout, convert, strip, autoreset, wrap) 39 | if sys.stderr is None: 40 | wrapped_stderr = None 41 | else: 42 | sys.stderr = wrapped_stderr = \ 43 | wrap_stream(orig_stderr, convert, strip, autoreset, wrap) 44 | 45 | global atexit_done 46 | if not atexit_done: 47 | atexit.register(reset_all) 48 | atexit_done = True 49 | 50 | 51 | def deinit(): 52 | if orig_stdout is not None: 53 | sys.stdout = orig_stdout 54 | if orig_stderr is not None: 55 | sys.stderr = orig_stderr 56 | 57 | 58 | @contextlib.contextmanager 59 | def colorama_text(*args, **kwargs): 60 | init(*args, **kwargs) 61 | try: 62 | yield 63 | finally: 64 | deinit() 65 | 66 | 67 | def reinit(): 68 | if wrapped_stdout is not None: 69 | sys.stdout = wrapped_stdout 70 | if wrapped_stderr is not None: 71 | sys.stderr = wrapped_stderr 72 | 73 | 74 | def wrap_stream(stream, convert, strip, autoreset, wrap): 75 | if wrap: 76 | wrapper = AnsiToWin32(stream, 77 | convert=convert, strip=strip, autoreset=autoreset) 78 | if wrapper.should_wrap(): 79 | stream = wrapper.stream 80 | return stream 81 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/distlib/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2012-2019 Vinay Sajip. 4 | # Licensed to the Python Software Foundation under a contributor agreement. 5 | # See LICENSE.txt and CONTRIBUTORS.txt. 6 | # 7 | import logging 8 | 9 | __version__ = '0.3.0' 10 | 11 | class DistlibException(Exception): 12 | pass 13 | 14 | try: 15 | from logging import NullHandler 16 | except ImportError: # pragma: no cover 17 | class NullHandler(logging.Handler): 18 | def handle(self, record): pass 19 | def emit(self, record): pass 20 | def createLock(self): self.lock = None 21 | 22 | logger = logging.getLogger(__name__) 23 | logger.addHandler(NullHandler()) 24 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/distlib/_backport/__init__.py: -------------------------------------------------------------------------------- 1 | """Modules copied from Python 3 standard libraries, for internal use only. 2 | 3 | Individual classes and functions are found in d2._backport.misc. Intended 4 | usage is to always import things missing from 3.1 from that module: the 5 | built-in/stdlib objects will be used if found. 6 | """ 7 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/distlib/_backport/misc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2012 The Python Software Foundation. 4 | # See LICENSE.txt and CONTRIBUTORS.txt. 5 | # 6 | """Backports for individual classes and functions.""" 7 | 8 | import os 9 | import sys 10 | 11 | __all__ = ['cache_from_source', 'callable', 'fsencode'] 12 | 13 | 14 | try: 15 | from imp import cache_from_source 16 | except ImportError: 17 | def cache_from_source(py_file, debug=__debug__): 18 | ext = debug and 'c' or 'o' 19 | return py_file + ext 20 | 21 | 22 | try: 23 | callable = callable 24 | except NameError: 25 | from collections import Callable 26 | 27 | def callable(obj): 28 | return isinstance(obj, Callable) 29 | 30 | 31 | try: 32 | fsencode = os.fsencode 33 | except AttributeError: 34 | def fsencode(filename): 35 | if isinstance(filename, bytes): 36 | return filename 37 | elif isinstance(filename, str): 38 | return filename.encode(sys.getfilesystemencoding()) 39 | else: 40 | raise TypeError("expect bytes or str, not %s" % 41 | type(filename).__name__) 42 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/distlib/_backport/sysconfig.cfg: -------------------------------------------------------------------------------- 1 | [posix_prefix] 2 | # Configuration directories. Some of these come straight out of the 3 | # configure script. They are for implementing the other variables, not to 4 | # be used directly in [resource_locations]. 5 | confdir = /etc 6 | datadir = /usr/share 7 | libdir = /usr/lib 8 | statedir = /var 9 | # User resource directory 10 | local = ~/.local/{distribution.name} 11 | 12 | stdlib = {base}/lib/python{py_version_short} 13 | platstdlib = {platbase}/lib/python{py_version_short} 14 | purelib = {base}/lib/python{py_version_short}/site-packages 15 | platlib = {platbase}/lib/python{py_version_short}/site-packages 16 | include = {base}/include/python{py_version_short}{abiflags} 17 | platinclude = {platbase}/include/python{py_version_short}{abiflags} 18 | data = {base} 19 | 20 | [posix_home] 21 | stdlib = {base}/lib/python 22 | platstdlib = {base}/lib/python 23 | purelib = {base}/lib/python 24 | platlib = {base}/lib/python 25 | include = {base}/include/python 26 | platinclude = {base}/include/python 27 | scripts = {base}/bin 28 | data = {base} 29 | 30 | [nt] 31 | stdlib = {base}/Lib 32 | platstdlib = {base}/Lib 33 | purelib = {base}/Lib/site-packages 34 | platlib = {base}/Lib/site-packages 35 | include = {base}/Include 36 | platinclude = {base}/Include 37 | scripts = {base}/Scripts 38 | data = {base} 39 | 40 | [os2] 41 | stdlib = {base}/Lib 42 | platstdlib = {base}/Lib 43 | purelib = {base}/Lib/site-packages 44 | platlib = {base}/Lib/site-packages 45 | include = {base}/Include 46 | platinclude = {base}/Include 47 | scripts = {base}/Scripts 48 | data = {base} 49 | 50 | [os2_home] 51 | stdlib = {userbase}/lib/python{py_version_short} 52 | platstdlib = {userbase}/lib/python{py_version_short} 53 | purelib = {userbase}/lib/python{py_version_short}/site-packages 54 | platlib = {userbase}/lib/python{py_version_short}/site-packages 55 | include = {userbase}/include/python{py_version_short} 56 | scripts = {userbase}/bin 57 | data = {userbase} 58 | 59 | [nt_user] 60 | stdlib = {userbase}/Python{py_version_nodot} 61 | platstdlib = {userbase}/Python{py_version_nodot} 62 | purelib = {userbase}/Python{py_version_nodot}/site-packages 63 | platlib = {userbase}/Python{py_version_nodot}/site-packages 64 | include = {userbase}/Python{py_version_nodot}/Include 65 | scripts = {userbase}/Scripts 66 | data = {userbase} 67 | 68 | [posix_user] 69 | stdlib = {userbase}/lib/python{py_version_short} 70 | platstdlib = {userbase}/lib/python{py_version_short} 71 | purelib = {userbase}/lib/python{py_version_short}/site-packages 72 | platlib = {userbase}/lib/python{py_version_short}/site-packages 73 | include = {userbase}/include/python{py_version_short} 74 | scripts = {userbase}/bin 75 | data = {userbase} 76 | 77 | [osx_framework_user] 78 | stdlib = {userbase}/lib/python 79 | platstdlib = {userbase}/lib/python 80 | purelib = {userbase}/lib/python/site-packages 81 | platlib = {userbase}/lib/python/site-packages 82 | include = {userbase}/include 83 | scripts = {userbase}/bin 84 | data = {userbase} 85 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/distlib/t32.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_vendor/distlib/t32.exe -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/distlib/t64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_vendor/distlib/t64.exe -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/distlib/w32.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_vendor/distlib/w32.exe -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/distlib/w64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_vendor/distlib/w64.exe -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | HTML parsing library based on the `WHATWG HTML specification 3 | `_. The parser is designed to be compatible with 4 | existing HTML found in the wild and implements well-defined error recovery that 5 | is largely compatible with modern desktop web browsers. 6 | 7 | Example usage:: 8 | 9 | from pip._vendor import html5lib 10 | with open("my_document.html", "rb") as f: 11 | tree = html5lib.parse(f) 12 | 13 | For convenience, this module re-exports the following names: 14 | 15 | * :func:`~.html5parser.parse` 16 | * :func:`~.html5parser.parseFragment` 17 | * :class:`~.html5parser.HTMLParser` 18 | * :func:`~.treebuilders.getTreeBuilder` 19 | * :func:`~.treewalkers.getTreeWalker` 20 | * :func:`~.serializer.serialize` 21 | """ 22 | 23 | from __future__ import absolute_import, division, unicode_literals 24 | 25 | from .html5parser import HTMLParser, parse, parseFragment 26 | from .treebuilders import getTreeBuilder 27 | from .treewalkers import getTreeWalker 28 | from .serializer import serialize 29 | 30 | __all__ = ["HTMLParser", "parse", "parseFragment", "getTreeBuilder", 31 | "getTreeWalker", "serialize"] 32 | 33 | # this has to be at the top level, see how setup.py parses this 34 | #: Distribution version number. 35 | __version__ = "1.0.1" 36 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/_trie/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | from .py import Trie as PyTrie 4 | 5 | Trie = PyTrie 6 | 7 | # pylint:disable=wrong-import-position 8 | try: 9 | from .datrie import Trie as DATrie 10 | except ImportError: 11 | pass 12 | else: 13 | Trie = DATrie 14 | # pylint:enable=wrong-import-position 15 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/_trie/_base.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | try: 4 | from collections.abc import Mapping 5 | except ImportError: # Python 2.7 6 | from collections import Mapping 7 | 8 | 9 | class Trie(Mapping): 10 | """Abstract base class for tries""" 11 | 12 | def keys(self, prefix=None): 13 | # pylint:disable=arguments-differ 14 | keys = super(Trie, self).keys() 15 | 16 | if prefix is None: 17 | return set(keys) 18 | 19 | return {x for x in keys if x.startswith(prefix)} 20 | 21 | def has_keys_with_prefix(self, prefix): 22 | for key in self.keys(): 23 | if key.startswith(prefix): 24 | return True 25 | 26 | return False 27 | 28 | def longest_prefix(self, prefix): 29 | if prefix in self: 30 | return prefix 31 | 32 | for i in range(1, len(prefix) + 1): 33 | if prefix[:-i] in self: 34 | return prefix[:-i] 35 | 36 | raise KeyError(prefix) 37 | 38 | def longest_prefix_item(self, prefix): 39 | lprefix = self.longest_prefix(prefix) 40 | return (lprefix, self[lprefix]) 41 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/_trie/datrie.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | from datrie import Trie as DATrie 4 | from pip._vendor.six import text_type 5 | 6 | from ._base import Trie as ABCTrie 7 | 8 | 9 | class Trie(ABCTrie): 10 | def __init__(self, data): 11 | chars = set() 12 | for key in data.keys(): 13 | if not isinstance(key, text_type): 14 | raise TypeError("All keys must be strings") 15 | for char in key: 16 | chars.add(char) 17 | 18 | self._data = DATrie("".join(chars)) 19 | for key, value in data.items(): 20 | self._data[key] = value 21 | 22 | def __contains__(self, key): 23 | return key in self._data 24 | 25 | def __len__(self): 26 | return len(self._data) 27 | 28 | def __iter__(self): 29 | raise NotImplementedError() 30 | 31 | def __getitem__(self, key): 32 | return self._data[key] 33 | 34 | def keys(self, prefix=None): 35 | return self._data.keys(prefix) 36 | 37 | def has_keys_with_prefix(self, prefix): 38 | return self._data.has_keys_with_prefix(prefix) 39 | 40 | def longest_prefix(self, prefix): 41 | return self._data.longest_prefix(prefix) 42 | 43 | def longest_prefix_item(self, prefix): 44 | return self._data.longest_prefix_item(prefix) 45 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/_trie/py.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | from pip._vendor.six import text_type 3 | 4 | from bisect import bisect_left 5 | 6 | from ._base import Trie as ABCTrie 7 | 8 | 9 | class Trie(ABCTrie): 10 | def __init__(self, data): 11 | if not all(isinstance(x, text_type) for x in data.keys()): 12 | raise TypeError("All keys must be strings") 13 | 14 | self._data = data 15 | self._keys = sorted(data.keys()) 16 | self._cachestr = "" 17 | self._cachepoints = (0, len(data)) 18 | 19 | def __contains__(self, key): 20 | return key in self._data 21 | 22 | def __len__(self): 23 | return len(self._data) 24 | 25 | def __iter__(self): 26 | return iter(self._data) 27 | 28 | def __getitem__(self, key): 29 | return self._data[key] 30 | 31 | def keys(self, prefix=None): 32 | if prefix is None or prefix == "" or not self._keys: 33 | return set(self._keys) 34 | 35 | if prefix.startswith(self._cachestr): 36 | lo, hi = self._cachepoints 37 | start = i = bisect_left(self._keys, prefix, lo, hi) 38 | else: 39 | start = i = bisect_left(self._keys, prefix) 40 | 41 | keys = set() 42 | if start == len(self._keys): 43 | return keys 44 | 45 | while self._keys[i].startswith(prefix): 46 | keys.add(self._keys[i]) 47 | i += 1 48 | 49 | self._cachestr = prefix 50 | self._cachepoints = (start, i) 51 | 52 | return keys 53 | 54 | def has_keys_with_prefix(self, prefix): 55 | if prefix in self._data: 56 | return True 57 | 58 | if prefix.startswith(self._cachestr): 59 | lo, hi = self._cachepoints 60 | i = bisect_left(self._keys, prefix, lo, hi) 61 | else: 62 | i = bisect_left(self._keys, prefix) 63 | 64 | if i == len(self._keys): 65 | return False 66 | 67 | return self._keys[i].startswith(prefix) 68 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/filters/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_vendor/html5lib/filters/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/filters/alphabeticalattributes.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | from . import base 4 | 5 | from collections import OrderedDict 6 | 7 | 8 | def _attr_key(attr): 9 | """Return an appropriate key for an attribute for sorting 10 | 11 | Attributes have a namespace that can be either ``None`` or a string. We 12 | can't compare the two because they're different types, so we convert 13 | ``None`` to an empty string first. 14 | 15 | """ 16 | return (attr[0][0] or ''), attr[0][1] 17 | 18 | 19 | class Filter(base.Filter): 20 | """Alphabetizes attributes for elements""" 21 | def __iter__(self): 22 | for token in base.Filter.__iter__(self): 23 | if token["type"] in ("StartTag", "EmptyTag"): 24 | attrs = OrderedDict() 25 | for name, value in sorted(token["data"].items(), 26 | key=_attr_key): 27 | attrs[name] = value 28 | token["data"] = attrs 29 | yield token 30 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/filters/base.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | 4 | class Filter(object): 5 | def __init__(self, source): 6 | self.source = source 7 | 8 | def __iter__(self): 9 | return iter(self.source) 10 | 11 | def __getattr__(self, name): 12 | return getattr(self.source, name) 13 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/filters/whitespace.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | import re 4 | 5 | from . import base 6 | from ..constants import rcdataElements, spaceCharacters 7 | spaceCharacters = "".join(spaceCharacters) 8 | 9 | SPACES_REGEX = re.compile("[%s]+" % spaceCharacters) 10 | 11 | 12 | class Filter(base.Filter): 13 | """Collapses whitespace except in pre, textarea, and script elements""" 14 | spacePreserveElements = frozenset(["pre", "textarea"] + list(rcdataElements)) 15 | 16 | def __iter__(self): 17 | preserve = 0 18 | for token in base.Filter.__iter__(self): 19 | type = token["type"] 20 | if type == "StartTag" \ 21 | and (preserve or token["name"] in self.spacePreserveElements): 22 | preserve += 1 23 | 24 | elif type == "EndTag" and preserve: 25 | preserve -= 1 26 | 27 | elif not preserve and type == "SpaceCharacters" and token["data"]: 28 | # Test on token["data"] above to not introduce spaces where there were not 29 | token["data"] = " " 30 | 31 | elif not preserve and type == "Characters": 32 | token["data"] = collapse_spaces(token["data"]) 33 | 34 | yield token 35 | 36 | 37 | def collapse_spaces(text): 38 | return SPACES_REGEX.sub(' ', text) 39 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/treeadapters/__init__.py: -------------------------------------------------------------------------------- 1 | """Tree adapters let you convert from one tree structure to another 2 | 3 | Example: 4 | 5 | .. code-block:: python 6 | 7 | from pip._vendor import html5lib 8 | from pip._vendor.html5lib.treeadapters import genshi 9 | 10 | doc = 'Hi!' 11 | treebuilder = html5lib.getTreeBuilder('etree') 12 | parser = html5lib.HTMLParser(tree=treebuilder) 13 | tree = parser.parse(doc) 14 | TreeWalker = html5lib.getTreeWalker('etree') 15 | 16 | genshi_tree = genshi.to_genshi(TreeWalker(tree)) 17 | 18 | """ 19 | from __future__ import absolute_import, division, unicode_literals 20 | 21 | from . import sax 22 | 23 | __all__ = ["sax"] 24 | 25 | try: 26 | from . import genshi # noqa 27 | except ImportError: 28 | pass 29 | else: 30 | __all__.append("genshi") 31 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/treeadapters/genshi.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | from genshi.core import QName, Attrs 4 | from genshi.core import START, END, TEXT, COMMENT, DOCTYPE 5 | 6 | 7 | def to_genshi(walker): 8 | """Convert a tree to a genshi tree 9 | 10 | :arg walker: the treewalker to use to walk the tree to convert it 11 | 12 | :returns: generator of genshi nodes 13 | 14 | """ 15 | text = [] 16 | for token in walker: 17 | type = token["type"] 18 | if type in ("Characters", "SpaceCharacters"): 19 | text.append(token["data"]) 20 | elif text: 21 | yield TEXT, "".join(text), (None, -1, -1) 22 | text = [] 23 | 24 | if type in ("StartTag", "EmptyTag"): 25 | if token["namespace"]: 26 | name = "{%s}%s" % (token["namespace"], token["name"]) 27 | else: 28 | name = token["name"] 29 | attrs = Attrs([(QName("{%s}%s" % attr if attr[0] is not None else attr[1]), value) 30 | for attr, value in token["data"].items()]) 31 | yield (START, (QName(name), attrs), (None, -1, -1)) 32 | if type == "EmptyTag": 33 | type = "EndTag" 34 | 35 | if type == "EndTag": 36 | if token["namespace"]: 37 | name = "{%s}%s" % (token["namespace"], token["name"]) 38 | else: 39 | name = token["name"] 40 | 41 | yield END, QName(name), (None, -1, -1) 42 | 43 | elif type == "Comment": 44 | yield COMMENT, token["data"], (None, -1, -1) 45 | 46 | elif type == "Doctype": 47 | yield DOCTYPE, (token["name"], token["publicId"], 48 | token["systemId"]), (None, -1, -1) 49 | 50 | else: 51 | pass # FIXME: What to do? 52 | 53 | if text: 54 | yield TEXT, "".join(text), (None, -1, -1) 55 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/treeadapters/sax.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | from xml.sax.xmlreader import AttributesNSImpl 4 | 5 | from ..constants import adjustForeignAttributes, unadjustForeignAttributes 6 | 7 | prefix_mapping = {} 8 | for prefix, localName, namespace in adjustForeignAttributes.values(): 9 | if prefix is not None: 10 | prefix_mapping[prefix] = namespace 11 | 12 | 13 | def to_sax(walker, handler): 14 | """Call SAX-like content handler based on treewalker walker 15 | 16 | :arg walker: the treewalker to use to walk the tree to convert it 17 | 18 | :arg handler: SAX handler to use 19 | 20 | """ 21 | handler.startDocument() 22 | for prefix, namespace in prefix_mapping.items(): 23 | handler.startPrefixMapping(prefix, namespace) 24 | 25 | for token in walker: 26 | type = token["type"] 27 | if type == "Doctype": 28 | continue 29 | elif type in ("StartTag", "EmptyTag"): 30 | attrs = AttributesNSImpl(token["data"], 31 | unadjustForeignAttributes) 32 | handler.startElementNS((token["namespace"], token["name"]), 33 | token["name"], 34 | attrs) 35 | if type == "EmptyTag": 36 | handler.endElementNS((token["namespace"], token["name"]), 37 | token["name"]) 38 | elif type == "EndTag": 39 | handler.endElementNS((token["namespace"], token["name"]), 40 | token["name"]) 41 | elif type in ("Characters", "SpaceCharacters"): 42 | handler.characters(token["data"]) 43 | elif type == "Comment": 44 | pass 45 | else: 46 | assert False, "Unknown token type" 47 | 48 | for prefix, namespace in prefix_mapping.items(): 49 | handler.endPrefixMapping(prefix) 50 | handler.endDocument() 51 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/treewalkers/dom.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | from xml.dom import Node 4 | 5 | from . import base 6 | 7 | 8 | class TreeWalker(base.NonRecursiveTreeWalker): 9 | def getNodeDetails(self, node): 10 | if node.nodeType == Node.DOCUMENT_TYPE_NODE: 11 | return base.DOCTYPE, node.name, node.publicId, node.systemId 12 | 13 | elif node.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): 14 | return base.TEXT, node.nodeValue 15 | 16 | elif node.nodeType == Node.ELEMENT_NODE: 17 | attrs = {} 18 | for attr in list(node.attributes.keys()): 19 | attr = node.getAttributeNode(attr) 20 | if attr.namespaceURI: 21 | attrs[(attr.namespaceURI, attr.localName)] = attr.value 22 | else: 23 | attrs[(None, attr.name)] = attr.value 24 | return (base.ELEMENT, node.namespaceURI, node.nodeName, 25 | attrs, node.hasChildNodes()) 26 | 27 | elif node.nodeType == Node.COMMENT_NODE: 28 | return base.COMMENT, node.nodeValue 29 | 30 | elif node.nodeType in (Node.DOCUMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE): 31 | return (base.DOCUMENT,) 32 | 33 | else: 34 | return base.UNKNOWN, node.nodeType 35 | 36 | def getFirstChild(self, node): 37 | return node.firstChild 38 | 39 | def getNextSibling(self, node): 40 | return node.nextSibling 41 | 42 | def getParentNode(self, node): 43 | return node.parentNode 44 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/html5lib/treewalkers/genshi.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, unicode_literals 2 | 3 | from genshi.core import QName 4 | from genshi.core import START, END, XML_NAMESPACE, DOCTYPE, TEXT 5 | from genshi.core import START_NS, END_NS, START_CDATA, END_CDATA, PI, COMMENT 6 | 7 | from . import base 8 | 9 | from ..constants import voidElements, namespaces 10 | 11 | 12 | class TreeWalker(base.TreeWalker): 13 | def __iter__(self): 14 | # Buffer the events so we can pass in the following one 15 | previous = None 16 | for event in self.tree: 17 | if previous is not None: 18 | for token in self.tokens(previous, event): 19 | yield token 20 | previous = event 21 | 22 | # Don't forget the final event! 23 | if previous is not None: 24 | for token in self.tokens(previous, None): 25 | yield token 26 | 27 | def tokens(self, event, next): 28 | kind, data, _ = event 29 | if kind == START: 30 | tag, attribs = data 31 | name = tag.localname 32 | namespace = tag.namespace 33 | converted_attribs = {} 34 | for k, v in attribs: 35 | if isinstance(k, QName): 36 | converted_attribs[(k.namespace, k.localname)] = v 37 | else: 38 | converted_attribs[(None, k)] = v 39 | 40 | if namespace == namespaces["html"] and name in voidElements: 41 | for token in self.emptyTag(namespace, name, converted_attribs, 42 | not next or next[0] != END or 43 | next[1] != tag): 44 | yield token 45 | else: 46 | yield self.startTag(namespace, name, converted_attribs) 47 | 48 | elif kind == END: 49 | name = data.localname 50 | namespace = data.namespace 51 | if namespace != namespaces["html"] or name not in voidElements: 52 | yield self.endTag(namespace, name) 53 | 54 | elif kind == COMMENT: 55 | yield self.comment(data) 56 | 57 | elif kind == TEXT: 58 | for token in self.text(data): 59 | yield token 60 | 61 | elif kind == DOCTYPE: 62 | yield self.doctype(*data) 63 | 64 | elif kind in (XML_NAMESPACE, DOCTYPE, START_NS, END_NS, 65 | START_CDATA, END_CDATA, PI): 66 | pass 67 | 68 | else: 69 | yield self.unknown(kind) 70 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/idna/__init__.py: -------------------------------------------------------------------------------- 1 | from .package_data import __version__ 2 | from .core import * 3 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/idna/compat.py: -------------------------------------------------------------------------------- 1 | from .core import * 2 | from .codec import * 3 | 4 | def ToASCII(label): 5 | return encode(label) 6 | 7 | def ToUnicode(label): 8 | return decode(label) 9 | 10 | def nameprep(s): 11 | raise NotImplementedError("IDNA 2008 does not utilise nameprep protocol") 12 | 13 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/idna/intranges.py: -------------------------------------------------------------------------------- 1 | """ 2 | Given a list of integers, made up of (hopefully) a small number of long runs 3 | of consecutive integers, compute a representation of the form 4 | ((start1, end1), (start2, end2) ...). Then answer the question "was x present 5 | in the original list?" in time O(log(# runs)). 6 | """ 7 | 8 | import bisect 9 | 10 | def intranges_from_list(list_): 11 | """Represent a list of integers as a sequence of ranges: 12 | ((start_0, end_0), (start_1, end_1), ...), such that the original 13 | integers are exactly those x such that start_i <= x < end_i for some i. 14 | 15 | Ranges are encoded as single integers (start << 32 | end), not as tuples. 16 | """ 17 | 18 | sorted_list = sorted(list_) 19 | ranges = [] 20 | last_write = -1 21 | for i in range(len(sorted_list)): 22 | if i+1 < len(sorted_list): 23 | if sorted_list[i] == sorted_list[i+1]-1: 24 | continue 25 | current_range = sorted_list[last_write+1:i+1] 26 | ranges.append(_encode_range(current_range[0], current_range[-1] + 1)) 27 | last_write = i 28 | 29 | return tuple(ranges) 30 | 31 | def _encode_range(start, end): 32 | return (start << 32) | end 33 | 34 | def _decode_range(r): 35 | return (r >> 32), (r & ((1 << 32) - 1)) 36 | 37 | 38 | def intranges_contain(int_, ranges): 39 | """Determine if `int_` falls into one of the ranges in `ranges`.""" 40 | tuple_ = _encode_range(int_, 0) 41 | pos = bisect.bisect_left(ranges, tuple_) 42 | # we could be immediately ahead of a tuple (start, end) 43 | # with start < int_ <= end 44 | if pos > 0: 45 | left, right = _decode_range(ranges[pos-1]) 46 | if left <= int_ < right: 47 | return True 48 | # or we could be immediately behind a tuple (int_, end) 49 | if pos < len(ranges): 50 | left, _ = _decode_range(ranges[pos]) 51 | if left == int_: 52 | return True 53 | return False 54 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/idna/package_data.py: -------------------------------------------------------------------------------- 1 | __version__ = '2.9' 2 | 3 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/msgpack/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | from ._version import version 3 | from .exceptions import * 4 | from .ext import ExtType, Timestamp 5 | 6 | import os 7 | import sys 8 | 9 | 10 | if os.environ.get("MSGPACK_PUREPYTHON") or sys.version_info[0] == 2: 11 | from .fallback import Packer, unpackb, Unpacker 12 | else: 13 | try: 14 | from ._cmsgpack import Packer, unpackb, Unpacker 15 | except ImportError: 16 | from .fallback import Packer, unpackb, Unpacker 17 | 18 | 19 | def pack(o, stream, **kwargs): 20 | """ 21 | Pack object `o` and write it to `stream` 22 | 23 | See :class:`Packer` for options. 24 | """ 25 | packer = Packer(**kwargs) 26 | stream.write(packer.pack(o)) 27 | 28 | 29 | def packb(o, **kwargs): 30 | """ 31 | Pack object `o` and return packed bytes 32 | 33 | See :class:`Packer` for options. 34 | """ 35 | return Packer(**kwargs).pack(o) 36 | 37 | 38 | def unpack(stream, **kwargs): 39 | """ 40 | Unpack an object from `stream`. 41 | 42 | Raises `ExtraData` when `stream` contains extra bytes. 43 | See :class:`Unpacker` for options. 44 | """ 45 | data = stream.read() 46 | return unpackb(data, **kwargs) 47 | 48 | 49 | # alias for compatibility to simplejson/marshal/pickle. 50 | load = unpack 51 | loads = unpackb 52 | 53 | dump = pack 54 | dumps = packb 55 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/msgpack/_version.py: -------------------------------------------------------------------------------- 1 | version = (1, 0, 0) 2 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/msgpack/exceptions.py: -------------------------------------------------------------------------------- 1 | class UnpackException(Exception): 2 | """Base class for some exceptions raised while unpacking. 3 | 4 | NOTE: unpack may raise exception other than subclass of 5 | UnpackException. If you want to catch all error, catch 6 | Exception instead. 7 | """ 8 | 9 | 10 | class BufferFull(UnpackException): 11 | pass 12 | 13 | 14 | class OutOfData(UnpackException): 15 | pass 16 | 17 | 18 | class FormatError(ValueError, UnpackException): 19 | """Invalid msgpack format""" 20 | 21 | 22 | class StackError(ValueError, UnpackException): 23 | """Too nested""" 24 | 25 | 26 | # Deprecated. Use ValueError instead 27 | UnpackValueError = ValueError 28 | 29 | 30 | class ExtraData(UnpackValueError): 31 | """ExtraData is raised when there is trailing data. 32 | 33 | This exception is raised while only one-shot (not streaming) 34 | unpack. 35 | """ 36 | 37 | def __init__(self, unpacked, extra): 38 | self.unpacked = unpacked 39 | self.extra = extra 40 | 41 | def __str__(self): 42 | return "unpack(b) received extra data." 43 | 44 | 45 | # Deprecated. Use Exception instead to catch all exception during packing. 46 | PackException = Exception 47 | PackValueError = ValueError 48 | PackOverflowError = OverflowError 49 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/packaging/__about__.py: -------------------------------------------------------------------------------- 1 | # This file is dual licensed under the terms of the Apache License, Version 2 | # 2.0, and the BSD License. See the LICENSE file in the root of this repository 3 | # for complete details. 4 | from __future__ import absolute_import, division, print_function 5 | 6 | __all__ = [ 7 | "__title__", 8 | "__summary__", 9 | "__uri__", 10 | "__version__", 11 | "__author__", 12 | "__email__", 13 | "__license__", 14 | "__copyright__", 15 | ] 16 | 17 | __title__ = "packaging" 18 | __summary__ = "Core utilities for Python packages" 19 | __uri__ = "https://github.com/pypa/packaging" 20 | 21 | __version__ = "20.3" 22 | 23 | __author__ = "Donald Stufft and individual contributors" 24 | __email__ = "donald@stufft.io" 25 | 26 | __license__ = "BSD or Apache License, Version 2.0" 27 | __copyright__ = "Copyright 2014-2019 %s" % __author__ 28 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/packaging/__init__.py: -------------------------------------------------------------------------------- 1 | # This file is dual licensed under the terms of the Apache License, Version 2 | # 2.0, and the BSD License. See the LICENSE file in the root of this repository 3 | # for complete details. 4 | from __future__ import absolute_import, division, print_function 5 | 6 | from .__about__ import ( 7 | __author__, 8 | __copyright__, 9 | __email__, 10 | __license__, 11 | __summary__, 12 | __title__, 13 | __uri__, 14 | __version__, 15 | ) 16 | 17 | __all__ = [ 18 | "__title__", 19 | "__summary__", 20 | "__uri__", 21 | "__version__", 22 | "__author__", 23 | "__email__", 24 | "__license__", 25 | "__copyright__", 26 | ] 27 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/packaging/_compat.py: -------------------------------------------------------------------------------- 1 | # This file is dual licensed under the terms of the Apache License, Version 2 | # 2.0, and the BSD License. See the LICENSE file in the root of this repository 3 | # for complete details. 4 | from __future__ import absolute_import, division, print_function 5 | 6 | import sys 7 | 8 | from ._typing import MYPY_CHECK_RUNNING 9 | 10 | if MYPY_CHECK_RUNNING: # pragma: no cover 11 | from typing import Any, Dict, Tuple, Type 12 | 13 | 14 | PY2 = sys.version_info[0] == 2 15 | PY3 = sys.version_info[0] == 3 16 | 17 | # flake8: noqa 18 | 19 | if PY3: 20 | string_types = (str,) 21 | else: 22 | string_types = (basestring,) 23 | 24 | 25 | def with_metaclass(meta, *bases): 26 | # type: (Type[Any], Tuple[Type[Any], ...]) -> Any 27 | """ 28 | Create a base class with a metaclass. 29 | """ 30 | # This requires a bit of explanation: the basic idea is to make a dummy 31 | # metaclass for one level of class instantiation that replaces itself with 32 | # the actual metaclass. 33 | class metaclass(meta): # type: ignore 34 | def __new__(cls, name, this_bases, d): 35 | # type: (Type[Any], str, Tuple[Any], Dict[Any, Any]) -> Any 36 | return meta(name, bases, d) 37 | 38 | return type.__new__(metaclass, "temporary_class", (), {}) 39 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/packaging/_structures.py: -------------------------------------------------------------------------------- 1 | # This file is dual licensed under the terms of the Apache License, Version 2 | # 2.0, and the BSD License. See the LICENSE file in the root of this repository 3 | # for complete details. 4 | from __future__ import absolute_import, division, print_function 5 | 6 | 7 | class InfinityType(object): 8 | def __repr__(self): 9 | # type: () -> str 10 | return "Infinity" 11 | 12 | def __hash__(self): 13 | # type: () -> int 14 | return hash(repr(self)) 15 | 16 | def __lt__(self, other): 17 | # type: (object) -> bool 18 | return False 19 | 20 | def __le__(self, other): 21 | # type: (object) -> bool 22 | return False 23 | 24 | def __eq__(self, other): 25 | # type: (object) -> bool 26 | return isinstance(other, self.__class__) 27 | 28 | def __ne__(self, other): 29 | # type: (object) -> bool 30 | return not isinstance(other, self.__class__) 31 | 32 | def __gt__(self, other): 33 | # type: (object) -> bool 34 | return True 35 | 36 | def __ge__(self, other): 37 | # type: (object) -> bool 38 | return True 39 | 40 | def __neg__(self): 41 | # type: (object) -> NegativeInfinityType 42 | return NegativeInfinity 43 | 44 | 45 | Infinity = InfinityType() 46 | 47 | 48 | class NegativeInfinityType(object): 49 | def __repr__(self): 50 | # type: () -> str 51 | return "-Infinity" 52 | 53 | def __hash__(self): 54 | # type: () -> int 55 | return hash(repr(self)) 56 | 57 | def __lt__(self, other): 58 | # type: (object) -> bool 59 | return True 60 | 61 | def __le__(self, other): 62 | # type: (object) -> bool 63 | return True 64 | 65 | def __eq__(self, other): 66 | # type: (object) -> bool 67 | return isinstance(other, self.__class__) 68 | 69 | def __ne__(self, other): 70 | # type: (object) -> bool 71 | return not isinstance(other, self.__class__) 72 | 73 | def __gt__(self, other): 74 | # type: (object) -> bool 75 | return False 76 | 77 | def __ge__(self, other): 78 | # type: (object) -> bool 79 | return False 80 | 81 | def __neg__(self): 82 | # type: (object) -> InfinityType 83 | return Infinity 84 | 85 | 86 | NegativeInfinity = NegativeInfinityType() 87 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/packaging/_typing.py: -------------------------------------------------------------------------------- 1 | """For neatly implementing static typing in packaging. 2 | 3 | `mypy` - the static type analysis tool we use - uses the `typing` module, which 4 | provides core functionality fundamental to mypy's functioning. 5 | 6 | Generally, `typing` would be imported at runtime and used in that fashion - 7 | it acts as a no-op at runtime and does not have any run-time overhead by 8 | design. 9 | 10 | As it turns out, `typing` is not vendorable - it uses separate sources for 11 | Python 2/Python 3. Thus, this codebase can not expect it to be present. 12 | To work around this, mypy allows the typing import to be behind a False-y 13 | optional to prevent it from running at runtime and type-comments can be used 14 | to remove the need for the types to be accessible directly during runtime. 15 | 16 | This module provides the False-y guard in a nicely named fashion so that a 17 | curious maintainer can reach here to read this. 18 | 19 | In packaging, all static-typing related imports should be guarded as follows: 20 | 21 | from pip._vendor.packaging._typing import MYPY_CHECK_RUNNING 22 | 23 | if MYPY_CHECK_RUNNING: 24 | from typing import ... 25 | 26 | Ref: https://github.com/python/mypy/issues/3216 27 | """ 28 | 29 | MYPY_CHECK_RUNNING = False 30 | 31 | if MYPY_CHECK_RUNNING: # pragma: no cover 32 | import typing 33 | 34 | cast = typing.cast 35 | else: 36 | # typing's cast() is needed at runtime, but we don't want to import typing. 37 | # Thus, we use a dummy no-op version, which we tell mypy to ignore. 38 | def cast(type_, value): # type: ignore 39 | return value 40 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/packaging/utils.py: -------------------------------------------------------------------------------- 1 | # This file is dual licensed under the terms of the Apache License, Version 2 | # 2.0, and the BSD License. See the LICENSE file in the root of this repository 3 | # for complete details. 4 | from __future__ import absolute_import, division, print_function 5 | 6 | import re 7 | 8 | from ._typing import MYPY_CHECK_RUNNING 9 | from .version import InvalidVersion, Version 10 | 11 | if MYPY_CHECK_RUNNING: # pragma: no cover 12 | from typing import Union 13 | 14 | _canonicalize_regex = re.compile(r"[-_.]+") 15 | 16 | 17 | def canonicalize_name(name): 18 | # type: (str) -> str 19 | # This is taken from PEP 503. 20 | return _canonicalize_regex.sub("-", name).lower() 21 | 22 | 23 | def canonicalize_version(_version): 24 | # type: (str) -> Union[Version, str] 25 | """ 26 | This is very similar to Version.__str__, but has one subtle difference 27 | with the way it handles the release segment. 28 | """ 29 | 30 | try: 31 | version = Version(_version) 32 | except InvalidVersion: 33 | # Legacy versions cannot be normalized 34 | return _version 35 | 36 | parts = [] 37 | 38 | # Epoch 39 | if version.epoch != 0: 40 | parts.append("{0}!".format(version.epoch)) 41 | 42 | # Release segment 43 | # NB: This strips trailing '.0's to normalize 44 | parts.append(re.sub(r"(\.0)+$", "", ".".join(str(x) for x in version.release))) 45 | 46 | # Pre-release 47 | if version.pre is not None: 48 | parts.append("".join(str(x) for x in version.pre)) 49 | 50 | # Post-release 51 | if version.post is not None: 52 | parts.append(".post{0}".format(version.post)) 53 | 54 | # Development release 55 | if version.dev is not None: 56 | parts.append(".dev{0}".format(version.dev)) 57 | 58 | # Local version segment 59 | if version.local is not None: 60 | parts.append("+{0}".format(version.local)) 61 | 62 | return "".join(parts) 63 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/pep517/__init__.py: -------------------------------------------------------------------------------- 1 | """Wrappers to build Python packages using PEP 517 hooks 2 | """ 3 | 4 | __version__ = '0.8.2' 5 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/pep517/compat.py: -------------------------------------------------------------------------------- 1 | """Python 2/3 compatibility""" 2 | import json 3 | import sys 4 | 5 | 6 | # Handle reading and writing JSON in UTF-8, on Python 3 and 2. 7 | 8 | if sys.version_info[0] >= 3: 9 | # Python 3 10 | def write_json(obj, path, **kwargs): 11 | with open(path, 'w', encoding='utf-8') as f: 12 | json.dump(obj, f, **kwargs) 13 | 14 | def read_json(path): 15 | with open(path, 'r', encoding='utf-8') as f: 16 | return json.load(f) 17 | 18 | else: 19 | # Python 2 20 | def write_json(obj, path, **kwargs): 21 | with open(path, 'wb') as f: 22 | json.dump(obj, f, encoding='utf-8', **kwargs) 23 | 24 | def read_json(path): 25 | with open(path, 'rb') as f: 26 | return json.load(f) 27 | 28 | 29 | # FileNotFoundError 30 | 31 | try: 32 | FileNotFoundError = FileNotFoundError 33 | except NameError: 34 | FileNotFoundError = IOError 35 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/pep517/dirtools.py: -------------------------------------------------------------------------------- 1 | import os 2 | import io 3 | import contextlib 4 | import tempfile 5 | import shutil 6 | import errno 7 | import zipfile 8 | 9 | 10 | @contextlib.contextmanager 11 | def tempdir(): 12 | """Create a temporary directory in a context manager.""" 13 | td = tempfile.mkdtemp() 14 | try: 15 | yield td 16 | finally: 17 | shutil.rmtree(td) 18 | 19 | 20 | def mkdir_p(*args, **kwargs): 21 | """Like `mkdir`, but does not raise an exception if the 22 | directory already exists. 23 | """ 24 | try: 25 | return os.mkdir(*args, **kwargs) 26 | except OSError as exc: 27 | if exc.errno != errno.EEXIST: 28 | raise 29 | 30 | 31 | def dir_to_zipfile(root): 32 | """Construct an in-memory zip file for a directory.""" 33 | buffer = io.BytesIO() 34 | zip_file = zipfile.ZipFile(buffer, 'w') 35 | for root, dirs, files in os.walk(root): 36 | for path in dirs: 37 | fs_path = os.path.join(root, path) 38 | rel_path = os.path.relpath(fs_path, root) 39 | zip_file.writestr(rel_path + '/', '') 40 | for path in files: 41 | fs_path = os.path.join(root, path) 42 | rel_path = os.path.relpath(fs_path, root) 43 | zip_file.write(fs_path, rel_path) 44 | return zip_file 45 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/pep517/meta.py: -------------------------------------------------------------------------------- 1 | """Build metadata for a project using PEP 517 hooks. 2 | """ 3 | import argparse 4 | import logging 5 | import os 6 | import shutil 7 | import functools 8 | 9 | try: 10 | import importlib.metadata as imp_meta 11 | except ImportError: 12 | import importlib_metadata as imp_meta 13 | 14 | try: 15 | from zipfile import Path 16 | except ImportError: 17 | from zipp import Path 18 | 19 | from .envbuild import BuildEnvironment 20 | from .wrappers import Pep517HookCaller, quiet_subprocess_runner 21 | from .dirtools import tempdir, mkdir_p, dir_to_zipfile 22 | from .build import validate_system, load_system, compat_system 23 | 24 | log = logging.getLogger(__name__) 25 | 26 | 27 | def _prep_meta(hooks, env, dest): 28 | reqs = hooks.get_requires_for_build_wheel({}) 29 | log.info('Got build requires: %s', reqs) 30 | 31 | env.pip_install(reqs) 32 | log.info('Installed dynamic build dependencies') 33 | 34 | with tempdir() as td: 35 | log.info('Trying to build metadata in %s', td) 36 | filename = hooks.prepare_metadata_for_build_wheel(td, {}) 37 | source = os.path.join(td, filename) 38 | shutil.move(source, os.path.join(dest, os.path.basename(filename))) 39 | 40 | 41 | def build(source_dir='.', dest=None, system=None): 42 | system = system or load_system(source_dir) 43 | dest = os.path.join(source_dir, dest or 'dist') 44 | mkdir_p(dest) 45 | validate_system(system) 46 | hooks = Pep517HookCaller( 47 | source_dir, system['build-backend'], system.get('backend-path') 48 | ) 49 | 50 | with hooks.subprocess_runner(quiet_subprocess_runner): 51 | with BuildEnvironment() as env: 52 | env.pip_install(system['requires']) 53 | _prep_meta(hooks, env, dest) 54 | 55 | 56 | def build_as_zip(builder=build): 57 | with tempdir() as out_dir: 58 | builder(dest=out_dir) 59 | return dir_to_zipfile(out_dir) 60 | 61 | 62 | def load(root): 63 | """ 64 | Given a source directory (root) of a package, 65 | return an importlib.metadata.Distribution object 66 | with metadata build from that package. 67 | """ 68 | root = os.path.expanduser(root) 69 | system = compat_system(root) 70 | builder = functools.partial(build, source_dir=root, system=system) 71 | path = Path(build_as_zip(builder)) 72 | return imp_meta.PathDistribution(path) 73 | 74 | 75 | parser = argparse.ArgumentParser() 76 | parser.add_argument( 77 | 'source_dir', 78 | help="A directory containing pyproject.toml", 79 | ) 80 | parser.add_argument( 81 | '--out-dir', '-o', 82 | help="Destination in which to save the builds relative to source dir", 83 | ) 84 | 85 | 86 | def main(): 87 | args = parser.parse_args() 88 | build(args.source_dir, args.out_dir) 89 | 90 | 91 | if __name__ == '__main__': 92 | main() 93 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/pkg_resources/py31compat.py: -------------------------------------------------------------------------------- 1 | import os 2 | import errno 3 | import sys 4 | 5 | from pip._vendor import six 6 | 7 | 8 | def _makedirs_31(path, exist_ok=False): 9 | try: 10 | os.makedirs(path) 11 | except OSError as exc: 12 | if not exist_ok or exc.errno != errno.EEXIST: 13 | raise 14 | 15 | 16 | # rely on compatibility behavior until mode considerations 17 | # and exists_ok considerations are disentangled. 18 | # See https://github.com/pypa/setuptools/pull/1083#issuecomment-315168663 19 | needs_makedirs = ( 20 | six.PY2 or 21 | (3, 4) <= sys.version_info < (3, 4, 1) 22 | ) 23 | makedirs = _makedirs_31 if needs_makedirs else os.makedirs 24 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/progress/counter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Copyright (c) 2012 Giorgos Verigakis 4 | # 5 | # Permission to use, copy, modify, and distribute this software for any 6 | # purpose with or without fee is hereby granted, provided that the above 7 | # copyright notice and this permission notice appear in all copies. 8 | # 9 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | 17 | from __future__ import unicode_literals 18 | from . import Infinite, Progress 19 | 20 | 21 | class Counter(Infinite): 22 | def update(self): 23 | self.write(str(self.index)) 24 | 25 | 26 | class Countdown(Progress): 27 | def update(self): 28 | self.write(str(self.remaining)) 29 | 30 | 31 | class Stack(Progress): 32 | phases = (' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█') 33 | 34 | def update(self): 35 | nphases = len(self.phases) 36 | i = min(nphases - 1, int(self.progress * nphases)) 37 | self.write(self.phases[i]) 38 | 39 | 40 | class Pie(Stack): 41 | phases = ('○', '◔', '◑', '◕', '●') 42 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/progress/spinner.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Copyright (c) 2012 Giorgos Verigakis 4 | # 5 | # Permission to use, copy, modify, and distribute this software for any 6 | # purpose with or without fee is hereby granted, provided that the above 7 | # copyright notice and this permission notice appear in all copies. 8 | # 9 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | 17 | from __future__ import unicode_literals 18 | from . import Infinite 19 | 20 | 21 | class Spinner(Infinite): 22 | phases = ('-', '\\', '|', '/') 23 | hide_cursor = True 24 | 25 | def update(self): 26 | i = self.index % len(self.phases) 27 | self.write(self.phases[i]) 28 | 29 | 30 | class PieSpinner(Spinner): 31 | phases = ['◷', '◶', '◵', '◴'] 32 | 33 | 34 | class MoonSpinner(Spinner): 35 | phases = ['◑', '◒', '◐', '◓'] 36 | 37 | 38 | class LineSpinner(Spinner): 39 | phases = ['⎺', '⎻', '⎼', '⎽', '⎼', '⎻'] 40 | 41 | 42 | class PixelSpinner(Spinner): 43 | phases = ['⣾', '⣷', '⣯', '⣟', '⡿', '⢿', '⣻', '⣽'] 44 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/requests/__version__.py: -------------------------------------------------------------------------------- 1 | # .-. .-. .-. . . .-. .-. .-. .-. 2 | # |( |- |.| | | |- `-. | `-. 3 | # ' ' `-' `-`.`-' `-' `-' ' `-' 4 | 5 | __title__ = 'requests' 6 | __description__ = 'Python HTTP for Humans.' 7 | __url__ = 'https://requests.readthedocs.io' 8 | __version__ = '2.23.0' 9 | __build__ = 0x022300 10 | __author__ = 'Kenneth Reitz' 11 | __author_email__ = 'me@kennethreitz.org' 12 | __license__ = 'Apache 2.0' 13 | __copyright__ = 'Copyright 2020 Kenneth Reitz' 14 | __cake__ = u'\u2728 \U0001f370 \u2728' 15 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/requests/_internal_utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests._internal_utils 5 | ~~~~~~~~~~~~~~ 6 | 7 | Provides utility functions that are consumed internally by Requests 8 | which depend on extremely few external helpers (such as compat) 9 | """ 10 | 11 | from .compat import is_py2, builtin_str, str 12 | 13 | 14 | def to_native_string(string, encoding='ascii'): 15 | """Given a string object, regardless of type, returns a representation of 16 | that string in the native string type, encoding and decoding where 17 | necessary. This assumes ASCII unless told otherwise. 18 | """ 19 | if isinstance(string, builtin_str): 20 | out = string 21 | else: 22 | if is_py2: 23 | out = string.encode(encoding) 24 | else: 25 | out = string.decode(encoding) 26 | 27 | return out 28 | 29 | 30 | def unicode_is_ascii(u_string): 31 | """Determine if unicode string only contains ASCII characters. 32 | 33 | :param str u_string: unicode string to check. Must be unicode 34 | and not Python 2 `str`. 35 | :rtype: bool 36 | """ 37 | assert isinstance(u_string, str) 38 | try: 39 | u_string.encode('ascii') 40 | return True 41 | except UnicodeEncodeError: 42 | return False 43 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/requests/certs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | requests.certs 6 | ~~~~~~~~~~~~~~ 7 | 8 | This module returns the preferred default CA certificate bundle. There is 9 | only one — the one from the certifi package. 10 | 11 | If you are packaging Requests, e.g., for a Linux distribution or a managed 12 | environment, you can change the definition of where() to return a separately 13 | packaged CA bundle. 14 | """ 15 | from pip._vendor.certifi import where 16 | 17 | if __name__ == '__main__': 18 | print(where()) 19 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/requests/compat.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.compat 5 | ~~~~~~~~~~~~~~~ 6 | 7 | This module handles import compatibility issues between Python 2 and 8 | Python 3. 9 | """ 10 | 11 | from pip._vendor import chardet 12 | 13 | import sys 14 | 15 | # ------- 16 | # Pythons 17 | # ------- 18 | 19 | # Syntax sugar. 20 | _ver = sys.version_info 21 | 22 | #: Python 2.x? 23 | is_py2 = (_ver[0] == 2) 24 | 25 | #: Python 3.x? 26 | is_py3 = (_ver[0] == 3) 27 | 28 | # Note: We've patched out simplejson support in pip because it prevents 29 | # upgrading simplejson on Windows. 30 | # try: 31 | # import simplejson as json 32 | # except (ImportError, SyntaxError): 33 | # # simplejson does not support Python 3.2, it throws a SyntaxError 34 | # # because of u'...' Unicode literals. 35 | import json 36 | 37 | # --------- 38 | # Specifics 39 | # --------- 40 | 41 | if is_py2: 42 | from urllib import ( 43 | quote, unquote, quote_plus, unquote_plus, urlencode, getproxies, 44 | proxy_bypass, proxy_bypass_environment, getproxies_environment) 45 | from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag 46 | from urllib2 import parse_http_list 47 | import cookielib 48 | from Cookie import Morsel 49 | from StringIO import StringIO 50 | # Keep OrderedDict for backwards compatibility. 51 | from collections import Callable, Mapping, MutableMapping, OrderedDict 52 | 53 | 54 | builtin_str = str 55 | bytes = str 56 | str = unicode 57 | basestring = basestring 58 | numeric_types = (int, long, float) 59 | integer_types = (int, long) 60 | 61 | elif is_py3: 62 | from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag 63 | from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment 64 | from http import cookiejar as cookielib 65 | from http.cookies import Morsel 66 | from io import StringIO 67 | # Keep OrderedDict for backwards compatibility. 68 | from collections import OrderedDict 69 | from collections.abc import Callable, Mapping, MutableMapping 70 | 71 | builtin_str = str 72 | str = str 73 | bytes = bytes 74 | basestring = (str, bytes) 75 | numeric_types = (int, float) 76 | integer_types = (int,) 77 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/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 | HOOKS = ['response'] 15 | 16 | 17 | def default_hooks(): 18 | return {event: [] for event in HOOKS} 19 | 20 | # TODO: response is the only one 21 | 22 | 23 | def dispatch_hook(key, hooks, hook_data, **kwargs): 24 | """Dispatches a hook dictionary on a given piece of data.""" 25 | hooks = hooks or {} 26 | hooks = hooks.get(key) 27 | if hooks: 28 | if hasattr(hooks, '__call__'): 29 | hooks = [hooks] 30 | for hook in hooks: 31 | _hook_data = hook(hook_data, **kwargs) 32 | if _hook_data is not None: 33 | hook_data = _hook_data 34 | return hook_data 35 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/requests/packages.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | # This code exists for backwards compatibility reasons. 4 | # I don't like it either. Just look the other way. :) 5 | 6 | for package in ('urllib3', 'idna', 'chardet'): 7 | vendored_package = "pip._vendor." + package 8 | locals()[package] = __import__(vendored_package) 9 | # This traversal is apparently necessary such that the identities are 10 | # preserved (requests.packages.urllib3.* is urllib3.*) 11 | for mod in list(sys.modules): 12 | if mod == vendored_package or mod.startswith(vendored_package + '.'): 13 | unprefixed_mod = mod[len("pip._vendor."):] 14 | sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod] 15 | 16 | # Kinda cool, though, right? 17 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/resolvelib/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = [ 2 | "__version__", 3 | "AbstractProvider", 4 | "AbstractResolver", 5 | "BaseReporter", 6 | "InconsistentCandidate", 7 | "Resolver", 8 | "RequirementsConflicted", 9 | "ResolutionError", 10 | "ResolutionImpossible", 11 | "ResolutionTooDeep", 12 | ] 13 | 14 | __version__ = "0.3.0" 15 | 16 | 17 | from .providers import AbstractProvider, AbstractResolver 18 | from .reporters import BaseReporter 19 | from .resolvers import ( 20 | InconsistentCandidate, 21 | RequirementsConflicted, 22 | Resolver, 23 | ResolutionError, 24 | ResolutionImpossible, 25 | ResolutionTooDeep, 26 | ) 27 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/resolvelib/reporters.py: -------------------------------------------------------------------------------- 1 | class BaseReporter(object): 2 | """Delegate class to provider progress reporting for the resolver. 3 | """ 4 | 5 | def starting(self): 6 | """Called before the resolution actually starts. 7 | """ 8 | 9 | def starting_round(self, index): 10 | """Called before each round of resolution starts. 11 | 12 | The index is zero-based. 13 | """ 14 | 15 | def ending_round(self, index, state): 16 | """Called before each round of resolution ends. 17 | 18 | This is NOT called if the resolution ends at this round. Use `ending` 19 | if you want to report finalization. The index is zero-based. 20 | """ 21 | 22 | def ending(self, state): 23 | """Called before the resolution ends successfully. 24 | """ 25 | 26 | def adding_requirement(self, requirement): 27 | """Called when the resolver adds a new requirement into the resolve criteria. 28 | """ 29 | 30 | def backtracking(self, candidate): 31 | """Called when the resolver rejects a candidate during backtracking. 32 | """ 33 | 34 | def pinning(self, candidate): 35 | """Called when adding a candidate to the potential solution. 36 | """ 37 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/resolvelib/structs.py: -------------------------------------------------------------------------------- 1 | class DirectedGraph(object): 2 | """A graph structure with directed edges. 3 | """ 4 | 5 | def __init__(self): 6 | self._vertices = set() 7 | self._forwards = {} # -> Set[] 8 | self._backwards = {} # -> Set[] 9 | 10 | def __iter__(self): 11 | return iter(self._vertices) 12 | 13 | def __len__(self): 14 | return len(self._vertices) 15 | 16 | def __contains__(self, key): 17 | return key in self._vertices 18 | 19 | def copy(self): 20 | """Return a shallow copy of this graph. 21 | """ 22 | other = DirectedGraph() 23 | other._vertices = set(self._vertices) 24 | other._forwards = {k: set(v) for k, v in self._forwards.items()} 25 | other._backwards = {k: set(v) for k, v in self._backwards.items()} 26 | return other 27 | 28 | def add(self, key): 29 | """Add a new vertex to the graph. 30 | """ 31 | if key in self._vertices: 32 | raise ValueError("vertex exists") 33 | self._vertices.add(key) 34 | self._forwards[key] = set() 35 | self._backwards[key] = set() 36 | 37 | def remove(self, key): 38 | """Remove a vertex from the graph, disconnecting all edges from/to it. 39 | """ 40 | self._vertices.remove(key) 41 | for f in self._forwards.pop(key): 42 | self._backwards[f].remove(key) 43 | for t in self._backwards.pop(key): 44 | self._forwards[t].remove(key) 45 | 46 | def connected(self, f, t): 47 | return f in self._backwards[t] and t in self._forwards[f] 48 | 49 | def connect(self, f, t): 50 | """Connect two existing vertices. 51 | 52 | Nothing happens if the vertices are already connected. 53 | """ 54 | if t not in self._vertices: 55 | raise KeyError(t) 56 | self._forwards[f].add(t) 57 | self._backwards[t].add(f) 58 | 59 | def iter_edges(self): 60 | for f, children in self._forwards.items(): 61 | for t in children: 62 | yield f, t 63 | 64 | def iter_children(self, key): 65 | return iter(self._forwards[key]) 66 | 67 | def iter_parents(self, key): 68 | return iter(self._backwards[key]) 69 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/toml/__init__.py: -------------------------------------------------------------------------------- 1 | """Python module which parses and emits TOML. 2 | 3 | Released under the MIT license. 4 | """ 5 | 6 | from pip._vendor.toml import encoder 7 | from pip._vendor.toml import decoder 8 | 9 | __version__ = "0.10.0" 10 | _spec_ = "0.5.0" 11 | 12 | load = decoder.load 13 | loads = decoder.loads 14 | TomlDecoder = decoder.TomlDecoder 15 | TomlDecodeError = decoder.TomlDecodeError 16 | 17 | dump = encoder.dump 18 | dumps = encoder.dumps 19 | TomlEncoder = encoder.TomlEncoder 20 | TomlArraySeparatorEncoder = encoder.TomlArraySeparatorEncoder 21 | TomlPreserveInlineDictEncoder = encoder.TomlPreserveInlineDictEncoder 22 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/toml/ordered.py: -------------------------------------------------------------------------------- 1 | from collections import OrderedDict 2 | from pip._vendor.toml import TomlEncoder 3 | from pip._vendor.toml import TomlDecoder 4 | 5 | 6 | class TomlOrderedDecoder(TomlDecoder): 7 | 8 | def __init__(self): 9 | super(self.__class__, self).__init__(_dict=OrderedDict) 10 | 11 | 12 | class TomlOrderedEncoder(TomlEncoder): 13 | 14 | def __init__(self): 15 | super(self.__class__, self).__init__(_dict=OrderedDict) 16 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/toml/tz.py: -------------------------------------------------------------------------------- 1 | from datetime import tzinfo, timedelta 2 | 3 | 4 | class TomlTz(tzinfo): 5 | def __init__(self, toml_offset): 6 | if toml_offset == "Z": 7 | self._raw_offset = "+00:00" 8 | else: 9 | self._raw_offset = toml_offset 10 | self._sign = -1 if self._raw_offset[0] == '-' else 1 11 | self._hours = int(self._raw_offset[1:3]) 12 | self._minutes = int(self._raw_offset[4:6]) 13 | 14 | def tzname(self, dt): 15 | return "UTC" + self._raw_offset 16 | 17 | def utcoffset(self, dt): 18 | return self._sign * timedelta(hours=self._hours, minutes=self._minutes) 19 | 20 | def dst(self, dt): 21 | return timedelta(0) 22 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | urllib3 - Thread-safe connection pooling and re-using. 3 | """ 4 | from __future__ import absolute_import 5 | import warnings 6 | 7 | from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url 8 | 9 | from . import exceptions 10 | from .filepost import encode_multipart_formdata 11 | from .poolmanager import PoolManager, ProxyManager, proxy_from_url 12 | from .response import HTTPResponse 13 | from .util.request import make_headers 14 | from .util.url import get_host 15 | from .util.timeout import Timeout 16 | from .util.retry import Retry 17 | 18 | 19 | # Set default logging handler to avoid "No handler found" warnings. 20 | import logging 21 | from logging import NullHandler 22 | 23 | __author__ = "Andrey Petrov (andrey.petrov@shazow.net)" 24 | __license__ = "MIT" 25 | __version__ = "1.25.8" 26 | 27 | __all__ = ( 28 | "HTTPConnectionPool", 29 | "HTTPSConnectionPool", 30 | "PoolManager", 31 | "ProxyManager", 32 | "HTTPResponse", 33 | "Retry", 34 | "Timeout", 35 | "add_stderr_logger", 36 | "connection_from_url", 37 | "disable_warnings", 38 | "encode_multipart_formdata", 39 | "get_host", 40 | "make_headers", 41 | "proxy_from_url", 42 | ) 43 | 44 | logging.getLogger(__name__).addHandler(NullHandler()) 45 | 46 | 47 | def add_stderr_logger(level=logging.DEBUG): 48 | """ 49 | Helper for quickly adding a StreamHandler to the logger. Useful for 50 | debugging. 51 | 52 | Returns the handler after adding it. 53 | """ 54 | # This method needs to be in this __init__.py to get the __name__ correct 55 | # even if urllib3 is vendored within another package. 56 | logger = logging.getLogger(__name__) 57 | handler = logging.StreamHandler() 58 | handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(message)s")) 59 | logger.addHandler(handler) 60 | logger.setLevel(level) 61 | logger.debug("Added a stderr logging handler to logger: %s", __name__) 62 | return handler 63 | 64 | 65 | # ... Clean up. 66 | del NullHandler 67 | 68 | 69 | # All warning filters *must* be appended unless you're really certain that they 70 | # shouldn't be: otherwise, it's very hard for users to use most Python 71 | # mechanisms to silence them. 72 | # SecurityWarning's always go off by default. 73 | warnings.simplefilter("always", exceptions.SecurityWarning, append=True) 74 | # SubjectAltNameWarning's should go off once per host 75 | warnings.simplefilter("default", exceptions.SubjectAltNameWarning, append=True) 76 | # InsecurePlatformWarning's don't vary between requests, so we keep it default. 77 | warnings.simplefilter("default", exceptions.InsecurePlatformWarning, append=True) 78 | # SNIMissingWarnings should go off only once. 79 | warnings.simplefilter("default", exceptions.SNIMissingWarning, append=True) 80 | 81 | 82 | def disable_warnings(category=exceptions.HTTPWarning): 83 | """ 84 | Helper for quickly disabling all urllib3 warnings. 85 | """ 86 | warnings.simplefilter("ignore", category) 87 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/contrib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_vendor/urllib3/contrib/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/contrib/_appengine_environ.py: -------------------------------------------------------------------------------- 1 | """ 2 | This module provides means to detect the App Engine environment. 3 | """ 4 | 5 | import os 6 | 7 | 8 | def is_appengine(): 9 | return is_local_appengine() or is_prod_appengine() 10 | 11 | 12 | def is_appengine_sandbox(): 13 | """Reports if the app is running in the first generation sandbox. 14 | 15 | The second generation runtimes are technically still in a sandbox, but it 16 | is much less restrictive, so generally you shouldn't need to check for it. 17 | see https://cloud.google.com/appengine/docs/standard/runtimes 18 | """ 19 | return is_appengine() and os.environ["APPENGINE_RUNTIME"] == "python27" 20 | 21 | 22 | def is_local_appengine(): 23 | return "APPENGINE_RUNTIME" in os.environ and os.environ.get( 24 | "SERVER_SOFTWARE", "" 25 | ).startswith("Development/") 26 | 27 | 28 | def is_prod_appengine(): 29 | return "APPENGINE_RUNTIME" in os.environ and os.environ.get( 30 | "SERVER_SOFTWARE", "" 31 | ).startswith("Google App Engine/") 32 | 33 | 34 | def is_prod_appengine_mvms(): 35 | """Deprecated.""" 36 | return False 37 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/contrib/_securetransport/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_vendor/urllib3/contrib/_securetransport/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/filepost.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | import binascii 3 | import codecs 4 | import os 5 | 6 | from io import BytesIO 7 | 8 | from .packages import six 9 | from .packages.six import b 10 | from .fields import RequestField 11 | 12 | writer = codecs.lookup("utf-8")[3] 13 | 14 | 15 | def choose_boundary(): 16 | """ 17 | Our embarrassingly-simple replacement for mimetools.choose_boundary. 18 | """ 19 | boundary = binascii.hexlify(os.urandom(16)) 20 | if not six.PY2: 21 | boundary = boundary.decode("ascii") 22 | return boundary 23 | 24 | 25 | def iter_field_objects(fields): 26 | """ 27 | Iterate over fields. 28 | 29 | Supports list of (k, v) tuples and dicts, and lists of 30 | :class:`~urllib3.fields.RequestField`. 31 | 32 | """ 33 | if isinstance(fields, dict): 34 | i = six.iteritems(fields) 35 | else: 36 | i = iter(fields) 37 | 38 | for field in i: 39 | if isinstance(field, RequestField): 40 | yield field 41 | else: 42 | yield RequestField.from_tuples(*field) 43 | 44 | 45 | def iter_fields(fields): 46 | """ 47 | .. deprecated:: 1.6 48 | 49 | Iterate over fields. 50 | 51 | The addition of :class:`~urllib3.fields.RequestField` makes this function 52 | obsolete. Instead, use :func:`iter_field_objects`, which returns 53 | :class:`~urllib3.fields.RequestField` objects. 54 | 55 | Supports list of (k, v) tuples and dicts. 56 | """ 57 | if isinstance(fields, dict): 58 | return ((k, v) for k, v in six.iteritems(fields)) 59 | 60 | return ((k, v) for k, v in fields) 61 | 62 | 63 | def encode_multipart_formdata(fields, boundary=None): 64 | """ 65 | Encode a dictionary of ``fields`` using the multipart/form-data MIME format. 66 | 67 | :param fields: 68 | Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`). 69 | 70 | :param boundary: 71 | If not specified, then a random boundary will be generated using 72 | :func:`urllib3.filepost.choose_boundary`. 73 | """ 74 | body = BytesIO() 75 | if boundary is None: 76 | boundary = choose_boundary() 77 | 78 | for field in iter_field_objects(fields): 79 | body.write(b("--%s\r\n" % (boundary))) 80 | 81 | writer(body).write(field.render_headers()) 82 | data = field.data 83 | 84 | if isinstance(data, int): 85 | data = str(data) # Backwards compatibility 86 | 87 | if isinstance(data, six.text_type): 88 | writer(body).write(data) 89 | else: 90 | body.write(data) 91 | 92 | body.write(b"\r\n") 93 | 94 | body.write(b("--%s--\r\n" % (boundary))) 95 | 96 | content_type = str("multipart/form-data; boundary=%s" % boundary) 97 | 98 | return body.getvalue(), content_type 99 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import ssl_match_hostname 4 | 5 | __all__ = ("ssl_match_hostname",) 6 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/packages/backports/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunoHost-Apps/ffsync_ynh/c2820e616092cfaef619c9dd37f6c8794fc63659/sources/pip_20.1/_vendor/urllib3/packages/backports/__init__.py -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/packages/backports/makefile.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | backports.makefile 4 | ~~~~~~~~~~~~~~~~~~ 5 | 6 | Backports the Python 3 ``socket.makefile`` method for use with anything that 7 | wants to create a "fake" socket object. 8 | """ 9 | import io 10 | 11 | from socket import SocketIO 12 | 13 | 14 | def backport_makefile( 15 | self, mode="r", buffering=None, encoding=None, errors=None, newline=None 16 | ): 17 | """ 18 | Backport of ``socket.makefile`` from Python 3.5. 19 | """ 20 | if not set(mode) <= {"r", "w", "b"}: 21 | raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,)) 22 | writing = "w" in mode 23 | reading = "r" in mode or not writing 24 | assert reading or writing 25 | binary = "b" in mode 26 | rawmode = "" 27 | if reading: 28 | rawmode += "r" 29 | if writing: 30 | rawmode += "w" 31 | raw = SocketIO(self, rawmode) 32 | self._makefile_refs += 1 33 | if buffering is None: 34 | buffering = -1 35 | if buffering < 0: 36 | buffering = io.DEFAULT_BUFFER_SIZE 37 | if buffering == 0: 38 | if not binary: 39 | raise ValueError("unbuffered streams must be binary") 40 | return raw 41 | if reading and writing: 42 | buffer = io.BufferedRWPair(raw, raw, buffering) 43 | elif reading: 44 | buffer = io.BufferedReader(raw, buffering) 45 | else: 46 | assert writing 47 | buffer = io.BufferedWriter(raw, buffering) 48 | if binary: 49 | return buffer 50 | text = io.TextIOWrapper(buffer, encoding, errors, newline) 51 | text.mode = mode 52 | return text 53 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/packages/ssl_match_hostname/__init__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | try: 4 | # Our match_hostname function is the same as 3.5's, so we only want to 5 | # import the match_hostname function if it's at least that good. 6 | if sys.version_info < (3, 5): 7 | raise ImportError("Fallback to vendored code") 8 | 9 | from ssl import CertificateError, match_hostname 10 | except ImportError: 11 | try: 12 | # Backport of the function from a pypi module 13 | from backports.ssl_match_hostname import CertificateError, match_hostname 14 | except ImportError: 15 | # Our vendored copy 16 | from ._implementation import CertificateError, match_hostname 17 | 18 | # Not needed, but documenting what we provide. 19 | __all__ = ("CertificateError", "match_hostname") 20 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/util/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | # For backwards compatibility, provide imports that used to be here. 4 | from .connection import is_connection_dropped 5 | from .request import make_headers 6 | from .response import is_fp_closed 7 | from .ssl_ import ( 8 | SSLContext, 9 | HAS_SNI, 10 | IS_PYOPENSSL, 11 | IS_SECURETRANSPORT, 12 | assert_fingerprint, 13 | resolve_cert_reqs, 14 | resolve_ssl_version, 15 | ssl_wrap_socket, 16 | PROTOCOL_TLS, 17 | ) 18 | from .timeout import current_time, Timeout 19 | 20 | from .retry import Retry 21 | from .url import get_host, parse_url, split_first, Url 22 | from .wait import wait_for_read, wait_for_write 23 | 24 | __all__ = ( 25 | "HAS_SNI", 26 | "IS_PYOPENSSL", 27 | "IS_SECURETRANSPORT", 28 | "SSLContext", 29 | "PROTOCOL_TLS", 30 | "Retry", 31 | "Timeout", 32 | "Url", 33 | "assert_fingerprint", 34 | "current_time", 35 | "is_connection_dropped", 36 | "is_fp_closed", 37 | "get_host", 38 | "parse_url", 39 | "make_headers", 40 | "resolve_cert_reqs", 41 | "resolve_ssl_version", 42 | "split_first", 43 | "ssl_wrap_socket", 44 | "wait_for_read", 45 | "wait_for_write", 46 | ) 47 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/util/queue.py: -------------------------------------------------------------------------------- 1 | import collections 2 | from ..packages import six 3 | from ..packages.six.moves import queue 4 | 5 | if six.PY2: 6 | # Queue is imported for side effects on MS Windows. See issue #229. 7 | import Queue as _unused_module_Queue # noqa: F401 8 | 9 | 10 | class LifoQueue(queue.Queue): 11 | def _init(self, _): 12 | self.queue = collections.deque() 13 | 14 | def _qsize(self, len=len): 15 | return len(self.queue) 16 | 17 | def _put(self, item): 18 | self.queue.append(item) 19 | 20 | def _get(self): 21 | return self.queue.pop() 22 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/urllib3/util/response.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from ..packages.six.moves import http_client as httplib 3 | 4 | from ..exceptions import HeaderParsingError 5 | 6 | 7 | def is_fp_closed(obj): 8 | """ 9 | Checks whether a given file-like object is closed. 10 | 11 | :param obj: 12 | The file-like object to check. 13 | """ 14 | 15 | try: 16 | # Check `isclosed()` first, in case Python3 doesn't set `closed`. 17 | # GH Issue #928 18 | return obj.isclosed() 19 | except AttributeError: 20 | pass 21 | 22 | try: 23 | # Check via the official file-like-object way. 24 | return obj.closed 25 | except AttributeError: 26 | pass 27 | 28 | try: 29 | # Check if the object is a container for another file-like object that 30 | # gets released on exhaustion (e.g. HTTPResponse). 31 | return obj.fp is None 32 | except AttributeError: 33 | pass 34 | 35 | raise ValueError("Unable to determine whether fp is closed.") 36 | 37 | 38 | def assert_header_parsing(headers): 39 | """ 40 | Asserts whether all headers have been successfully parsed. 41 | Extracts encountered errors from the result of parsing headers. 42 | 43 | Only works on Python 3. 44 | 45 | :param headers: Headers to verify. 46 | :type headers: `httplib.HTTPMessage`. 47 | 48 | :raises urllib3.exceptions.HeaderParsingError: 49 | If parsing errors are found. 50 | """ 51 | 52 | # This will fail silently if we pass in the wrong kind of parameter. 53 | # To make debugging easier add an explicit check. 54 | if not isinstance(headers, httplib.HTTPMessage): 55 | raise TypeError("expected httplib.Message, got {0}.".format(type(headers))) 56 | 57 | defects = getattr(headers, "defects", None) 58 | get_payload = getattr(headers, "get_payload", None) 59 | 60 | unparsed_data = None 61 | if get_payload: 62 | # get_payload is actually email.message.Message.get_payload; 63 | # we're only interested in the result if it's not a multipart message 64 | if not headers.is_multipart(): 65 | payload = get_payload() 66 | 67 | if isinstance(payload, (bytes, str)): 68 | unparsed_data = payload 69 | 70 | if defects or unparsed_data: 71 | raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data) 72 | 73 | 74 | def is_response_to_head(response): 75 | """ 76 | Checks whether the request of a response has been a HEAD-request. 77 | Handles the quirks of AppEngine. 78 | 79 | :param conn: 80 | :type conn: :class:`httplib.HTTPResponse` 81 | """ 82 | # FIXME: Can we do this somehow without accessing private httplib _method? 83 | method = response._method 84 | if isinstance(method, int): # Platform-specific: Appengine 85 | return method == 3 86 | return method.upper() == "HEAD" 87 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/vendor.txt: -------------------------------------------------------------------------------- 1 | appdirs==1.4.3 2 | CacheControl==0.12.6 3 | colorama==0.4.3 4 | contextlib2==0.6.0.post1 5 | distlib==0.3.0 6 | distro==1.5.0 7 | html5lib==1.0.1 8 | ipaddress==1.0.23 # Only needed on 2.6 and 2.7 9 | msgpack==1.0.0 10 | packaging==20.3 11 | pep517==0.8.2 12 | progress==1.5 13 | pyparsing==2.4.7 14 | requests==2.23.0 15 | certifi==2020.04.05.1 16 | chardet==3.0.4 17 | idna==2.9 18 | urllib3==1.25.8 19 | resolvelib==0.3.0 20 | retrying==1.3.3 21 | setuptools==44.0.0 22 | six==1.14.0 23 | toml==0.10.0 24 | webencodings==0.5.1 25 | -------------------------------------------------------------------------------- /sources/pip_20.1/_vendor/webencodings/mklabels.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | webencodings.mklabels 4 | ~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | Regenarate the webencodings.labels module. 7 | 8 | :copyright: Copyright 2012 by Simon Sapin 9 | :license: BSD, see LICENSE for details. 10 | 11 | """ 12 | 13 | import json 14 | try: 15 | from urllib import urlopen 16 | except ImportError: 17 | from urllib.request import urlopen 18 | 19 | 20 | def assert_lower(string): 21 | assert string == string.lower() 22 | return string 23 | 24 | 25 | def generate(url): 26 | parts = ['''\ 27 | """ 28 | 29 | webencodings.labels 30 | ~~~~~~~~~~~~~~~~~~~ 31 | 32 | Map encoding labels to their name. 33 | 34 | :copyright: Copyright 2012 by Simon Sapin 35 | :license: BSD, see LICENSE for details. 36 | 37 | """ 38 | 39 | # XXX Do not edit! 40 | # This file is automatically generated by mklabels.py 41 | 42 | LABELS = { 43 | '''] 44 | labels = [ 45 | (repr(assert_lower(label)).lstrip('u'), 46 | repr(encoding['name']).lstrip('u')) 47 | for category in json.loads(urlopen(url).read().decode('ascii')) 48 | for encoding in category['encodings'] 49 | for label in encoding['labels']] 50 | max_len = max(len(label) for label, name in labels) 51 | parts.extend( 52 | ' %s:%s %s,\n' % (label, ' ' * (max_len - len(label)), name) 53 | for label, name in labels) 54 | parts.append('}') 55 | return ''.join(parts) 56 | 57 | 58 | if __name__ == '__main__': 59 | print(generate('http://encoding.spec.whatwg.org/encodings.json')) 60 | --------------------------------------------------------------------------------