pryv.core
¶
This package defines the core modules of pryv. Those are related to projects and packages management.
pryv.core.project
¶
This module defines the Project
class and functions related to project
retrieval or creation.
-
class
pryv.core.project.
Project
(name)¶ Bases:
object
This class defines a project.
It uses lazy loading for the
packages
andreleases
attributes.-
__init__
(name)¶ Creates a new instance of a project.
Parameters: name ( str
) – The name of the project.
-
add_release
(metadata)¶ Adds a release with the given metadata to the project.
Parameters: metadata ( Metadata
) – The metadata of the release.Returns: The added release. Return type: Release
-
normalized_name
¶ The project’s normalized name.
Returns: The normalized name. Return type: str
-
packages
¶ The packages of the project.
Returns: The packages. Return type: list
-
releases
¶ The releases of the project.
Returns: The releases. Return type: list
-
url
¶ The URL to the project.
Returns: The URL. Return type: str
-
-
pryv.core.project.
create
(metadata)¶ Creates a project with the given metadata.
Parameters: metadata ( pryv.core.metadata.Metadata
) – The metadata of the project.Returns: The created project. Return type: Project
-
pryv.core.project.
find
(name=None, normalized_name=None)¶ Finds the project with the given name or normalized name.
Parameters: - name (
str
) – The name of the project. - normalized_name (
str
) – The normalized name of the project.
Returns: The project if found;
None
otherwise.Return type: Project
orNone
- name (
-
pryv.core.project.
find_all
()¶ Finds all projects.
Returns: A list of projects. Return type: list
pryv.core.release
¶
This module defines the Release
class.
A release is equivalent to a version of a project. It can contain several packages.
-
class
pryv.core.release.
Release
(name, project_name)¶ Bases:
object
This class defines a release of a project.
It uses lazy loading for the
timestamp
,metadata
andpackages
attributes.-
__init__
(name, project_name)¶ Creates a new instance of a release.
Parameters: - name (
str
) – The name of the release (its vernum). - project_name (
str
) – The name of the project.
- name (
-
add_package
(package_name, package_stream, package_hash)¶ Adds a package to the release.
Parameters: - package_name (
str
) – The name of the package. - package_stream (
stream
) – The stream of the package. - package_hash (
dict
) – The dictionary of hash of the package.
Returns: The package if successful;
None
otherwise.Return type: - package_name (
-
html_description
¶ The HTML description of the package.
Returns: The HTML description. Return type: str
-
packages
¶ The packages of the release.
Returns: The packages. Return type: list
-
save
(new_metadata=None)¶ Saves the release to the filesystem.
If the
new_metadata
parameter is given, this method saves the release with the given one; otherwise, it saves the release with the already stored metadata on the file system.Parameters: new_metadata – The new metadata. Type: Metadata
-
timestamp
¶ The timestamp of the release.
Returns: The timestamp. Return type: datetime.datetime
-
pryv.core.metadata
¶
This module defines the Metadata
class.
Metadata describe a release of a project.
See also
- PEP 566 – Metadata for Python Software Packages 2.1 | Python.org
- Official python’s documentation for a packages metadata.
-
class
pryv.core.metadata.
Metadata
(fields)¶ Bases:
object
This class defines the metadata of a project.
-
__init__
(fields)¶ Creates a new instance of a metadata object.
Parameters: fields ( dict
) – The fields of the metadata.
-
static
deserialize
(raw)¶ Deserializes a raw dictionary into an instance of metadata.
Parameters: raw ( dict
) – The raw dictionary to deserialize.Returns: An instance of metadata. Return type: Metadata
-
serialize
()¶ Serializes the metadata to a dictionary.
Returns: A serialized package. Return type: dict
-
pryv.core.package
¶
This module defines the Package
class.
A package is a file that contains a distribution. It is linked to a release of a project.
-
class
pryv.core.package.
Package
(name, file_hash=None, file_size=None)¶ Bases:
object
This class defines a package of a project’s release.
-
__init__
(name, file_hash=None, file_size=None)¶ Creates a new instance of a package.
Parameters: - name (
str
) – The name of the package (its file name). - file_hash (
str
) – The hash of the package’s file (its SHA256 digest). - file_size (
int
) – The size of the package’s file (the number of bytes).
- name (
-
static
deserialize
(raw)¶ Deserializes a raw dictionary into an instance of a package.
Parameters: raw ( dict
) – The raw dictionary to deserialize.Returns: An instance of a package. Return type: Package
-
exists
¶ Gets a value indicating whether the package exists or not.
Returns: True
if the package exists;False
otherwise.Return type: bool
-
file
¶ Gets the file of the package.
Returns: The file of the package. Return type: File
-
save
(file_stream, file_hash)¶ Saves the package.
Depending on the tool used to upload the package (e.g. setuptools, twine), the provided hash might differ. In some situations only md5 might be available (setuptools), in others both md5 and sha256 are available (twine). In any cases, this method computes the hash and check their digest for each provided hash name and value. Note that if no hash is provided (i.e. an empty dictionary is provided), no hash check is performed.
Parameters: - file_stream (
File
) – The byte stream of the package’s file. - file_hash (
dict
) – The hash map of the package’s file.
- file_stream (
-
serialize
()¶ Serializes the package to a dictionary.
Returns: A serialized package. Return type: dict
-
url
¶ The URL to the package.
Returns: The URL. Return type: str
-