portage.env.loaders module

class portage.env.loaders.DataLoader(validator)

Bases: object

load()

Function to do the actual work of a Loader

class portage.env.loaders.EnvLoader(validator)

Bases: portage.env.loaders.DataLoader

Class to access data in the environment

load()

Function to do the actual work of a Loader

class portage.env.loaders.FileLoader(filename, validator)

Bases: portage.env.loaders.DataLoader

Class to access data in files

lineParser(line, line_num, data, errors)

This function parses 1 line at a time Args:

line: a string representing 1 line of a file line_num: an integer representing what line we are processing data: a dict that contains the data we have extracted from the file

already

errors: a dict representing parse errors.

Returns:

Nothing (None). Writes to data and errors

load()

Return the {source: {key: value}} pairs from a file Return the {source: [list of errors] from a load

Parameters

recursive – If set and self.fname is a directory; load all files in self.fname

Type

Boolean

Return type

tuple

Returns

Returns (data,errors), both may be empty dicts or populated.

class portage.env.loaders.ItemFileLoader(filename, validator)

Bases: portage.env.loaders.FileLoader

Class to load data from a file full of items one per line

>>> item1
>>> item2
>>> item3
>>> item1

becomes { ‘item1’:None, ‘item2’:None, ‘item3’:None } Note that due to the data store being a dict, duplicates are removed.

lineParser(line, line_num, data, errors)

This function parses 1 line at a time Args:

line: a string representing 1 line of a file line_num: an integer representing what line we are processing data: a dict that contains the data we have extracted from the file

already

errors: a dict representing parse errors.

Returns:

Nothing (None). Writes to data and errors

load()

Return the {source: {key: value}} pairs from a file Return the {source: [list of errors] from a load

Parameters

recursive – If set and self.fname is a directory; load all files in self.fname

Type

Boolean

Return type

tuple

Returns

Returns (data,errors), both may be empty dicts or populated.

class portage.env.loaders.KeyListFileLoader(filename, validator=None, valuevalidator=None)

Bases: portage.env.loaders.FileLoader

Class to load data from a file full of key [list] tuples

>>>>key foo1 foo2 foo3 becomes {‘key’:[‘foo1’,’foo2’,’foo3’]}

lineParser(line, line_num, data, errors)

This function parses 1 line at a time Args:

line: a string representing 1 line of a file line_num: an integer representing what line we are processing data: a dict that contains the data we have extracted from the file

already

errors: a dict representing parse errors.

Returns:

Nothing (None). Writes to data and errors

load()

Return the {source: {key: value}} pairs from a file Return the {source: [list of errors] from a load

Parameters

recursive – If set and self.fname is a directory; load all files in self.fname

Type

Boolean

Return type

tuple

Returns

Returns (data,errors), both may be empty dicts or populated.

class portage.env.loaders.KeyValuePairFileLoader(filename, validator, valuevalidator=None)

Bases: portage.env.loaders.FileLoader

Class to load data from a file full of key=value pairs

>>>>key=value >>>>foo=bar becomes: {‘key’:’value’,

‘foo’:’bar’}

lineParser(line, line_num, data, errors)

This function parses 1 line at a time Args:

line: a string representing 1 line of a file line_num: an integer representing what line we are processing data: a dict that contains the data we have extracted from the file

already

errors: a dict representing parse errors.

Returns:

Nothing (None). Writes to data and errors

load()

Return the {source: {key: value}} pairs from a file Return the {source: [list of errors] from a load

Parameters

recursive – If set and self.fname is a directory; load all files in self.fname

Type

Boolean

Return type

tuple

Returns

Returns (data,errors), both may be empty dicts or populated.

exception portage.env.loaders.LoaderError(resource, error_msg)

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

portage.env.loaders.RecursiveFileLoader(filename)

If filename is of type file, return a generate that yields filename else if filename is of type directory, return a generator that fields files in that directory.

Ignore files beginning with . or ending in ~. Prune CVS directories.

Parameters

filename – name of a file/directory to traverse

Return type

list

Returns

List of files to process

class portage.env.loaders.TestTextLoader(validator)

Bases: portage.env.loaders.DataLoader

You give it some data, it ‘loads’ it for you, no filesystem access

load()

Function to do the actual work of a Loader

setData(text)

Explicitly set the data field Args:

text - a dict of data typical of Loaders

Returns:

None

setErrors(errors)