twine.utils module#
- twine.utils.get_config(path: str) Dict[str, Dict[str, Optional[str]]] [source]#
Read repository configuration from a file (i.e. ~/.pypirc).
Format: https://packaging.python.org/specifications/pypirc/
If the default config file doesn’t exist, return a default configuration for pypyi and testpypi.
- twine.utils._validate_repository_url(repository_url: str) None [source]#
Validate the given url for allowed schemes and components.
- twine.utils.get_repository_from_config(config_file: str, repository: str, repository_url: Optional[str] = None) Dict[str, Optional[str]] [source]#
Get repository config command-line values or the .pypirc file.
- twine.utils.get_file_size(filename: str) str [source]#
Return the size of a file in KB, or MB if >= 1024 KB.
- twine.utils.check_status_code(response: Response, verbose: bool) None [source]#
Generate a helpful message based on the response from the repository.
Raise a custom exception for recognized errors. Otherwise, print the response content (based on the verbose option) before re-raising the HTTPError.
- twine.utils.get_userpass_value(cli_value: Optional[str], config: Dict[str, Optional[str]], key: str, prompt_strategy: Optional[Callable[[], str]] = None) Optional[str] [source]#
Get a credential (e.g. a username or password) from the configuration.
Uses the following rules:
If
cli_value
is specified, use that.If
config[key]
is specified, use that.If
prompt_strategy
is specified, use its return value.Otherwise return
None
- Parameters:
cli_value – The value supplied from the command line.
config – A dictionary of repository configuration values.
key – The credential to look up in
config
, e.g."username"
or"password"
.prompt_strategy – An argumentless function to get the value, e.g. from keyring or by prompting the user.
- Returns:
The credential value, i.e. the username or password.
- twine.utils.get_cacert(cli_value: Optional[str], config: Dict[str, Optional[str]], *, key: str = 'ca_cert', prompt_strategy: Optional[Callable[[], str]] = None) Optional[str] #
Get the CA bundle via
get_userpass_value()
.
- twine.utils.get_clientcert(cli_value: Optional[str], config: Dict[str, Optional[str]], *, key: str = 'client_cert', prompt_strategy: Optional[Callable[[], str]] = None) Optional[str] #
Get the client certificate via
get_userpass_value()
.