cheerio

package module
v0.0.0-...-51367fc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2014 License: Apache-2.0 Imports: 10 Imported by: 0

README

cheerio

A set of extensions to Python's pip.

Install

Cheerio requires Go.

go install github.com/beyang/cheerio/...

Usage

Usage information: cheerio -h

Examples
%> cheerio repo flask
http://github.com/mitsuhiko/flask
%> cheerio reqs flask-celery
pkg flask-celery uses (3):
  flask flask-script celery
and is used by (1):
    bundle-celery
Regenerate data

The cheerio reqs subcommand uses a cached data file to get backward dependencies for PyPI packages. This file is located in the data/ directory. It can be regenerated with cheerio reqs-generate > <cache-file>. You can also specify the cache file optionally as in cheerio reqs -graphfile=<cache-file> <package-name>.

Known issues

  • Does not correctly parse requirements for PyPI packages that contain multiple top-level packages (this is fairly rare)

TODO

  • mock pypi and add more unit tests

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPyPI = &PackageIndex{URI: "https://pypi.python.org"}

Functions

func NormalizedPkgName

func NormalizedPkgName(pkg string) string

Normalizes package names so they are comparable

Types

type PackageIndex

type PackageIndex struct {
	URI string
}

func (*PackageIndex) AllPackages

func (p *PackageIndex) AllPackages() ([]string, error)

Get names of all packages served by a PyPI server.

func (*PackageIndex) FetchPackageRequirements

func (p *PackageIndex) FetchPackageRequirements(pkg string) ([]*Requirement, error)

Fetches package requirements from PyPI by downloading the package archive and extracting the requires.txt file. If no such file exists (sometimes it doesn't), returns an error.

func (*PackageIndex) FetchRawMetadata

func (p *PackageIndex) FetchRawMetadata(pkg string, tarPattern, eggPattern, zipPattern *regexp.Regexp) ([]byte, error)

func (*PackageIndex) FetchSourceRepoURL

func (p *PackageIndex) FetchSourceRepoURL(pkg string) (string, error)

Returns the source repository URL for a given PyPI package. This information is not explicitly specified anywhere in PyPI metadata, so try to infer it by doing the following: First, check if it is hardcoded below. If not, then fetch the metadata from the PyPI server and check if the website (specified in the metdata) pattern matches a repository URL.

func (*PackageIndex) FetchSourceTopLevelModules

func (p *PackageIndex) FetchSourceTopLevelModules(pkg string) ([]string, error)

Returns the top-level modules for a given PyPI package. This information is typically stored in the PyPI metadata, which is fetched from the remote PyPI server. In some cases where the information is unavailable in the metadata, it has been hard-coded below.

type PyPIGraph

type PyPIGraph struct {
	Req   map[string][]string
	ReqBy map[string][]string
}

Dependency graph over repositories in a given Python Package Index.

var DefaultPyPIGraph *PyPIGraph

func NewPyPIGraph

func NewPyPIGraph(file string) (*PyPIGraph, error)

Deserializes a PyPIGraph stored in a file

func (*PyPIGraph) RequiredBy

func (p *PyPIGraph) RequiredBy(pkg string) []string

func (*PyPIGraph) Requires

func (p *PyPIGraph) Requires(pkg string) []string

type Requirement

type Requirement struct {
	Name       string
	Constraint string
	Version    string
}

func ParseRequirement

func ParseRequirement(reqStr string) (*Requirement, error)

Parse a single raw requirement, e.g., from "flask=1.0.1"

func ParseRequirements

func ParseRequirements(rawReqs string) ([]*Requirement, error)

Parse requirements from a raw string in the requirements format expected by pip (e.g., in requirements.txt)

func RequirementsForDir

func RequirementsForDir(dir string) ([]*Requirement, error)

Return requirements for python PyPI package in directory

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL