adaptivemd.BaseBundle

class adaptivemd.BaseBundle[source]

BaseClass for Bundle functionality a special set of storable objects

__init__()

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

Methods

c(cls) Return a view bundle on all entries that are instances of a class
f(pattern) Return a view bundle on all entries that match a location pattern
pick() Pick a random element
sorted(key) Return a view bundle where all entries are sorted by a given key attribute
v(fnc) Return a view bundle on all entries that are filtered by a function

Attributes

all Return a Delegator that will apply attribute and function call to all bundle elements
one Return one element from the list
c(cls)[source]

Return a view bundle on all entries that are instances of a class

Parameters:cls (type) – a class to be filtered by
Returns:the read-only bundle showing filtered entries
Return type:ViewBundle
f(pattern)[source]

Return a view bundle on all entries that match a location pattern

Works only when all objects are of type File

Parameters:pattern (str) – a string CL pattern using wildcards to match a filename
Returns:the read-only bundle showing filtered entries
Return type:ViewBundle
sorted(key)[source]

Return a view bundle where all entries are sorted by a given key attribute

Parameters:key (function) – a function to compute the key to be sorted by
Returns:the read-only bundle showing sorted entries
Return type:ViewBundle
v(fnc)[source]

Return a view bundle on all entries that are filtered by a function

Parameters:fnc (function) – a function to be used for filtering
Returns:the read-only bundle showing filtered entries
Return type:ViewBundle
pick()[source]

Pick a random element

Returns:a random object if bundle is not empty
Return type:object or None
one

Return one element from the list

Use only if you just need one and do not care which one it is

Returns:one object (there is no guarantee that this will always be the same element)
Return type:object
all

Return a Delegator that will apply attribute and function call to all bundle elements

Returns:the delegator object to map to all elements in the bundle
Return type:BundleDelegator