PEP Validation partis.pyproj.pep#

class CompatibilityTags(py_tag, abi_tag, plat_tag)#

Bases: tuple

abi_tag#

Alias for field number 1

plat_tag#

Alias for field number 2

py_tag#

Alias for field number 0

exception PEPValidationError(*, pep, msg, val)[source]#

Bases: ValidationError

Error from value incompatible with a PEP

Parameters:
  • pep (int) – The referenced PEP number

  • msg (str) – Error message

  • val (object) – Value that was being validated

norm_printable(text=None)[source]#

Removes leading and trailing whitespace and all non-printable characters, except for newlines ‘\n’ and tabs ‘\t’.

Parameters:

text (None | str) – If None, an empty string is returned.

Returns:

str

Note

While not explicitly stated in any PEP, it is implied through referenced RFCs and other assumptions that text in package meta-data should only contain printable unicode characters.

Example

import re
from partis.pyproj import norm_printable

x = ''.join([ chr(i) for i in range(50) ])
print( x.isprintable() )

y = norm_printable(x)
print( y.isprintable() )

z = re.sub(r'[\t\n]', '', y)
print( z.isprintable() )

print( norm_printable(None) )
print( norm_printable('f\ubaaar') )
valid_dist_name(name)[source]#

Checks for valid distribution name (PEP 426)

norm_dist_name(name)[source]#

Normalizes a distribution name (PEP 503)

Note

The name should be lowercased with all runs of the characters ., -, or _ replaced with a single - character.

norm_dist_filename(name)[source]#

Normalize distribution filename component (PEP 427)

Note

Each component of the filename is escaped by replacing runs of non-alphanumeric characters with an underscore ‘_’

join_dist_filename(parts)[source]#

Joins distribution filename component (PEP 427)

Note

Each component of the filename is joined by ‘-’

norm_dist_version(version)[source]#

Checks for valid distribution version (PEP 440)

norm_dist_author(name=None, email=None)[source]#

Checks for valid distribution author/maintainer name/email (PEP 621)

  • The name value MUST be a valid email name (i.e. whatever can be put as a name, before an email, in RFC #822) and not contain commas.

  • If only name is provided, the value goes in Author/Maintainer as appropriate.

  • If only email is provided, the value goes in Author-email/Maintainer-email as appropriate.

  • If both email and name are provided, the value goes in Author-email/Maintainer-email as appropriate, with the format {name} <{email}> (with appropriate quoting, e.g. using email.headerregistry.Address).

    Note

    The returned name field will be empty in this case.

Parameters:
Returns:

  • name (str)

  • email (str)

norm_dist_classifier(classifier)[source]#
norm_dist_keyword(keyword)[source]#
norm_dist_url(label, url)[source]#
norm_dist_extra(extra)[source]#

Normalize distribution ‘extra’ requirement

Note

  • No known PEP specifies this format, but is treated as

norm_dist_build(build)[source]#

Note

  • Must start with a digit, remainder is ASCII alpha-numeric

norm_dist_compat(py_tag, abi_tag, plat_tag)[source]#

Note

  • Tags must contain only ASCII alpha-numeric or underscore

  • platform tag with all hyphens - and periods . replaced with underscore _.

join_dist_compat(tags)[source]#
compress_dist_compat(compat)[source]#
purelib_compat_tags()[source]#

Return general compatability tags for the current system

platlib_compat_tags()[source]#

Get platform compatability tags for the current system

norm_entry_point_group(name)[source]#

Normalizes entry point group

norm_entry_point_name(name)[source]#

Normalizes entry point name

norm_entry_point_ref(ref)[source]#

Normalizes entry point object reference