coalib.collecting package — coala 0.9.0.dev99999999999999 documentation

# 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: | sections – List of sections so bear_dirs are taken into account 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 – log_printer 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 entrypoint to find packages with.
  Returns: | List of bear directories.

`coalib.collecting.Collectors.` `filter_capabilities_by_languages`(bears, languages)

  Filters the bears capabilities by languages.

  Parameters: | bears – Dictionary with sections as keys and list of bears as values. languages – Languages that bears are being filtered on.
  Returns: | New dictionary with languages as keys and their bears capabilities as values. The capabilities are stored in a tuple of two elements where the first one represents what the bears can detect, and the second one what they can fix.

`coalib.collecting.Collectors.` `filter_section_bears_by_languages`(bears, languages)

  Filters the bears by languages.

  Parameters: | bears – The dictionary of the sections as keys and list of bears as values. languages – Languages that bears are being filtered on.
  Returns: | New dictionary with filtered out bears that don’t match any language from languages.

`coalib.collecting.Collectors.` `get_all_bears_names`()

`coalib.collecting.Collectors.` `icollect`(file_paths, ignored_globs=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_globs – List of globs to ignore when matching files
  Returns: | Iterator that yields tuple of path of a matching file, the glob where it was found

`coalib.collecting.Collectors.` `icollect_bears`(bear_dir_glob, bear_globs, kinds, log_printer)

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

  Parameters: | bear_dir_glob – Directory globs 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 – Log_printer to handle logging
  Returns: | Iterator that yields a tuple with bear class and which bear_glob was used to find that bear class.

## 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, suppress_output=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. suppress_output – Whether console output from stdout shall be suppressed or not.
  Returns: | An 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.

`coalib.collecting.Importers.` `object_defined_in`(obj, file_path)

  Check if the object is defined in the given file.

      >>> object_defined_in(object_defined_in, __file__)
      True
      >>> object_defined_in(object_defined_in, "somewhere else")
      False

  Builtins are always defined outside any given file:

      >>> object_defined_in(False, __file__)
      False

  Parameters: | obj – The object to check. file_path – The path it might be defined in.
  Returns: | True if the object is defined in the file.

## Module contents