Package portage :: Module dep
[hide private]

Module dep

source code

Classes [hide private]
  paren_normalize
Take a dependency structure as returned by paren_reduce or use_reduce and generate an equivalent structure that has no redundant lists.
  _use_dep
  _AtomCache
Cache Atom instances from constructor calls and reuse identical instances when available.
  Atom
For compatibility with existing atom string manipulation code, this class emulates most of the str methods that are useful with atoms.
Functions [hide private]
 
cpvequal(cpv1, cpv2)
@param cpv1: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1" @type cpv1: String @param cpv2: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1" @type cpv2: String @rtype: Boolean @returns: 1.
source code
Array
strip_empty(myarr)
Strip all empty elements from an array
source code
Array
paren_reduce(mystr, tokenize=1)
Take a string and convert all paren enclosed entities into sublists, optionally futher splitting the list elements by spaces.
source code
String
paren_enclose(mylist)
Convert a list to a string with sublists enclosed with parens.
source code
List
use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[])
Takes a paren_reduce'd array and reduces the use? conditionals out leaving an array with subarrays
source code
List
dep_opconvert(deplist)
Iterate recursively through a list of deps, if the dep is a '||' or '&&' operator, combine it with the list of deps that follows..
source code
String
get_operator(mydep)
Return the operator used in a depstring.
source code
String
dep_getcpv(mydep)
Return the category-package-version with any operators/slot specifications stripped off
source code
String
dep_getslot(mydep)
Retrieve the slot on a depend.
source code
 
remove_slot(mydep)
Removes dep components from the right side of an atom:...
source code
List
dep_getusedeps(depend)
Pull a listing of USE Dependencies out of a dep atom.
source code
Integer
isvalidatom(atom, allow_blockers=False)
Check to see if a depend atom is valid
source code
Integer
isjustname(mypkg)
Checks to see if the depstring is only the package name (no version parts)
source code
Integer
isspecific(mypkg)
Checks to see if a package is in category/package-version or package-version format, possibly returning a cached result.
source code
String
dep_getkey(mydep)
Return the category/package-name of a depstring.
source code
List
match_to_list(mypkg, mylist)
Searches list for entries that matches the package.
source code
String
best_match_to_list(mypkg, mylist)
Returns the most specific entry that matches the package given.
source code
List
match_from_list(mydep, candidate_list)
Searches list for entries that matches the package.
source code
Variables [hide private]
  _paren_whitespace_re = re.compile(r'\S([\(\)])|([\(\)])\S')
  _dep_check_strict = True
  _dep_getcpv_cache = {'*app-arch/bzip2': 'app-arch/bzip2', '*ap...
  _valid_category = re.compile(r'^\w[\w-]*')
  _invalid_atom_chars_regexp = re.compile(r'[\(\)\|@]')
  iscache = {'app-accessibility/dasher': 0, 'app-admin/bastille'...

Imports: re, sys, types, weakref, chain, InvalidData, InvalidAtom, catpkgsplit, catsplit, pkgcmp, pkgsplit, ververify, portage


Function Details [hide private]

cpvequal(cpv1, cpv2)

source code 


@param cpv1: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1"
@type cpv1: String
@param cpv2: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1"
@type cpv2: String
@rtype: Boolean
@returns:
1.  True if cpv1 = cpv2
2.  False Otherwise
3.  Throws PortageException if cpv1 or cpv2 is not a CPV

Example Usage:
>>> from portage.dep import cpvequal
>>> cpvequal("sys-apps/portage-2.1","sys-apps/portage-2.1")
>>> True

strip_empty(myarr)

source code 

Strip all empty elements from an array

Parameters:
  • myarr (List) - The list of elements
Returns: Array
The array with empty elements removed

paren_reduce(mystr, tokenize=1)

source code 

Take a string and convert all paren enclosed entities into sublists, optionally futher splitting the list elements by spaces.

Example usage:

>>> paren_reduce('foobar foo ( bar baz )',1)
['foobar', 'foo', ['bar', 'baz']]
>>> paren_reduce('foobar foo ( bar baz )',0)
['foobar foo ', [' bar baz ']]
Parameters:
  • mystr (String) - The string to reduce
  • tokenize (Integer) - Split on spaces to produces further list breakdown
Returns: Array
The reduced string in an array

paren_enclose(mylist)

source code 

Convert a list to a string with sublists enclosed with parens.

Example usage:

>>> test = ['foobar','foo',['bar','baz']]
>>> paren_enclose(test)
'foobar foo ( bar baz )'
Parameters:
  • mylist (List) - The list
Returns: String
The paren enclosed string

use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[])

source code 

Takes a paren_reduce'd array and reduces the use? conditionals out leaving an array with subarrays

Parameters:
  • deparray (List) - paren_reduce'd list of deps
  • uselist (List) - List of use flags
  • masklist (List) - List of masked flags
  • matchall (Integer) - Resolve all conditional deps unconditionally. Used by repoman
Returns: List
The use reduced depend array

dep_opconvert(deplist)

source code 

Iterate recursively through a list of deps, if the dep is a '||' or '&&' operator, combine it with the list of deps that follows..

Example usage:

>>> test = ["blah", "||", ["foo", "bar", "baz"]]
>>> dep_opconvert(test)
['blah', ['||', 'foo', 'bar', 'baz']]
Parameters:
  • deplist - A list of deps to format
  • mydep (List)
Returns: List
The new list with the new ordering

get_operator(mydep)

source code 

Return the operator used in a depstring.

Example usage:

>>> from portage.dep import *
>>> get_operator(">=test-1.0")
'>='
Parameters:
  • mydep (String) - The dep string to check
Returns: String
The operator. One of: '~', '=', '>', '<', '=*', '>=', or '<='

dep_getcpv(mydep)

source code 

Return the category-package-version with any operators/slot specifications stripped off

Example usage:

>>> dep_getcpv('>=media-libs/test-3.0')
'media-libs/test-3.0'
Parameters:
  • mydep (String) - The depstring
Returns: String
The depstring with the operator removed

dep_getslot(mydep)

source code 

Retrieve the slot on a depend.

Example usage:

>>> dep_getslot('app-misc/test:3')
'3'
Parameters:
  • mydep (String) - The depstring to retrieve the slot of
Returns: String
The slot

remove_slot(mydep)

source code 

Removes dep components from the right side of an atom:
        * slot
        * use
        * repo

dep_getusedeps(depend)

source code 

Pull a listing of USE Dependencies out of a dep atom.

Example usage:

>>> dep_getusedeps('app-misc/test:3[foo][-bar]')
['foo','-bar']
Parameters:
  • depend (String) - The depstring to process
Returns: List
List of use flags ( or [] if no flags exist )

isvalidatom(atom, allow_blockers=False)

source code 

Check to see if a depend atom is valid

Example usage:

>>> isvalidatom('media-libs/test-3.0')
0
>>> isvalidatom('>=media-libs/test-3.0')
1
Parameters:
  • atom (String) - The depend atom to check against
Returns: Integer
One of the following: 1) 0 if the atom is invalid 2) 1 if the atom is valid

isjustname(mypkg)

source code 

Checks to see if the depstring is only the package name (no version parts)

Example usage:

>>> isjustname('media-libs/test-3.0')
0
>>> isjustname('test')
1
>>> isjustname('media-libs/test')
1
Parameters:
  • mypkg - The package atom to check
  • mypkg - String
Returns: Integer
One of the following: 1) 0 if the package string is not just the package name 2) 1 if it is

isspecific(mypkg)

source code 

Checks to see if a package is in category/package-version or package-version format, possibly returning a cached result.

Example usage:

>>> isspecific('media-libs/test')
0
>>> isspecific('media-libs/test-3.0')
1
Parameters:
  • mypkg (String) - The package depstring to check against
Returns: Integer
One of the following: 1) 0 if the package string is not specific 2) 1 if it is

dep_getkey(mydep)

source code 

Return the category/package-name of a depstring.

Example usage:

>>> dep_getkey('media-libs/test-3.0')
'media-libs/test'
Parameters:
  • mydep (String) - The depstring to retrieve the category/package-name of
Returns: String
The package category/package-version

match_to_list(mypkg, mylist)

source code 

Searches list for entries that matches the package.

Parameters:
  • mypkg (String) - The package atom to match
  • mylist - The list of package atoms to compare against
  • mylist - List
Returns: List
A unique list of package atoms that match the given package atom

best_match_to_list(mypkg, mylist)

source code 

Returns the most specific entry that matches the package given.

Parameters:
  • mypkg (String) - The package atom to check
  • mylist (List) - The list of package atoms to check against
Returns: String
The package atom which best matches given the following ordering:
  • =cpv 6
  • ~cpv 5
  • =cpv* 4
  • cp:slot 3
  • >cpv 2
  • <cpv 2
  • >=cpv 2
  • <=cpv 2
  • cp 1

match_from_list(mydep, candidate_list)

source code 

Searches list for entries that matches the package.

Parameters:
  • mydep (String) - The package atom to match
  • candidate_list - The list of package atoms to compare against
  • candidate_list - List
Returns: List
A list of package atoms that match the given package atom

Variables Details [hide private]

_dep_getcpv_cache

Value:
{'*app-arch/bzip2': 'app-arch/bzip2',
 '*app-arch/cpio': 'app-arch/cpio',
 '*app-arch/tar': 'app-arch/tar',
 '*app-shells/bash': 'app-shells/bash',
 '*net-misc/iputils': 'net-misc/iputils',
 '*net-misc/rsync': 'net-misc/rsync',
 '*net-misc/wget': 'net-misc/wget',
 '*sys-apps/baselayout': 'sys-apps/baselayout',
...

iscache

Value:
{'app-accessibility/dasher': 0,
 'app-admin/bastille': 0,
 'app-admin/eselect': 0,
 'app-admin/eselect-compiler': 0,
 'app-admin/firstboot': 0,
 'app-admin/gnome-system-tools-2.14': 1,
 'app-admin/gnome-system-tools-2.20': 1,
 'app-admin/setools': 0,
...