MultiFileSource#

class MultiFileSource(params=None, **kwargs)#

Bases: SourceAbstract[str]

Abstract class for source consisting of multiple files.

It is easier to deal with multiple files when separating a root directory, and the files therein. root_directory() deals with that.

Also defines an autocached property datafiles() that will be returned upon asking the source. If they are many files, caching this can make sense.

Parameters:
  • params (Any | None)

  • kwargs (Any)

property datafiles: list[str]#

List of source files.

Not implemented:

implement in a module subclass.

get_root_directory()#

Return the directory containing all datafiles.

Can return a path, or an iterable of directories that will automatically be joined into a valid path.

Not implemented:

implement in your Source module subclass.

Return type:

str | PathLike | list[str] | list[PathLike]

get_source(relative=False, _warn=True)#

Return list of filenames.

Parameters:
  • relative (bool) – If True, return filenames relative to the root directory. Default is False.

  • _warn (bool) – If True, log a warning when no files are found.

Return type:

list[str]

property root_directory: Path#

Root directory containing data.

Call get_root_directory() and, if necessary, joins individuals folders into a single path.