Value Normalization partis.pyproj.norms#
- class scalar_list(vals=None)[source]#
Bases:
valid_list
- class str_list(vals=None)[source]#
Bases:
valid_list
- class nonempty_str_list(vals=None)[source]#
Bases:
valid_list
- norm_path(path)[source]#
Normalizes a file path for writing into a distribution archive
Note
Must be a valid path
Must be relative, and no reference to parent any directory (e.g. ‘..’)
May not contain any white-space in path components
All slashes replaced with forward slashes
- norm_mode(mode=None)[source]#
Normalizes file permission mode for distribution archive
Note
The returned mode is either
0o644(rw-r–r–), or 0o755 (rwxr-xr-x) ifmode & stat.S_IXUSR == TrueExample
from partis.pyproj import norm_mode print( norm_mode( 0o000 ) == 0o644 ) print( norm_mode( 0o100 ) == 0o755 )
- norm_zip_external_attr(mode=None)[source]#
Converts the unix integer mode to zip external_attr
The returned value follows the 4 byte format
|mm|mm|xx|dx|The file permission mode is masked and shifted to the two most significant bytes. If specified as a directory, the second bit is set.
- hash_sha256(stream)[source]#
Computes SHA-256 hash
- Parameters:
stream¶ (bytes | io.BytesIO) –
- Returns:
str, int – urlsafe base64 encoded hash, and size (in bytes) of the hashed data
See also
hashlib.sha256()