pep440

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package pep440 implements types for working with versions as defined in PEP-440.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Range

type Range []criterion

Range is a set of criteria corresponding to a range of versions.

func ParseRange

func ParseRange(r string) (Range, error)

ParseRange takes a version specifer as described in PEP-440 and turns it into a Range, with the following exceptions:

Wildcards are not implemented.

Arbtrary matching (===) is not implemented.

func (Range) AND

func (r Range) AND(n Range) Range

AND returns a Range that is the logical AND of the two Ranges.

func (Range) Match

func (r Range) Match(v *Version) bool

Match reports whether the passed-in Version matches the Range.

func (Range) String

func (r Range) String() string

type Version

type Version struct {
	Epoch   int
	Release []int
	Pre     struct {
		Label string
		N     int
	}
	Post int
	Dev  int
}

Version repesents a canonical-ish represention of a PEP440 version.

Local revisions are discarded.

func Parse

func Parse(s string) (v Version, err error)

Parse attempts to extract a PEP-440 version string from the provided string.

func (*Version) Compare

func (a *Version) Compare(b *Version) int

Compare returns an integer comparing two versions. The result will be 0 if a == b, -1 if a < b and +1 if a > b.

func (*Version) String

func (v *Version) String() string

String returns the canonicalized representation of the Version.

func (*Version) Version

func (v *Version) Version() (c claircore.Version)

Version returns a fixed-width slice of integers meant for allowing some amount of version comparision with no knowledge of the version scheme.

In generating this slice, the following rules are applied:

Release is normalized to five numbers. Missing numbers are set to "0" and additional numbers are dropped.

The Dev revision is promoted earlier in the int slice if there's no Pre or Post revision, and sorts as earlier than a Pre revision.

type Versions

type Versions []Version

Versions implements sort.Interface.

func (Versions) Len

func (vs Versions) Len() int

func (Versions) Less

func (vs Versions) Less(i, j int) bool

func (Versions) Swap

func (vs Versions) Swap(i, j int)

Notes

Bugs

  • The int-slice versioning method tries to accomdate arbitrary numbers, but may give odd results with sufficiently large revision numbers. One suggested workaround is to make fewer than 9 quintillion releases.

Jump to

Keyboard shortcuts

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