Skip to content

Commit

Permalink
generate_bear_requirements.py: Tidy language file
Browse files Browse the repository at this point in the history
Remove values `[]` and sort by bear name.

Related to coala#2479
  • Loading branch information
jayvdb authored and gitmate-bot committed Nov 3, 2018
1 parent 9e54e48 commit 5993a3c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
18 changes: 13 additions & 5 deletions .ci/generate_bear_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import itertools
import os
import sys
import operator

from ruamel.yaml import YAML, RoundTripDumper
from ruamel.yaml.comments import CommentedMap
Expand Down Expand Up @@ -175,15 +174,24 @@ def get_pip_requirements(requirements):
def get_cabal_requirements(requirements):
return _get_requirements(requirements, '==')


def _create_sorted_commented_map(input_dict):
return CommentedMap(sorted(input_dict.items(),
key=lambda t: t[0]))


def get_languages(bears):
language_dict = {}
for bear in bears:
language_dict[str(bear.name)] = list(sorted(bear.LANGUAGES))
for value in language_dict.values():
for key, value in language_dict.items():
if 'All' in value:
value.remove('All')
if 'default' in value:
value.remove('default')
if not value:
language_dict[key] = None

return language_dict


Expand Down Expand Up @@ -222,10 +230,10 @@ def deep_diff(target, src):
return errors



def sort_requirements(req_dict):
for key in INSTANCE_NAMES:
req_dict[key] = CommentedMap(sorted(req_dict[key].items(),
key=lambda t: t[0]))
req_dict[key] = _create_sorted_commented_map(req_dict[key])


if __name__ == '__main__':
Expand Down Expand Up @@ -288,8 +296,8 @@ def sort_requirements(req_dict):
else:
output = open(args.output, 'w')

all_bears.sort(key = operator.attrgetter('name'))
language_requirements = get_languages(all_bears)
language_requirements = _create_sorted_commented_map(language_requirements)
file_path = os.path.join(PROJECT_DIR, BEAR_LANGUAGES_YAML)
with open(file_path, 'w') as outfile:
yaml.indent(mapping=2, sequence=4, offset=2)
Expand Down
36 changes: 18 additions & 18 deletions bear-languages.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AlexBear:
- Natural Language
AnnotationBear: []
AnnotationBear:
ApertiumLintBear:
- Apertium
ArtisticStyleBear:
Expand Down Expand Up @@ -137,7 +137,7 @@ DocumentationStyleBear:
- python3
- tcl
- vhdl
DuplicateFileBear: []
DuplicateFileBear:
ESLintBear:
- HTML
- JSX
Expand All @@ -146,7 +146,7 @@ ESLintBear:
- Typescript
ElmLintBear:
- Elm
FilenameBear: []
FilenameBear:
FormatRBear:
- R
GNUIndentBear:
Expand Down Expand Up @@ -186,7 +186,7 @@ HTMLLintBear:
- HTML
- Jinja2
- PHP
HTTPSBear: []
HTTPSBear:
HTTPoliceLintBear:
- HAR
HappinessLintBear:
Expand All @@ -195,10 +195,10 @@ HaskellLintBear:
- Haskell
HgCommitBear:
- Hg
IndentationBear: []
IndentationBear:
InferBear:
- Java
InvalidLinkBear: []
InvalidLinkBear:
JSComplexityBear:
- JavaScript
JSHintBear:
Expand All @@ -214,23 +214,23 @@ Jinja2Bear:
- Jinja2
JuliaLintBear:
- Julia
KeywordBear: []
KeywordBear:
LanguageToolBear:
- Natural Language
LatexLintBear:
- Tex
LicenseCheckBear: []
LicenseHeaderBear: []
LineCountBear: []
LineLengthBear: []
LicenseCheckBear:
LicenseHeaderBear:
LineCountBear:
LineLengthBear:
LuaLintBear:
- Lua
MarkdownBear:
- Markdown
MatlabIndentationBear:
- Matlab
- Octave
MementoBear: []
MementoBear:
MypyBear:
- Python
- Python 2
Expand Down Expand Up @@ -311,7 +311,7 @@ PythonPackageInitBear:
- Python
- Python 2
- Python 3
QuotesBear: []
QuotesBear:
RAMLLintBear:
- RAML
RLintBear:
Expand Down Expand Up @@ -346,7 +346,7 @@ ShellCheckBear:
- dash
- ksh
- sh
SpaceConsistencyBear: []
SpaceConsistencyBear:
SpellCheckBear:
- Natural Language
StyleLintBear:
Expand All @@ -366,8 +366,8 @@ TextLintBear:
- reStructuredText
TravisLintBear:
- YAML
URLBear: []
URLHeadBear: []
URLBear:
URLHeadBear:
VCSCommitMetadataBear:
- Git
VHDLLintBear:
Expand All @@ -389,7 +389,7 @@ YapfBear:
- Python
- Python 2
- Python 3
_CommitBear: []
coalaBear: []
_CommitBear:
coalaBear:
reSTLintBear:
- reStructuredText

0 comments on commit 5993a3c

Please sign in to comment.