libcomps - Libcomps objects

libcomps.Comps

class libcomps.Comps

Comps class is representating comps.xml file represented in structure form.

Note

members:blacklist, langpacks, whiteout

are Fedora objects only

arch_filter

arch_filter(arch_list)->libcomps.Comps Filter Comps object content by _arch attribute matchingpassed archictures

Parameter:arch_list (list of strings or libcomps.StrSeq) – list of architectures
Returns:new :py:class:`libcomps.Comps` instace
blacklist
:py:class:`libcomps.MDict` of blacklist
categories
:py:class:`libcomps.CategoryList` of categories
categories_match

validate inner structure of Comps object.Raise appropriate exception on first occured error

Raises ValueError:
 with appropriate error message
clear
Clear Comps
environments
:py:class:`libcomps.EnvList` of environments
environments_match

validate inner structure of Comps object.Raise appropriate exception on first occured error

Raises ValueError:
 with appropriate error message
fromxml_f

fromxml_f(fname, [def_options])->int Load COMPS from xml file

Parameters:
  • str fname – filename to be readed
  • dict def_options – dictionary containing options used forspecify values of missing objects attributes in xml_str string
Returns:

1 if some non-fatal error occured during parsing

0 if parsing ended without any error

Raises libcomps.ParserError:
 

if some fatal erroroccured during parsing

Raises IOError:

if specified filename cannot be opened for reading

fromxml_str

fromxml_str(xml_str, [def_options])->int Load COMPS from xml string

Parameters:
  • str xml_str – string containing comps xml representation
  • dict def_options – dictionary containing options used forspecify values of missing objects attributes in xml_str string
Returns:

1 if some non-fatal error occured during parsing

0 if parsing ended without any error

Raises libcomps.ParserError:
 

if some fatal error occured during parsing

get_last_errors
return list of messages from log of last parse action, contains errors only
get_last_log
return list of messages from log of last parse action.
groups
:py:class:`libcomps.GroupList` of groups
groups_match

validate inner structure of Comps object.Raise appropriate exception on first occured error

Raises ValueError:
 with appropriate error message
langpacks
:py:class:`libcomps.StrDict` of langpacks
toxml_f
toxml_f(fname,[xml_options,[def_options]])->int alias for :py:meth:`Comps.xml_f`
toxml_str
toxml_str([xml_options,[def_options]])->str alias for :py:meth:`Comps.xml_str`
validate

validate inner structure of Comps object.Raise appropriate exception on first occured error

Raises ValueError:
 with appropriate error message
validate_nf

validate inner structure of Comps class.Returns list of error strings

Return type:list of strings
whiteout
:py:class:`libcomps.MDict` of whiteout
xml_f

xml_f(fname,[xml_options,[def_options]])->list Generate xml output of Comps class to file

Parameters:
  • str fname – filename
  • dict xml_options – dict of options used for specify xml output
  • dict def_options – dict of options used for specify default values of missing attributes of objects
Returns:

list of errors encountered during xml generating

Return type:

list of strings

Raises XMLGenError:
 

if generating xml encounter some fatal error

xml_str

xml_str([xml_options,[def_options]])->str Generate xml output of Comps object a return it as string

Parameters:
  • dict xml_options – dict of options used for specify xml output
  • dict def_options – dict of options used for specify default values of missing attributes of objects
Returns:

string containing xml output

libcomps.GroupList

class libcomps.GroupList

Comps Group list

is class mostly similar to normal python list with few diferences:

  • accepting only specified type of object. :py:class:`GroupList` devours only :py:class:`Group` instance.
  • accepting string argument in getter/setter items methods as identificator of objects by id.
  • run validation procedure on absorbed object so you can’t append/insert/set invalid :py:class:`Group` object
g1 = libcomps.Group()
g1.id = "g1"
comps.categories.append(g1)

g2 = libcomps.Group()
g2.id = "g2"
comps.categories.append(g2)

g = comps.groups["g2"]
comps.categories["g1"] = libcomps.Group()
append
Append item to new of the list
clear
Clear the list
insert

insert(pos, item) -> None Insert item into list at position pos

Parameter:pos – intposition
Returns:None
remove

remove(item) -> None Remove first occurence of item from list

Raises TypeError:
 If type of item is not type acceptable for list
Raises ValueError:
 If item is not in the list

libcomps.CategoryList

class libcomps.CategoryList

Comps Category list

is class mostly similar to normal python list with few diferences:

c1 = libcomps.Category()
c1.id = "c1"
comps.categories.append(c1)

c2 = libcomps.Category()
c2.id = "c2"
comps.categories.append(c2)

c = comps.groups["c2"]
comps.categories["c1"] = libcomps.Category()
append
Append item to new of the list
clear
Clear the list
insert

insert(pos, item) -> None Insert item into list at position pos

Parameter:pos – intposition
Returns:None
remove

remove(item) -> None Remove first occurence of item from list

Raises TypeError:
 If type of item is not type acceptable for list
Raises ValueError:
 If item is not in the list

libcomps.EnvList

class libcomps.EnvList

Comps Env list

is class mostly similar to normal python list with few diferences:

e1 = libcomps.Environment()
e1.id = "e1"
comps.environments.append(e1)

e2 = libcomps.Environment()
e2.id = "e2"
comps.environments.append(e2)

e = comps.groups["e2"]
comps.categories["e1"] = libcomps.Environment()
append
Append item to new of the list
clear
Clear the list
insert

insert(pos, item) -> None Insert item into list at position pos

Parameter:pos – intposition
Returns:None
remove

remove(item) -> None Remove first occurence of item from list

Raises TypeError:
 If type of item is not type acceptable for list
Raises ValueError:
 If item is not in the list

libcomps.Group

class libcomps.Group

Comps Group

biarchonly
Group uservisible attribute
default
Group default attribute
desc
descrition of group
desc_by_lang
dictionary of locale group descriptions
display_order
Group display order attribute
id
group string identificator
lang_only
group langonly attribute
name
name of group
name_by_lang
dictionary of locale group names
packages
:py:class:`libcomps.PackageList` of :py:class:`libcomps.Package`
packages_match

Return list of packages matching selected criteria

Returns:List of packages
uservisible
Group uservisible attribute
validate

Validate inner group structure. Raise exception on firstoccured error.

Returns:None if validation successful
Raises ValueError:
 on first occured error

libcomps.PackageList

class libcomps.PackageList

Comps Group Package list

is class mostly similar to normal python list with few diferences:

  • accepting only specified type of object. :py:class:`PackageList` devours only :py:class:`Package` instance.
  • accepting string argument in getter/setter items methods as identificator of package name.
  • run validation procedure on absorbed object so you can’t append/insert/set invalid :py:class:`Package` object

libcomps.Package

class libcomps.Package

Comps Group Package

basearchonly
Package basearchonly attribute
name
Package name
requires
Package requires
type

package type which could be one of following:

validate

Validate inner package structure. Raise exception on firstoccured error.

Returns:None if validation successful
Raises ValueError:
 on first occured error

libcomps.Category

class libcomps.Category

Comps Category

desc
description of category
desc_by_lang
dictionary of locale category description
display_order
category display order attribute
group_ids
:py:class:`libcomps.IdList` of :py:class:`libcomps.GroupId`
id
category string identificator
name
name of category
name_by_lang
dictionary of locale category names
validate
validate inner category structure

libcomps.Environment

class libcomps.Environment

Comps Environment

desc
description of environment
desc_by_lang
dictionary of locale environment descriptions
display_order
environment display order attribute
group_ids
:py:class:`libcomps.IdList` of :py:class:`libcomps.GroupId` representing environments group list
id
environment string identificator
name
name of environment
name_by_lang
dictionary of locale environment names
option_ids
:py:class:`libcomps.IdList` of :py:class:`libcomps.GroupId` representing environments option list
validate

Validate inner environment structure. Raise exception on firstoccured error.

Returns:None if validation successful
Raises ValueError:
 on first occured error

libcomps.IdList

class libcomps.IdList

Comps GIDs list

is class mostly similar to normal python list with few diferences:

libcomps.GroupId

class libcomps.GroupId

Comps GroupId

default
Group ID default
name
Group ID name
validate
validate inner Group ID structure

libcomps.StrDict

class libcomps.StrDict

Comps Str Dict

clear
clear the dict
copy
return shallow copy of dict
get

get(key)->object Return object associated with key

Parameter:

str/unicode key – object key

Returns:

object if there’s object associated with key

None otherwise

has_key

has_key(key)->bool Tests if there’s key in object

Parameter:

str/unicode key – object key

Returns:

True if there’s object associated with key

False otherwise

items
return list of (key, val) tuples
iteritems
return iterator returning (key, value) tuple
iterkeys
return iterator returning item’s key
itervalues
return iterator returning item’s value
keys
return list of keys
update

update(dict)->None Update dictionary with (key,value) pair from another dictionary.Existing pairs are overwritten

Parameter:dict:py:class:`libcomps.Dict` instance or subclass instance
Returns:None
values
return list of values

is very lightweight version of python dict

  • libcomps.StrDict can have only string/unicode keys and accepts only string/unicode object

libcomps.MDict

class libcomps.MDict

Comps Dict

clear
clear the dict
copy
return shallow copy of dict
get

get(key)->list of strings Return object associated with key

Parameter:

str/unicode key – object key

Returns:

object if there’s object associated with key

None otherwise

has_key

has_key(key)->bool Tests if there’s key in object

Parameter:

str/unicode key – object key

Returns:

True if there’s object associated with key

False otherwise

items
return list of (key, val) tuples
iteritems
return iterator returning (key, value) tuple
iterkeys
return iterator returning item’s key
itervalues
return iterator returning item’s value
keys
return list of keys
update

update(dict)->None Update dictionary with (key,value) pair from another dictionary.Existing pairs are overwritten

Parameter:dict:py:class:`libcomps.Dict` instance or subclass instance
Returns:None
values
return list of values

is class similar to python dict, except of these properties:

  • libcomps.MDict can have only string/unicode keys and accepts only list of string or libcomps.StrSeq which is also object returned from dict.__get__()
  • output of StrDict.keys() is in alphabetical order ()

libcomps.StrSeq

class libcomps.StrSeq

Comps Str list

append
Append item to new of the list
clear
Clear the list
insert

insert(pos, item) -> None Insert item into list at position pos

Parameter:pos – intposition
Returns:None
remove

remove(item) -> None Remove first occurence of item from list

Raises TypeError:
 If type of item is not type acceptable for list
Raises ValueError:
 If item is not in the list

is class similar to list, but accepts only string/unicode objects.