@yield_once
def icollect_bears(bear_dir_glob, bear_globs, kinds, log_printer):
 for (bear_dir, dir_glob) in filter((lambda x: os.path.isdir(x[0])), icollect(bear_dir_glob)):
  bear_dir = glob_escape(bear_dir)
  for bear_glob in bear_globs:
   for matching_file in iglob(os.path.join(bear_dir, (bear_glob + '.py'))):
    try:
     for bear in _import_bears(matching_file, kinds):
      (yield (bear, bear_glob))
    except pkg_resources.VersionConflict as exception:
     log_printer.log_exception('Unable to collect bears from {file} because there is a conflict with the version of a dependency you have installed. This may be resolved by creating a separate virtual environment for coala or running `pip install "{pkg}"`. Be aware that the latter solution might break other python packages that depend on the currently installed version.'.format(file=matching_file, pkg=exception.req), exception, log_level=LOG_LEVEL.WARNING)
    except BaseException as exception:
     log_printer.log_exception('Unable to collect bears from {file}. Probably the file is malformed or the module code raises an exception.'.format(file=matching_file), exception, log_level=LOG_LEVEL.WARNING)

@ yield_once def icollect_bears ( bear_dir_glob , bear_globs , kinds , log_printer ) : for ( bear_dir , dir_glob ) in filter ( ( lambda x : os . path . isdir ( x [ 0 ] ) ) , icollect ( bear_dir_glob ) ) : bear_dir = glob_escape ( bear_dir ) for bear_glob in bear_globs : for matching_file in iglob ( os . path . join ( bear_dir , ( bear_glob + '.py' ) ) ) : try : for bear in _import_bears ( matching_file , kinds ) : ( yield ( bear , bear_glob ) ) except pkg_resources . VersionConflict as exception : log_printer . log_exception ( 'Unable to collect bears from {file} because there is a conflict with the version of a dependency you have installed. This may be resolved by creating a separate virtual environment for coala or running `pip install "{pkg}"`. Be aware that the latter solution might break other python packages that depend on the currently installed version.' . format ( file = matching_file , pkg = exception . req ) , exception , log_level = LOG_LEVEL . WARNING ) except BaseException as exception : log_printer . log_exception ( 'Unable to collect bears from {file}. Probably the file is malformed or the module code raises an exception.' . format ( file = matching_file ) , exception , log_level = LOG_LEVEL . WARNING )
collect all bears from bear directories that have a matching kind .