🧑💻 Py scripts refinements
This commit is contained in:
@@ -32,7 +32,7 @@ def set(file_path, define_name, value):
|
||||
|
||||
# Write the modified content back to the file only if changes were made
|
||||
if modified:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
with open(file_path, 'w', encoding='utf-8', newline='') as f:
|
||||
f.writelines(content)
|
||||
return True
|
||||
|
||||
@@ -59,7 +59,7 @@ def add(file_path, define_name, value=""):
|
||||
# If no blank line is found, append to the end
|
||||
content.append(f"#define {define_name}{value}\n")
|
||||
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
with open(file_path, 'w', encoding='utf-8', newline='') as f:
|
||||
f.writelines(content)
|
||||
|
||||
def enable(file_path, define_name, enable=True):
|
||||
@@ -96,7 +96,7 @@ def enable(file_path, define_name, enable=True):
|
||||
|
||||
# Write the modified content back to the file only if changes were made
|
||||
if modified:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
with open(file_path, 'w', encoding='utf-8', newline='') as f:
|
||||
f.writelines(content)
|
||||
|
||||
return found
|
||||
|
||||
@@ -59,7 +59,7 @@ def back_up_config(name):
|
||||
nr = 1 if nr == '' else nr + 1
|
||||
continue
|
||||
|
||||
with open(bak_path, 'w', encoding='utf-8') as b:
|
||||
with open(bak_path, 'w', encoding='utf-8', newline='') as b:
|
||||
b.writelines(f.readlines())
|
||||
break
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ if pioutil.is_pio_build():
|
||||
modified_text = text.replace("BOTH(", "ALL(").replace("EITHER(", "ANY(")
|
||||
if text != modified_text:
|
||||
conf_modified = True
|
||||
with open(conf_path, 'w', encoding="utf8") as file:
|
||||
with open(conf_path, 'w', encoding="utf8", newline='') as file:
|
||||
file.write(modified_text)
|
||||
|
||||
if conf_modified:
|
||||
|
||||
@@ -284,7 +284,7 @@ def compute_build_signature(env):
|
||||
for line in sec_lines[1:]: sec_list += '\n' + ext_fmt.format('', line)
|
||||
|
||||
config_ini = build_path / 'config.ini'
|
||||
with config_ini.open('w', encoding='utf-8') as outfile:
|
||||
with config_ini.open('w', encoding='utf-8', newline='') as outfile:
|
||||
filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' }
|
||||
vers = build_defines["CONFIGURATION_H_VERSION"]
|
||||
dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S")
|
||||
|
||||
Reference in New Issue
Block a user