mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 09:37:25 +00:00
all: Format with black.
Also activate auto formatting. Bump flake8 and mark black disagreements in setup.cfg.
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
import os
|
||||
|
||||
# Get list of scripts to be parsed
|
||||
script_names = [f for f in os.listdir('.') if f != 'make_shared_examples.py']
|
||||
script_names = [f for f in os.listdir(".") if f != "make_shared_examples.py"]
|
||||
|
||||
# Go through all template scripts
|
||||
for script in (open(f, 'r') for f in script_names):
|
||||
for script in (open(f, "r") for f in script_names):
|
||||
|
||||
# First line contains hub info
|
||||
hubs = script.readline().strip().split()[3:]
|
||||
@@ -15,17 +15,17 @@ for script in (open(f, 'r') for f in script_names):
|
||||
|
||||
for hub in hubs:
|
||||
# Determine path to the hub
|
||||
hub_path = os.path.join('..', 'hub_' + hub.lower())
|
||||
hub_path = os.path.join("..", "hub_" + hub.lower())
|
||||
|
||||
# Reset source script
|
||||
script.seek(0)
|
||||
script.readline()
|
||||
|
||||
# Open destination script:
|
||||
with open(os.path.join(hub_path, script.name), 'w') as dest_file:
|
||||
with open(os.path.join(hub_path, script.name), "w") as dest_file:
|
||||
|
||||
# Read script line by line
|
||||
for line in script.readlines():
|
||||
|
||||
# Replace hub name if present
|
||||
dest_file.writelines(line.replace('ExampleHub', hub))
|
||||
dest_file.writelines(line.replace("ExampleHub", hub))
|
||||
|
||||
Reference in New Issue
Block a user