Code re-org for my sanity.
This commit is contained in:
parent
3461709ebf
commit
f70aea7ec3
|
@ -24,6 +24,19 @@ _ = gettext.gettext
|
|||
# |___/
|
||||
|
||||
|
||||
# (commandLineDictionary, repositoryLocation) -> (configurationDictionary | exit)
|
||||
def load_config(options, base):
|
||||
"""Loads the git-lint configuration file.
|
||||
|
||||
Returns the configuration file as a dictionary of dictionaries.
|
||||
Performs substitutions as specified in the SafeConfigParser
|
||||
specification; the only one performed currently is the 'repodir'
|
||||
will be replaced with the base directory of the repository.
|
||||
Combined with the option to specify the .git-lint configuration as
|
||||
a directory, this allows users to keep per-project configuration
|
||||
files for specific linters.
|
||||
"""
|
||||
|
||||
def find_config_file(options, base):
|
||||
""" Returns the configuration file from a prioritized list of locations.
|
||||
|
||||
|
@ -56,20 +69,6 @@ def find_config_file(options, base):
|
|||
|
||||
return matches[0]
|
||||
|
||||
|
||||
# (commandLineDictionary, repositoryLocation) -> (configurationDictionary | exit)
|
||||
def load_config(options, base):
|
||||
"""Loads the git-lint configuration file.
|
||||
|
||||
Returns the configuration file as a dictionary of dictionaries.
|
||||
Performs substitutions as specified in the SafeConfigParser
|
||||
specification; the only one performed currently is the 'repodir'
|
||||
will be replaced with the base directory of the repository.
|
||||
Combined with the option to specify the .git-lint configuration as
|
||||
a directory, this allows users to keep per-project configuration
|
||||
files for specific linters.
|
||||
"""
|
||||
|
||||
Linter = namedtuple('Linter', ['name', 'linter'])
|
||||
path = find_config_file(options, base)
|
||||
configloader = configparser.SafeConfigParser()
|
||||
|
@ -193,12 +192,12 @@ def executable_exists(script, label):
|
|||
return (len(possibles) and possibles.pop(0)) or False
|
||||
|
||||
|
||||
def get_linter_status(config):
|
||||
|
||||
def get_working_linter_names(config):
|
||||
return [i.name for i in config
|
||||
if executable_exists(i.linter['command'], i.name)]
|
||||
|
||||
|
||||
def get_linter_status(config):
|
||||
working_linter_names = get_working_linter_names(config)
|
||||
broken_linter_names = (set([i.name for i in config]) - set(working_linter_names))
|
||||
return working_linter_names, broken_linter_names
|
||||
|
|
|
@ -5,10 +5,12 @@ import gettext
|
|||
_ = gettext.gettext
|
||||
|
||||
|
||||
def print_report(results, unlintable_filenames, cant_lint_filenames,
|
||||
broken_linter_names, unfindable_filenames, options={'bylinter': True}):
|
||||
|
||||
def base_file_cleaner(files):
|
||||
return [file.replace(git_base + '/', '', 1) for file in files]
|
||||
|
||||
|
||||
# ICK. Mutation, references, and hidden assignment.
|
||||
def group_by(iterable, field_id):
|
||||
results = []
|
||||
|
@ -22,9 +24,6 @@ def group_by(iterable, field_id):
|
|||
results.append((key, keys[key]))
|
||||
return results
|
||||
|
||||
|
||||
def print_report(results, unlintable_filenames, cant_lint_filenames,
|
||||
broken_linter_names, unfindable_filenames, options={'bylinter': True}):
|
||||
sort_position = 1
|
||||
grouping = _('Linter: {}')
|
||||
if 'byfile' in options:
|
||||
|
|
Loading…
Reference in New Issue