maven

Maven repository utilities.

Module Contents

Classes

MavenLink

Represent Maven package download link with metadata.

MavenLinksParser

Parser for Maven repository metadata XML to extract package links.

Maven

Interface to Maven repository for package discovery and download.

Attributes

logger

maven.logger

Represent Maven package download link with metadata.

property sha1_checksum: str | None

Retrieve the SHA1 checksum of a package if any.

Returns:

The SHA1 checksum if possible, otherwise None.

property md5_checksum: str | None

Retrieve the MD5 checksum of a package if any.

Returns:

The MD5 checksum if possible, otherwise None.

property pom_sha1_checksum: str | None

Retrieve the SHA1 checksum of a package’s POM file if any.

Returns:

The SHA1 checksum if possible, otherwise None.

property pom_md5_checksum: str | None

Retrieve the MD5 checksum of a package’s POM file if any.

Returns:

The MD5 checksum if possible, otherwise None.

BASE_URL = 'https://repo.maven.apache.org/maven2'
_DEFAULT_SESSION
__init_pkg_checksum() None

Retrieve package checksums.

This private method is used to initialise lazily the package checksum.

__init_pom_checksum() None

Retrieve POM checksums.

This private method is used to lazily initialise the checksum of the package’s POM file.

class maven.MavenLinksParser(group: str, name: str, *, session: requests.Session | None = None)

Parser for Maven repository metadata XML to extract package links.

start(tag: str, attrs: dict[str, str | None]) None

See XMLParser.start.

Parameters:
  • tag – XML tag name

  • attrs – XML tag attributes

Note

The attrs parameter is not used by this method implementation, but is defined by XMLParser.start method signature.

data(text: str) None

See XMLParser.data.

Parameters:

text – text data from XML

feed(data: str) MavenLinksParser

See HTMLParser.feed.

This class doesn’t use the HTMLParser, but this method as the exact same function and logic that HTMLParser.feed.

Parameters:

data – XML data to parse

class maven.Maven(url: str = MavenLink.BASE_URL)

Interface to Maven repository for package discovery and download.

_DEFAULT_SESSION

Fetch list of resources for a given Maven package.

Parameters:
  • group – Maven group ID

  • name – Maven package name

  • headers – To add additionnal headers to the HTTP request. Can be mandatory depending on the situation.

  • session – The session object to use to make HTTP requests.

Returns:

a list of dict containing the link to each resource along with some metadata