REDROOM
PHP 8.5.2
Path:
Logout
Edit File
Size: 4.42 KB
Close
//lib/python3/dist-packages/launchpadlib/uris.py
Text
Base64
# Copyright 2009 Canonical Ltd. # This file is part of launchpadlib. # # launchpadlib is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the # Free Software Foundation, version 3 of the License. # # launchpadlib is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # for more details. # # You should have received a copy of the GNU Lesser General Public License # along with launchpadlib. If not, see <http://www.gnu.org/licenses/>. """Launchpad-specific URIs and convenience lookup functions. The code in this module lets users say "staging" when they mean "https://api.staging.launchpad.net/". """ __metaclass__ = type __all__ = [ "lookup_service_root", "lookup_web_root", "web_root_for_service_root", ] try: from urllib.parse import urlparse except ImportError: from urlparse import urlparse import warnings from lazr.uri import URI LPNET_SERVICE_ROOT = "https://api.launchpad.net/" QASTAGING_SERVICE_ROOT = "https://api.qastaging.launchpad.net/" STAGING_SERVICE_ROOT = "https://api.staging.launchpad.net/" DEV_SERVICE_ROOT = "https://api.launchpad.test/" DOGFOOD_SERVICE_ROOT = "https://api.dogfood.paddev.net/" TEST_DEV_SERVICE_ROOT = "http://api.launchpad.test:8085/" LPNET_WEB_ROOT = "https://launchpad.net/" QASTAGING_WEB_ROOT = "https://qastaging.launchpad.net/" STAGING_WEB_ROOT = "https://staging.launchpad.net/" DEV_WEB_ROOT = "https://launchpad.test/" DOGFOOD_WEB_ROOT = "https://dogfood.paddev.net/" TEST_DEV_WEB_ROOT = "http://launchpad.test:8085/" # If you use EDGE_SERVICE_ROOT, or its alias, or the equivalent # string, launchpadlib will issue a deprecation warning and use # PRODUCTION_SERVICE_ROOT instead. Similarly for EDGE_WEB_ROOT. EDGE_SERVICE_ROOT = "https://api.edge.launchpad.net/" EDGE_WEB_ROOT = "https://edge.launchpad.net/" service_roots = dict( production=LPNET_SERVICE_ROOT, edge=LPNET_SERVICE_ROOT, qastaging=QASTAGING_SERVICE_ROOT, staging=STAGING_SERVICE_ROOT, dogfood=DOGFOOD_SERVICE_ROOT, dev=DEV_SERVICE_ROOT, test_dev=TEST_DEV_SERVICE_ROOT, ) web_roots = dict( production=LPNET_WEB_ROOT, edge=LPNET_WEB_ROOT, qastaging=QASTAGING_WEB_ROOT, staging=STAGING_WEB_ROOT, dogfood=DOGFOOD_WEB_ROOT, dev=DEV_WEB_ROOT, test_dev=TEST_DEV_WEB_ROOT, ) def _dereference_alias(root, aliases): """Dereference what might a URL or an alias for a URL.""" if root == "edge": warnings.warn( ( "Launchpad edge server no longer exists. " "Using 'production' instead." ), DeprecationWarning, ) if root in aliases: return aliases[root] # It's not an alias. Is it a valid URL? (scheme, netloc, path, parameters, query, fragment) = urlparse(root) if scheme != "" and netloc != "": return root # It's not an alias or a valid URL. raise ValueError( "%s is not a valid URL or an alias for any Launchpad " "server" % root ) def lookup_service_root(service_root): """Dereference an alias to a service root. A recognized server alias such as "staging" gets turned into the appropriate URI. A URI gets returned as is. Any other string raises a ValueError. """ if service_root == EDGE_SERVICE_ROOT: # This will trigger a deprecation warning and use production instead. service_root = "edge" return _dereference_alias(service_root, service_roots) def lookup_web_root(web_root): """Dereference an alias to a website root. A recognized server alias such as "staging" gets turned into the appropriate URI. A URI gets returned as is. Any other string raises a ValueError. """ if web_root == EDGE_WEB_ROOT: # This will trigger a deprecation warning and use production instead. web_root = "edge" return _dereference_alias(web_root, web_roots) def web_root_for_service_root(service_root): """Turn a service root URL into a web root URL. This is done heuristically, not with a lookup. """ service_root = lookup_service_root(service_root) web_root_uri = URI(service_root) web_root_uri.path = "" web_root_uri.host = web_root_uri.host.replace("api.", "", 1) web_root = str(web_root_uri.ensureSlash()) return web_root
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 3 × Files: 6
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
testing
DIR
-
drwxr-xr-x
2026-01-08 12:56:19
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
tests
DIR
-
drwxr-xr-x
2026-01-08 12:56:19
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__pycache__
DIR
-
drwxr-xr-x
2026-01-08 12:56:19
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
apps.py
1.54 KB
lrw-r--r--
2021-11-17 01:30:15
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
credentials.py
30.34 KB
lrw-r--r--
2021-11-17 09:42:31
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
errors.py
805 B
lrw-r--r--
2021-10-29 13:45:13
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
launchpad.py
29.26 KB
lrw-r--r--
2022-01-21 14:12:11
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
uris.py
4.42 KB
lrw-r--r--
2021-11-05 22:40:06
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
848 B
lrw-r--r--
2021-10-26 12:15:53
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).