Code re-org for my sanity.
This commit is contained in:
parent
3461709ebf
commit
f70aea7ec3
|
@ -24,7 +24,20 @@ _ = gettext.gettext
|
||||||
# |___/
|
# |___/
|
||||||
|
|
||||||
|
|
||||||
def find_config_file(options, base):
|
# (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.
|
""" Returns the configuration file from a prioritized list of locations.
|
||||||
|
|
||||||
Locations are prioritized as:
|
Locations are prioritized as:
|
||||||
|
@ -56,20 +69,6 @@ def find_config_file(options, base):
|
||||||
|
|
||||||
return matches[0]
|
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'])
|
Linter = namedtuple('Linter', ['name', 'linter'])
|
||||||
path = find_config_file(options, base)
|
path = find_config_file(options, base)
|
||||||
configloader = configparser.SafeConfigParser()
|
configloader = configparser.SafeConfigParser()
|
||||||
|
@ -193,12 +192,12 @@ def executable_exists(script, label):
|
||||||
return (len(possibles) and possibles.pop(0)) or False
|
return (len(possibles) and possibles.pop(0)) or False
|
||||||
|
|
||||||
|
|
||||||
def get_working_linter_names(config):
|
def get_linter_status(config):
|
||||||
|
|
||||||
|
def get_working_linter_names(config):
|
||||||
return [i.name for i in config
|
return [i.name for i in config
|
||||||
if executable_exists(i.linter['command'], i.name)]
|
if executable_exists(i.linter['command'], i.name)]
|
||||||
|
|
||||||
|
|
||||||
def get_linter_status(config):
|
|
||||||
working_linter_names = get_working_linter_names(config)
|
working_linter_names = get_working_linter_names(config)
|
||||||
broken_linter_names = (set([i.name for i in config]) - set(working_linter_names))
|
broken_linter_names = (set([i.name for i in config]) - set(working_linter_names))
|
||||||
return working_linter_names, broken_linter_names
|
return working_linter_names, broken_linter_names
|
||||||
|
|
|
@ -5,12 +5,14 @@ import gettext
|
||||||
_ = gettext.gettext
|
_ = gettext.gettext
|
||||||
|
|
||||||
|
|
||||||
def base_file_cleaner(files):
|
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]
|
return [file.replace(git_base + '/', '', 1) for file in files]
|
||||||
|
|
||||||
|
# ICK. Mutation, references, and hidden assignment.
|
||||||
# ICK. Mutation, references, and hidden assignment.
|
def group_by(iterable, field_id):
|
||||||
def group_by(iterable, field_id):
|
|
||||||
results = []
|
results = []
|
||||||
keys = {}
|
keys = {}
|
||||||
for obj in iterable:
|
for obj in iterable:
|
||||||
|
@ -22,9 +24,6 @@ def group_by(iterable, field_id):
|
||||||
results.append((key, keys[key]))
|
results.append((key, keys[key]))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def print_report(results, unlintable_filenames, cant_lint_filenames,
|
|
||||||
broken_linter_names, unfindable_filenames, options={'bylinter': True}):
|
|
||||||
sort_position = 1
|
sort_position = 1
|
||||||
grouping = _('Linter: {}')
|
grouping = _('Linter: {}')
|
||||||
if 'byfile' in options:
|
if 'byfile' in options:
|
||||||
|
|
Loading…
Reference in New Issue