For a package, locate its source repository url and its relative path within the repository
Project description
Features
For a given package, package-locator locates its source code repository and the sub-directory within the repository the package resides in.
Covers packages from npm, PyPI, RubyGems, Composer, and Cargo.
Locates repository from metadata collected from registry APIs.
Validates repository and locates sub-directory through a set of heuristics for each package ecosystem. For npm, Composer, and Cargo packages, package-locator looks at the manifest file (
package.json
,composer.json
, andCargo.toml
) to locate package specific code. For RubyGems and PyPI packages, package-locator either looks at the manifest file (gemspec
file) or compares the files present in the registry with the files present in the repository.
Installation
You can install package-locator via pip from PyPI:
$ pip install package-locator
Usage
from package_locator.locator import get_repository_url_and_subdir
is the primary function offered by package-locator. The function takes two inputs - ecosystem and package. The ecosystem names need to be provided as per defined within package-locator. You can import from package-locator.common import CARGO, NPM, PYPI, COMPOSER, RUBYGEMS
and then use the constant values to indicate the ecosystem name. The function returns the source code repository URL and the sub-directory within the repository where the input package resides in. For example, get_repository_url_and_subdir(NPM, "react")
call returns ("https://github.com/facebook/react", "./packages/react")
.
Credits
This package was created with cookietemple using Cookiecutter based on Hypermodern_Python_Cookiecutter.
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
Hashes for package_locator-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 114299909aaa6b05c2d2f9afd15789061053f903c291d733ab9dbfe36767d8c9 |
|
MD5 | ccff1fd026435474cfc349b996af113c |
|
BLAKE2b-256 | de62b3d9a223587457018d0ccd06ccc0b1766389feb15293c02c35977b3b90a7 |