Skip to content

Commit f362315

Browse files
committed
Usermod script cleanup
Fix whitespace and remove unused imports
1 parent e80a7c6 commit f362315

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

pio-scripts/load_usermods.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
Import('env')
2-
import os.path
32
from collections import deque
43
from pathlib import Path # For OS-agnostic path manipulation
54
from click import secho
65
from SCons.Script import Exit
76
from platformio.builder.tools.piolib import LibBuilderBase
8-
from platformio.package.manager.library import LibraryPackageManager
97

108
usermod_dir = Path(env["PROJECT_DIR"]).resolve() / "usermods"
119

@@ -21,7 +19,7 @@ def find_usermod(mod: str) -> Path:
2119
return mp
2220
mp = usermod_dir / f"{mod}_v2"
2321
if mp.exists():
24-
return mp
22+
return mp
2523
mp = usermod_dir / f"usermod_v2_{mod}"
2624
if mp.exists():
2725
return mp
@@ -50,7 +48,7 @@ def is_wled_module(dep: LibBuilderBase) -> bool:
5048
# Utility function for assembling usermod include paths
5149
def cached_add_includes(dep, dep_cache: set, includes: deque):
5250
""" Add dep's include paths to includes if it's not in the cache """
53-
if dep not in dep_cache:
51+
if dep not in dep_cache:
5452
dep_cache.add(dep)
5553
for include in dep.get_include_dirs():
5654
if include not in includes:
@@ -96,7 +94,7 @@ def wrapped_ConfigureProjectLibBuilder(xenv):
9694
secho(
9795
f"ERROR: libArchive=false is missing on usermod(s) {' '.join(broken_usermods)} -- modules will not compile in correctly",
9896
fg="red",
99-
err=True)
97+
err=True)
10098
Exit(1)
10199

102100
return result

pio-scripts/validate_modules.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import re
2-
import sys
32
from pathlib import Path # For OS-agnostic path manipulation
43
from typing import Iterable
54
from click import secho
65
from SCons.Script import Action, Exit
7-
from platformio import util
86
from platformio.builder.tools.piolib import LibBuilderBase
97

108

@@ -56,8 +54,8 @@ def validate_map_file(source, target, env):
5654
Exit(1)
5755

5856
# Identify the WLED module source directories
59-
module_lib_builders = [builder for builder in env.GetLibBuilders() if is_wled_module(env, builder)]
60-
57+
module_lib_builders = [builder for builder in env.GetLibBuilders() if is_wled_module(env, builder)]
58+
6159
if env.GetProjectOption("custom_usermods","") == "*":
6260
# All usermods build; filter non-platform-OK modules
6361
module_lib_builders = [builder for builder in module_lib_builders if env.IsCompatibleLibBuilder(builder)]
@@ -68,16 +66,15 @@ def validate_map_file(source, target, env):
6866
f"ERROR: Modules {[b.name for b in incompatible_builders]} are not compatible with this platform!",
6967
fg="red",
7068
err=True)
71-
Exit(1)
72-
pass
69+
Exit(1)
7370

7471
# Extract the values we care about
7572
modules = {Path(builder.build_dir).name: builder.name for builder in module_lib_builders}
7673
secho(f"INFO: {len(modules)} libraries linked as WLED optional/user modules")
7774

7875
# Now parse the map file
7976
map_file_contents = read_lines(map_file_path)
80-
usermod_object_count = count_usermod_objects(map_file_contents)
77+
usermod_object_count = count_usermod_objects(map_file_contents)
8178
secho(f"INFO: {usermod_object_count} usermod object entries")
8279

8380
confirmed_modules = check_map_file_objects(map_file_contents, modules.keys())

0 commit comments

Comments
 (0)