Package entropy :: Package server :: Package interfaces :: Module main :: Class RepositoryConfigParser

Class RepositoryConfigParser

source code


Entropy .ini-like server-side repository configuration file parser.

Entropy Server now supports repositories defined inside
/etc/entropy/repositories.conf.d/ files, written using the
syntax detailed below. This improves the ability to enable, disable,
add and remove repositories programmatically. Furthermore, it
makes possible to extend the supported parameters without breaking
backward compatibility.

In order to differentiate Entropy Client repository definitions between
Entropy Server ones, each repository section must start with "[server=".

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

[server=sabayon-limbo]
desc = Sabayon Linux Official Testing Repository
repo = ssh://[email protected]:~username/sabayon-limbo
enabled = <true/false>

[server=sabayon-limbo]
desc = This statement will be ignored.
repo-only = ssh://[email protected]:~username/sabayon-limbo
pkg-only = ssh://[email protected]:~username/sabayon-limbo

[server=sabayon-base]
desc = This is the base repository.
repo-only = ssh://[email protected]:~username/sabayon-base
pkg-only = ssh://[email protected]:~username/sabayon-base
base = <true/false>

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,repo}* = as you want.

The repository order is important, but this is guaranteed by the
fact that configuration files are parsed in lexical order.

Statements description:
- "desc": stands for description, the repository name description.
- "repo": the push & pull URI, for both packages and repository database.
- "repo-only": same as repo, but only for the repository database
               push & pull.
- "pkg-only": same as repo, but only for the packages push & pull.
         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.
- "base": if set, its value can be either "true" or "false". The default
          value is "false". If no repository has the flag set, the first
          listed repository will be the base one. Only the first repository
          with "base = true" will be considered. The base repository is the
          repository that is considered base for all the others
          (the main one).
- "exclude-qa": if set, its value can be either "true" or "false".
                The default value is "false". If "true", the repository is
                excluded from QA checks.

Instance Methods
new empty dictionary

__init__(self, encoding=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
string or None
base_repository(self)
Return the base repository, if any, or None.
source code
 
add(self, repository_id, desc, repo, repo_only, pkg_only, base, enabled=True, exclude_qa=False)
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
 
write(self, path, repository_id, desc, repo, repo_only, pkg_only, base, enabled=True, exclude_qa=False)
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 repository push & pull URIs for both packages and repository database.
source code
list
repo_only(self, repository_id)
Return the repository push & pull URIs for the repository database only.
source code
list
pkg_only(self, repository_id)
Return the repository push & pull URIs for the repository only.
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
bool
exclude_qa(self, repository_id)
Return whether the repository is excluded from QA.
source code

Inherited from core.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 = 'entropysrv_'

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)

base_repository(self)

source code 

Return the base repository, if any, or None.

Returns: string or None
the base repository identifier

add(self, repository_id, desc, repo, repo_only, pkg_only, base, enabled=True, exclude_qa=False)

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
  • repo (list) - list of "repo=" uris
  • repo_only (list) - list of "repo-only=" uris
  • pkg_only (list) - list of "pkg-only=" uris
  • base (bool) - True, if this is the base repository
  • enabled (bool) - True, if the repository is enabled
  • exclude_qa (bool) - True, if the repository should be excluded from QA

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

write(self, path, repository_id, desc, repo, repo_only, pkg_only, base, enabled=True, exclude_qa=False)

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
  • repo (list) - list of "repo=" uris
  • repo_only (list) - list of "repo-only=" uris
  • pkg_only (list) - list of "pkg-only=" uris
  • base (bool) - True, if this is the base repository, False if not, None if unset.
  • enabled (bool) - True, if the repository is enabled
  • exclude_qa (bool) - True, if the repository should be excluded from QA

repositories(self)

source code 

Return a list of valid parsed repositories.

A repository is considered valid iff it contains at least "repo". The parse order is preserved.

repo(self, repository_id)

source code 

Return the repository push & pull URIs for both packages and repository database.

Parameters:
  • repository_id (string) - the repository identifier
Returns: list
the repository push & pull URIs.
Raises:
  • KeyError - if repository_id is not found or metadata is not available

repo_only(self, repository_id)

source code 

Return the repository push & pull URIs for the repository database only.

Parameters:
  • repository_id (string) - the repository identifier
Returns: list
the repository push & pull URIs for the repository database only.
Raises:
  • KeyError - if repository_id is not found or metadata is not available

pkg_only(self, repository_id)

source code 

Return the repository push & pull URIs for the repository only.

Parameters:
  • repository_id (string) - the repository identifier
Returns: list
the repository push & pull URIs for the packages only.
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

exclude_qa(self, repository_id)

source code 

Return whether the repository is excluded from QA.

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