๐ Application Programming Interface#
galactic.helpers.market.core
module.
- class Market#
Bases:
Cache
Singleton class representing a market of proxies managing cached packages.
- __init__()#
Initialize the Market instance.
- add_proxy(proxy)#
Add a new proxy to the market.
- Parameters:
proxy (Proxy) โ The Proxy instance to add.
- Raises:
TypeError โ If proxy is not an instance of Proxy.
ValueError โ If a proxy with the same name or url already exists.
- Return type:
- get_proxy(name)#
Get a proxy by its name.
- Parameters:
name (str) โ The name of the proxy to retrieve.
- Returns:
The Proxy instance with the specified name.
- Return type:
- Raises:
TypeError โ If name is not a string.
ValueError โ If the proxy does not exist.
- load_proxy(name)#
Load the proxy by downloading the latest packages from the remote index.
- Raises:
RuntimeError โ If the download fails for any package.
- Return type:
- remove_proxy(name)#
Remove a proxy by its name.
- Parameters:
name (str) โ The name of the proxy to remove.
- Raises:
TypeError โ If name is not a string.
ValueError โ If the proxy does not exist.
PermissionError โ If trying to remove a system-level proxy.
- Return type:
- save_proxy(name)#
Save the proxy metadata to the proxies.json file.
- Parameters:
name (str) โ The name of the proxy to save.
- Raises:
TypeError โ If name is not a string.
ValueError โ If the proxy does not exist.
- Return type:
- unload_proxy(name)#
Unload the proxy by removing its cached packages.
- unsave_proxy(name)#
Remove the proxy metadata from the proxies.json file.
- Parameters:
name (str) โ The name of the proxy to remove.
- Raises:
TypeError โ If name is not a string.
ValueError โ If the proxy does not exist.
- Return type:
- class Proxy(name, summary, url, is_system=False, created_at=None, loaded_at=None, package_count=None, access_level=None)#
Bases:
object
Class representing a proxy for managing Python package repositories.
- property access_level: str#
Get the access level of the proxy.
- Returns:
The access level of the proxy.
- Return type:
- property created_at: datetime#
Get the timestamp when the proxy was created.
- Returns:
The creation timestamp in ISO 8601 format.
- Return type:
datetime
- fetch_access_level()#
Determine the access level of the proxy by performing an HTTP GET request.
- Returns:
One of the following access levels: - โpublicโ: accessible without authentication (HTTP 200) - โprotectedโ: requires authentication but is free (HTTP 401) - โpaidโ: requires payment for access (HTTP 402) - โprivateโ: requires special permissions (HTTP 403) - โnetwork_errorโ: if a network error occurs
- Return type:
- fetch_package_count()#
Get the number of packages available in the proxy.
- Returns:
The number of packages in the proxy, or -1 if an error occurs.
- Return type:
- property is_system: bool#
Check if the proxy is a system-level proxy.
- Returns:
True if the proxy is system-level, False otherwise.
- Return type:
- property loaded_at: datetime#
Get the timestamp when the proxy was last updated.
- Returns:
The last updated timestamp in ISO 8601 format.
- Return type:
datetime
- property package_count: int#
Get the number of packages available in the proxy.
- Returns:
The number of packages in the proxy.
- Return type:
- class Cache#
Bases:
object
Utility class for managing cached Python packages.
- static find_matching_packages(**criteria)#
Find packages in the cache matching given criteria.
- static get_package(name)#
Find package metadata by name using fuzzy matching.
- Parameters:
name (str) โ The name of the package to search for (without version).
- Returns:
Metadata dictionary of the closest matching package.
- Return type:
- Raises:
FileNotFoundError โ If no matching package is found in the cache.
- static get_packages()#
List all wheel packages grouped by proxy folder.
- static get_proxy_packages(name)#
List all wheel packages for a given proxy name.
- static install_package(name, extra_index_urls=None)#
Install a package by name using fuzzy matching.
- Parameters:
- Returns:
The name of the installed package file.
- Return type:
- Raises:
TypeError โ If name is not a string or extra_index_urls is not a list of strings.
FileNotFoundError โ If no matching package is found in the cache.
RuntimeError โ If pip is not installed or fails to install the package.
subprocess.CalledProcessError โ If the pip install command fails.
- static purge_cache()#
Purge the entire cache directory by removing it and recreating it.
- Return type: