From 842fff39d3fed1eed14dc8646f315f3d1ee388cb Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sun, 8 Mar 2020 18:30:43 -0500 Subject: [PATCH] tools: codeformat.py New code formatter based on upstream. --- tools/codeformat.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 tools/codeformat.py diff --git a/tools/codeformat.py b/tools/codeformat.py new file mode 100755 index 000000000..65811649c --- /dev/null +++ b/tools/codeformat.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +import importlib.util +import os + +# import codeformat from upstream micropython tools +spec = importlib.util.spec_from_file_location( + "codeformat", + os.path.join(os.path.dirname(__file__), "..", "..", "..", "tools", "codeformat.py"), +) +codeformat = importlib.util.module_from_spec(spec) +spec.loader.exec_module(codeformat) + +# override with Pybricks paths + +codeformat.PATHS = [ + "ports/pybricks/bricks/**/*.[ch]", + "ports/pybricks/extmod/*.[ch]", + "ports/pybricks/lib/pbio/**/*.[ch]", + "ports/pybricks/py/*.[ch]", + # Python + "ports/pybricks/bricks/**/*.py", + "ports/pybricks/tests/**/*.py", + "ports/pybricks/tools/**/*.py", +] + +codeformat.EXCLUSIONS = [ + "ports/pybricks/bricks/nxt/nxt-firmware-drivers/**/*.[ch]", + "ports/pybricks/bricks/*/build*/**/*.[ch]", +] + +if __name__ == "__main__": + codeformat.main()