Extract package information for a given user in PyPi.
Project description
Overview
PyPI Extractor is a Python package designed to fetch and process detailed information about packages hosted on the Python Package Index (PyPI). This package is particularly useful for users who want to retrieve and analyze metadata for packages maintained by a specific PyPI user.
Features
- Retrieve a list of packages maintained by a specific PyPI user.
- Fetch detailed metadata for each package, including versions, author information, dependencies, and more.
- Custom exceptions for handling errors gracefully.
- Option to set the PyPI username after initializing the class.
Installation
You can install the package using pip:
pip install wolfsoftware.pypi-extractor
Usage
Basic Usage
Here's a basic example of how to use the PyPI Extractor:
from wolfsoftware.pypi_extractor import PyPiExtractor
# Initialize without username
pypi_info = PyPiExtractor()
# Set username later
pypi_info.set_username("your_pypi_username")
# Get detailed information for all packages
try:
packages_details = pypi_info.get_all_packages_details()
print(packages_details)
except PyPiExtractorError as e:
print(f"An error occurred: {e.message}")
Setting Username During Initialization
You can also set the username during initialization:
pypi_info = PyPiExtractor("your_pypi_username")
Retrieving User Packages
You can retrieve a list of packages maintained by a specific user:
packages = pypi_info.get_user_packages()
print(packages)
Retrieving Package Details
To get detailed information about a specific package:
package_details = pypi_info.get_package_details("package_name")
print(package_details)
API Reference
Classes
PyPiExtractor
A class to fetch and process package details for a given PyPI user.
__init__(self, username: str)
- Initializes the
PyPiExtractor
with a username. - Parameters:
username
(str): The PyPI username.
- Raises:
PyPiExtractorError
: If the username is not provided.
set_username(self, username: str)
- Sets the PyPI username.
- Parameters:
username
(str): The PyPI username.
- Raises:
PyPiExtractorError
: If the username is not provided.
get_user_packages(self) -> list
- Fetches the list of packages for the given PyPI user.
- Returns:
list
: A list of dictionaries containing package names and summaries.
- Raises:
PyPiExtractorError
: If there is an error fetching or parsing the user profile.
get_package_details(self, package_name: str) -> dict
- Fetches detailed information for a specific package.
- Parameters:
package_name
(str): The name of the package.
- Returns:
dict
: A dictionary containing detailed information about the package.
- Raises:
PyPiExtractorError
: If there is an error fetching or parsing the package details.
get_all_packages_details(self) -> list
- Fetches detailed information for all packages of the given PyPI user.
- Returns:
list
: A list of dictionaries containing detailed information about each package.
- Raises:
PyPiExtractorError
: If there is an error fetching or processing the package details.
PyPiExtractorError
Custom exception class for PyPiExtractor
errors.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wolfsoftware_pypi_extractor-0.1.2.tar.gz
.
File metadata
- Download URL: wolfsoftware_pypi_extractor-0.1.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19532b30e44674ce98ace393bf9247f6f7a96c269fb4b07c7ab6628abae75dd6 |
|
MD5 | c81e7b3cfd6759520782423d47c26576 |
|
BLAKE2b-256 | b7b1c663ee3d339ce2945892d0ac939add66adf661bea44594c805f5e052bd05 |
Provenance
File details
Details for the file wolfsoftware.pypi_extractor-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: wolfsoftware.pypi_extractor-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47fdb0f03ded947043e9ca1cca7ce69e33edc9e1431ace169b5038279c73f5c7 |
|
MD5 | 3a6d7f4ddfe17ae58e176fb6e96f0489 |
|
BLAKE2b-256 | fa21acd87d5489668fef49d294c241ac7a532a7f7749d9cdae1c9cbdd8c0addb |