🔨 Simplify scripts with pathlib (#24574)

This commit is contained in:
Scott Lahteine
2022-08-01 01:14:58 -05:00
parent c3f2586445
commit 3b30951e83
14 changed files with 182 additions and 196 deletions

View File

@ -10,12 +10,10 @@
#
import pioutil
if pioutil.is_pio_build():
import os,sys,marlin
Import("env")
from SCons.Script import DefaultEnvironment
board = DefaultEnvironment().BoardConfig()
import sys,marlin
env = marlin.env
board = env.BoardConfig()
board_keys = board.get("build").keys()
#
@ -56,7 +54,7 @@ if pioutil.is_pio_build():
if 'rename' in board_keys:
def rename_target(source, target, env):
firmware = os.path.join(target[0].dir.path, board.get("build.rename"))
os.replace(target[0].path, firmware)
from pathlib import Path
Path(target[0].path).replace(Path(target[0].dir.path, board.get("build.rename")))
marlin.add_post_action(rename_target)