From f7bdc54c697ff24bec1bd0781666ac05401bafb2 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/python') diff --git a/lib/python/kle2xy.py b/lib/python/kle2xy.py index 929144319..bff1d025b 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 5c2980009..234ffb12c 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 c4ee20cba..e17d8bb9b 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
.