From dfa3631a44eee30c7c734cf023ef1316e240eca3 Mon Sep 17 00:00:00 2001 From: skullydazed Date: Wed, 20 Nov 2019 14:54:18 -0800 Subject: Add flake8 to our test suite and fix all errors (#7379) * Add flake8 to our test suite and fix all errors * Add some documentation --- lib/python/kle2xy.py | 2 +- lib/python/qmk/cli/compile.py | 3 -- lib/python/qmk/cli/config.py | 94 ++++++++++++++++++++++-------------- lib/python/qmk/cli/doctor.py | 2 - lib/python/qmk/cli/flash.py | 10 +--- lib/python/qmk/cli/json/keymap.py | 1 - lib/python/qmk/cli/kle2json.py | 4 +- lib/python/qmk/cli/list/keyboards.py | 26 +++++----- lib/python/qmk/cli/pytest.py | 16 +++--- lib/python/qmk/keymap.py | 4 -- lib/python/qmk/path.py | 1 - 11 files changed, 80 insertions(+), 83 deletions(-) (limited to 'lib') diff --git a/lib/python/kle2xy.py b/lib/python/kle2xy.py index 9291443190..bff1d025b7 100644 --- a/lib/python/kle2xy.py +++ b/lib/python/kle2xy.py @@ -46,7 +46,7 @@ class KLE2xy(list): if 'name' in properties: self.name = properties['name'] - def parse_layout(self, layout): + def parse_layout(self, layout): # noqa FIXME(skullydazed): flake8 says this has a complexity of 25, it should be refactored. # Wrap this in a dictionary so hjson will parse KLE raw data layout = '{"layout": [' + layout + ']}' layout = hjson.loads(layout)['layout'] diff --git a/lib/python/qmk/cli/compile.py b/lib/python/qmk/cli/compile.py index 5c29800096..234ffb12ca 100755 --- a/lib/python/qmk/cli/compile.py +++ b/lib/python/qmk/cli/compile.py @@ -2,9 +2,6 @@ You can compile a keymap already in the repo or using a QMK Configurator export. """ -import json -import os -import sys import subprocess from argparse import FileType diff --git a/lib/python/qmk/cli/config.py b/lib/python/qmk/cli/config.py index c4ee20cba5..e17d8bb9ba 100644 --- a/lib/python/qmk/cli/config.py +++ b/lib/python/qmk/cli/config.py @@ -1,8 +1,5 @@ """Read and write configuration settings """ -import os -import subprocess - from milc import cli @@ -12,6 +9,54 @@ def print_config(section, key): cli.echo('%s.%s{fg_cyan}={fg_reset}%s', section, key, cli.config[section][key]) +def show_config(): + """Print the current configuration to stdout. + """ + for section in cli.config: + for key in cli.config[section]: + print_config(section, key) + + +def parse_config_token(config_token): + """Split a user-supplied configuration-token into its components. + """ + section = option = value = None + + if '=' in config_token and '.' not in config_token: + cli.log.error('Invalid configuration token, the key must be of the form
.