law.target.collection#

Collections that wrap multiple targets.

Class TargetCollection#

class TargetCollection(targets, threshold=1.0, **kwargs)[source]#

Bases: Target

Collection of arbitrary targets.

complete(**kwargs)[source]#

Returns almost the same state information as exists() (called internally), but potentially also includes settings such as optional. All kwargs are forwarded to exists().

This method is mostly useful in conjunction with task implementations whereas the vanilla exists() method should be used when relying on the actual existence status.

exists(**kwargs)[source]#

Returns True if the Target exists and False otherwise.

map(func)[source]#

Returns a copy of this collection with all targets being transformed by func.

Class SiblingFileCollection#

class SiblingFileCollection(*args, **kwargs)[source]#

Bases: SiblingFileCollectionBase

Collection of targets that represent files which are all located in the same directory. Specifically, the performance of exists() and count() can greatly improve with respect to the standard FileCollection as the directory listing is used internally. This is especially useful for large collections of remote files.

Class NestedSiblingFileCollection#

class NestedSiblingFileCollection(*args, **kwargs)[source]#

Bases: SiblingFileCollectionBase

Collection of targets that represent files which are located across several directories, with files in the same directory being wrapped by a SiblingFileCollection to exploit its benefit over the standard FileCollection (see description above). This is especially useful for large collections of remote files that are located in different (sub) directories.

The constructor identifies targets located in the same physical directory (identified by URI), creates one collection for each of them, and stores them in the collections attribute. Key access, iteration, etc., is identical to the standard FileCollection.