coalib.collecting package

Submodules

coalib.collecting.Collectors module

coalib.collecting.Collectors.collect_all_bears_from_sections(sections, log_printer)

Collect all kinds of bears from bear directories given in the sections.

Parameters:
  • bear_dirs – directory name or list of such that can contain bears
  • log_printer – log_printer to handle logging
Returns:

tuple of dictionaries of local and global bears The dictionary key is section class and dictionary value is a list of Bear classes

coalib.collecting.Collectors.collect_bears(bear_dirs, bear_globs, kinds, log_printer, warn_if_unused_glob=True)

Collect all bears from bear directories that have a matching kind matching the given globs.

Parameters:
  • bear_dirs – Directory name or list of such that can contain bears.
  • bear_globs – Globs of bears to collect.
  • kinds – List of bear kinds to be collected.
  • log_printer – LogPrinter to handle logging.
  • warn_if_unused_glob – True if warning message should be shown if a glob didn’t give any bears.
Returns:

Tuple of list of matching bear classes based on kind. The lists are in the same order as kinds.

coalib.collecting.Collectors.collect_dirs(dir_paths, ignored_dir_paths=None)

Evaluate globs in directory paths and return all matching directories

Parameters:
  • dir_paths – file path or list of such that can include globs
  • ignored_dir_paths – list of globs that match to-be-ignored dirs
Returns:

list of paths of all matching directories

coalib.collecting.Collectors.collect_files(file_paths, log_printer, ignored_file_paths=None, limit_file_paths=None)

Evaluate globs in file paths and return all matching files

Parameters:
  • file_paths – file path or list of such that can include globs
  • ignored_file_paths – list of globs that match to-be-ignored files
  • limit_file_paths – list of globs that the files are limited to
Returns:

list of paths of all matching files

coalib.collecting.Collectors.collect_registered_bears_dirs(entrypoint)

Searches setuptools for the entrypoint and returns the bear directories given by the module.

Parameters:entrypoint – The endpoint to find packages with.
Returns:List of bear directories.

coalib.collecting.Dependencies module

exception coalib.collecting.Dependencies.CircularDependencyError

Bases: Exception

classmethod for_bears(bears)

Creates the CircularDependencyError with a helpful message about the dependency.

coalib.collecting.Dependencies.resolve(bears)

Collects all dependencies of the given bears. This will also remove duplicates.

Parameters:bears – The given bears. Will not be modified.
Returns:The new list of bears, sorted so that it can be executed sequentially without dependency issues.

coalib.collecting.Importers module

coalib.collecting.Importers.iimport_objects(file_paths, names=None, types=None, supers=None, attributes=None, local=False, verbose=False)

Import all objects from the given modules that fulfill the requirements

Parameters:
  • file_paths – File path(s) from which objects will be imported
  • names – Name(s) an objects need to have one of
  • types – Type(s) an objects need to be out of
  • supers – Class(es) objects need to be a subclass of
  • attributes – Attribute(s) an object needs to (all) have
  • local – if True: Objects need to be defined in the file they appear in to be collected
Returns:

iterator that yields all matching python objects

Raises:

Exception – Any exception that is thrown in module code or an ImportError if paths are erroneous.

coalib.collecting.Importers.import_objects(file_paths, names=None, types=None, supers=None, attributes=None, local=False, verbose=False)

Import all objects from the given modules that fulfill the requirements

Parameters:
  • file_paths – File path(s) from which objects will be imported
  • names – Name(s) an objects need to have one of
  • types – Type(s) an objects need to be out of
  • supers – Class(es) objects need to be a subclass of
  • attributes – Attribute(s) an object needs to (all) have
  • local – if True: Objects need to be defined in the file they appear in to be collected
Returns:

list of all matching python objects

Raises:

Exception – Any exception that is thrown in module code or an ImportError if paths are erroneous.

Module contents