pypiuploader.pypirc Module

Reading .pypirc file.

class RCParser(config_parser)[source]

Bases: object

Parser for the ~/.pypirc file.

Parses the file to find a specified repository’s config:

  • repository URL
  • username
  • password

Example:

>>> parser = RCParser.from_file()
>>> parser.get_repository_config('internal')
{'repository': 'http://localhost/', 'username': 'foo', 'password': 'bar'}
Parameters:config_parserconfigparser.ConfigParser instance with the .pypirc content loaded.
config = None

configparser.ConfigParser instance to parse.

classmethod from_file(path=None)[source]

Read a config file and instantiate the RCParser.

Create new configparser.ConfigParser for the given path and instantiate the RCParser with the ConfigParser as config attribute.

If the path doesn’t exist, raise exceptions.ConfigFileError. Otherwise return a new RCParser instance.

Parameters:path – Optional path to the config file to parse. If not given, use '~/.pypirc'.
get_repository_config(repository)[source]

Get config dictionary for the given repository.

If the repository section is not found in the config file, return None. If the file is invalid, raise configparser.Error.

Otherwise return a dictionary with:

  • 'repository' – the repository URL
  • 'username' – username for authentication
  • 'password' – password for authentication
Parameters:repository – Name or URL of the repository to find in the .pypirc file. The repository section must be defined in the config file.
read_config(path)[source]

Make a config parser for the given config file.

Return a configparser.ConfigParser instance with the given file loaded.

Parameters:path – Path to the config file to read.

Related Topics

This Page