twine.package module#

twine.package._safe_name(name: str) str[source]#

Convert an arbitrary string to a standard distribution name.

Any runs of non-alphanumeric/. characters are replaced with a single ‘-‘.

Copied from pkg_resources.safe_name for compatibility with warehouse. See https://github.com/pypa/twine/issues/743.

class twine.package.PackageFile[source]#
__init__(filename: str, comment: Optional[str], metadata: Distribution, python_version: Optional[str], filetype: Optional[str]) None[source]#
classmethod from_filename(filename: str, comment: Optional[str]) PackageFile[source]#
metadata_dictionary() Dict[str, Union[str, None, Sequence[str], Tuple[str, bytes]]][source]#

Merge multiple sources of metadata into a single dictionary.

Includes values from filename, PKG-INFO, hashers, and signature.

add_gpg_signature(signature_filepath: str, signature_filename: str) None[source]#
sign(sign_with: str, identity: Optional[str]) None[source]#
classmethod run_gpg(gpg_args: Tuple[str, ...]) None[source]#
class twine.package.Hexdigest[source]#

Hexdigest(md5, sha2, blake2)

property md5#

Alias for field number 0

property sha2#

Alias for field number 1

property blake2#

Alias for field number 2

static __new__(_cls, md5: Optional[str], sha2: Optional[str], blake2: Optional[str])#

Create new instance of Hexdigest(md5, sha2, blake2)

_asdict()#

Return a new OrderedDict which maps field names to their values.

_field_defaults = {}#
_field_types = {'blake2': typing.Union[str, NoneType], 'md5': typing.Union[str, NoneType], 'sha2': typing.Union[str, NoneType]}#
_fields = ('md5', 'sha2', 'blake2')#
_fields_defaults = {}#
classmethod _make(iterable)#

Make a new Hexdigest object from a sequence or iterable

_replace(**kwds)#

Return a new Hexdigest object replacing specified fields with new values

class twine.package.HashManager[source]#

Manage our hashing objects for simplicity.

This will also allow us to better test this logic.

__init__(filename: str) None[source]#

Initialize our manager and hasher objects.

_md5_update(content: bytes) None[source]#
_md5_hexdigest() Optional[str][source]#
_sha2_update(content: bytes) None[source]#
_sha2_hexdigest() Optional[str][source]#
_blake_update(content: bytes) None[source]#
_blake_hexdigest() Optional[str][source]#
hash() None[source]#

Hash the file contents.

hexdigest() Hexdigest[source]#

Return the hexdigest for the file.