Package entropy :: Package core :: Package settings :: Module base :: Class RepositoryConfigParser

Class RepositoryConfigParser

source code


Entropy .ini-like repository configuration file parser.

This is backward compatible with the previous repository
implementation, in the sense that old repository syntax
is just ignored. However, a mix of old and new statements
may result in an undefined behaviour.

This is an example of the new syntax (with a complete listing
of the supported arguments):

[sabayon-limbo]
desc = Sabayon Linux Official Testing Repository
repo = http://pkg.sabayon.org
repo = http://pkg.repo.sabayon.org
pkg = http://pkg.sabayon.org
pkg = http://dl.sabayon.org/entropy
enabled = <true/false>

[sabayon-limbo]
desc = This statement will be ignored.
repo = This url will be ignored.
pkg = http://some.more.mirror.org/entropy
pkg = http://some.more.mirror.net/entropy

As you can see, multiple statements for the same repository
are allowed. However, only the first desc = statement will be
considered, while there can be as many pkg = and repo = as you
want.

Statements description:
- "desc": stands for description, the repository name description.
- "repo": the repository database URL string, plus other parameters
          as supported in the previous configuration file syntax:
          <db url prefix>[#<compression>].
- "pkg": the repository packages URL string. This must be a valid URL.
         The supported protocols are those supported by entropy.fetchers.
- "enabled": if set, its value can be either "true" or "false". The default
             value is "true". It indicates if a repository is configured
             but currently disabled or enabled. Please take into account
             that config files in /etc/entropy/repositories.conf.d/ starting
             with "_" are considered to contain disabled repositories. This
             is just provided for convienence.
- "username": if set, it used for HTTP Basic Authentication on retrieve
              data from remote repository.
- "password": if set, it used for HTTP Basic Authentication on retrieve
              data from remote repository.
- "https_validate_cert": if set to "false" disable ssl certificate
              validation of the remote repository.

Instance Methods
new empty dictionary

__init__(self, encoding=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
bool
add(self, repository_id, desc, repos, pkgs, enabled=True, username=None, password=None, https_validate_cert=True)
Add a repository to the repository configuration files directory.
source code
bool
remove(self, repository_id)
Remove a repository from the repositories configuration files directory.
source code
bool
enable(self, repository_id)
Enable a repository.
source code
bool
disable(self, repository_id)
Disable a repository.
source code
 
write(self, path, repository_id, desc, repos, pkgs, enabled=True, username=None, password=None, https_validate_cert=True)
Write the repository configuration to the given file.
source code
 
repositories(self)
Return a list of valid parsed repositories.
source code
list
repo(self, repository_id)
Return the list of database URLs for the given repository.
source code
list
pkgs(self, repository_id)
Return the list of package URLs for the given repository.
source code
string
desc(self, repository_id)
Return the description of the repository.
source code
bool
enabled(self, repository_id)
Return whether the repository is enabled or disabled.
source code
string
username(self, repository_id)
Return the username to use with the repository.
source code
string
password(self, repository_id)
Return the password to use with the repository.
source code
bool
https_validate_cert(self, repository_id)
Return whether SSL cert validation of remote repository is enabled.
source code

Inherited from BaseConfigParser: read

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __setitem__, __sizeof__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values, viewitems, viewkeys, viewvalues

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __str__, __subclasshook__

Class Variables
  FILENAME_PREFIX = 'entropy_'

Inherited from dict: __hash__

Properties

Inherited from object: __class__

Method Details

__init__(self, encoding=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Returns:
new empty dictionary

Overrides: object.__init__
(inherited documentation)

add(self, repository_id, desc, repos, pkgs, enabled=True, username=None, password=None, https_validate_cert=True)

source code 

Add a repository to the repository configuration files directory. Older repository configuration may get overwritten. This method only writes repository configuration in the new .ini format and to /etc/entropy/repositories.conf.d/<filename prefix><repository id>.

Parameters:
  • repository_id (string) - repository identifier
  • desc (string) - repository description
  • repos (list) - list of "repo=" uri dicts (containing "uri" and "dbcformat" keys)
  • pkgs (list) - list of packages mirrors uris
  • enabled (bool) - True, if the repository is enabled
Returns: bool
True, if success

remove(self, repository_id)

source code 

Remove a repository from the repositories configuration files directory.

This method only removes repository configuration at /etc/entropy/repositories.conf.d/<filename prefix><repository id>.

Parameters:
  • repository_id (string) - repository identifier
Returns: bool
True, if success

enable(self, repository_id)

source code 

Enable a repository.

This method only handles repository configuration at /etc/entropy/repositories.conf.d/<filename prefix><repository id>.

Parameters:
  • repository_id (string) - repository identifier
Returns: bool
True, if success

disable(self, repository_id)

source code 

Disable a repository.

This method only handles repository configuration at /etc/entropy/repositories.conf.d/<filename prefix><repository id>.

Parameters:
  • repository_id (string) - repository identifier
Returns: bool
True, if success

write(self, path, repository_id, desc, repos, pkgs, enabled=True, username=None, password=None, https_validate_cert=True)

source code 

Write the repository configuration to the given file.

Parameters:
  • path (string) - configuration file to write
  • repository_id (string) - repository identifier
  • desc (string) - repository description
  • repos (list) - list of "repo=" uri dicts (containing "uri" and "dbcformat" keys)
  • pkgs (list) - list of packages mirrors uris
  • enabled (bool) - True, if the repository is enabled

repositories(self)

source code 

Return a list of valid parsed repositories.

A repository is considered valid iff it contains at least one "repo" and "pkg" parameter.

repo(self, repository_id)

source code 

Return the list of database URLs for the given repository. This includes the default one, which is the first element listed.

Parameters:
  • repository_id (string) - the repository identifier
Returns: list
the list of repository URLs
Raises:
  • KeyError - if repository_id is not found or metadata is not available

pkgs(self, repository_id)

source code 

Return the list of package URLs for the given repository.

Parameters:
  • repository_id (string) - the repository identifier
Returns: list
the package URLs
Raises:
  • KeyError - if repository_id is not found or metadata is not available

desc(self, repository_id)

source code 

Return the description of the repository.

Parameters:
  • repository_id (string) - the repository identifier
Returns: string
the repository description
Raises:
  • KeyError - if repository_id is not found or metadata is not available

enabled(self, repository_id)

source code 

Return whether the repository is enabled or disabled.

Parameters:
  • repository_id (string) - the repository identifier
Returns: bool
the repository status

username(self, repository_id)

source code 

Return the username to use with the repository.

Parameters:
  • repository_id (string) - the repository identifier
Returns: string
the repository username.
Raises:
  • KeyError - if repository_id is not found or metadata is not available

password(self, repository_id)

source code 

Return the password to use with the repository.

Parameters:
  • repository_id (string) - the repository identifier
Returns: string
the repository password.
Raises:
  • KeyError - if repository_id is not found or metadata is not available

https_validate_cert(self, repository_id)

source code 

Return whether SSL cert validation of remote repository is enabled. It is used only for HTTPS.

Parameters:
  • repository_id (string) - the repository identifier
Returns: bool
status of ssl certificate validation.