Permalink
Browse files

ConfigurationGathering: Add get_filtered_bears

  • Loading branch information...
arafsheikh committed Jul 2, 2016
1 parent 3a6d00c commit 460a8c190345aa29e47ac65ceb27b20a3f7e2e9b
Showing with 26 additions and 12 deletions.
  1. +3 −12 coalib/coala.py
  2. +23 −0 coalib/settings/ConfigurationGathering.py
@@ -16,15 +16,13 @@
from pyprint.ConsolePrinter import ConsolePrinter
from coalib.coala_main import run_coala
from coalib.collecting.Collectors import (
collect_all_bears_from_sections, filter_section_bears_by_languages)
from coalib.misc.Exceptions import get_exitcode
from coalib.output.ConsoleInteraction import (
acquire_settings, nothing_done, print_results, print_section_beginning,
show_bears)
from coalib.output.printers.LogPrinter import LogPrinter
from coalib.parsing.DefaultArgParser import default_arg_parser
from coalib.settings.ConfigurationGathering import load_configuration
from coalib.settings.ConfigurationGathering import get_filtered_bears
def main():
@@ -36,15 +34,8 @@ def main():
args = default_arg_parser().parse_args()
if args.show_bears:
sections, _ = load_configuration(arg_list=None,
log_printer=log_printer)
local_bears, global_bears = collect_all_bears_from_sections(
sections, log_printer)
if args.filter_by_language:
local_bears = filter_section_bears_by_languages(
local_bears, args.filter_by_language)
global_bears = filter_section_bears_by_languages(
global_bears, args.filter_by_language)
local_bears, global_bears = get_filtered_bears(
args.filter_by_language, log_printer)
show_bears(local_bears,
global_bears,
@@ -2,6 +2,8 @@
import re
import sys
from coalib.collecting.Collectors import (
collect_all_bears_from_sections, filter_section_bears_by_languages)
from coalib.misc import Constants
from coalib.output.ConfWriter import ConfWriter
from coalib.output.printers.LOG_LEVEL import LOG_LEVEL
@@ -280,6 +282,27 @@ def get_config_directory(section):
return config if os.path.isdir(config) else os.path.dirname(config)
def get_filtered_bears(languages, log_printer):
"""
Fetch bears and filter them based on given list of languages.
:param languages: List of languages.
:param log_printer: The log_printer to handle logging.
:return: Tuple containing dictionaries of local bears
and global bears.
"""
sections, _ = load_configuration(arg_list=None,
log_printer=log_printer)
local_bears, global_bears = collect_all_bears_from_sections(
sections, log_printer)
if languages:
local_bears = filter_section_bears_by_languages(
local_bears, languages)
global_bears = filter_section_bears_by_languages(
global_bears, languages)
return local_bears, global_bears
def gather_configuration(acquire_settings,
log_printer,
autoapply=None,

0 comments on commit 460a8c1

Please sign in to comment.