mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2026-01-04 05:40:31 -07:00
🔨 PowerShell compatibility (#27720)
This commit is contained in:
parent
0d87dd9d51
commit
2f4f2bce15
8 changed files with 23 additions and 23 deletions
|
|
@ -296,7 +296,7 @@ if __name__ == "__main__":
|
|||
parser.add_argument('--layer', help='only include layers which have this string in their names')
|
||||
args = parser.parse_args()
|
||||
|
||||
f = open(args.filename, "r")
|
||||
f = open(args.filename, "r", encoding='utf-8')
|
||||
data = f.read()
|
||||
|
||||
# First pass to grab viewbox
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ def set(file_path, define_name, value):
|
|||
Returns True if the define was found and replaced, False otherwise.
|
||||
'''
|
||||
# Read the contents of the file
|
||||
with open(file_path, 'r') as f:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
content = f.readlines()
|
||||
|
||||
modified = False
|
||||
|
|
@ -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') as f:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
f.writelines(content)
|
||||
return True
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ def add(file_path, define_name, value=""):
|
|||
'''
|
||||
Insert a define on the first blank line in a file.
|
||||
'''
|
||||
with open(file_path, 'r') as f:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
content = f.readlines()
|
||||
|
||||
# Prepend a space to the value if it's not empty
|
||||
|
|
@ -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') as f:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
f.writelines(content)
|
||||
|
||||
def enable(file_path, define_name, enable=True):
|
||||
|
|
@ -68,7 +68,7 @@ def enable(file_path, define_name, enable=True):
|
|||
Returns True if the define was found, False otherwise.
|
||||
'''
|
||||
# Read the contents of the file
|
||||
with open(file_path, 'r') as f:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
content = f.readlines()
|
||||
|
||||
# Prepare the regex
|
||||
|
|
@ -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') as f:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
f.writelines(content)
|
||||
|
||||
return found
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ def set(file_path, define_name, value):
|
|||
Returns True if the define was found and replaced, False otherwise.
|
||||
'''
|
||||
# Read the contents of the file
|
||||
with open(file_path, 'r') as f:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
content = f.readlines()
|
||||
|
||||
modified = False
|
||||
|
|
@ -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') as f:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
f.writelines(content)
|
||||
return True
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ def add(file_path, define_name, value=""):
|
|||
'''
|
||||
Insert a define on the first blank line in a file.
|
||||
'''
|
||||
with open(file_path, 'r') as f:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
content = f.readlines()
|
||||
|
||||
# Prepend a space to the value if it's not empty
|
||||
|
|
@ -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') as f:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
f.writelines(content)
|
||||
|
||||
def enable(file_path, define_name, enable=True):
|
||||
|
|
@ -68,7 +68,7 @@ def enable(file_path, define_name, enable=True):
|
|||
Returns True if the define was found, False otherwise.
|
||||
'''
|
||||
# Read the contents of the file
|
||||
with open(file_path, 'r') as f:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
content = f.readlines()
|
||||
|
||||
# Prepare the regex
|
||||
|
|
@ -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') as f:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
f.writelines(content)
|
||||
|
||||
return found
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ def report_version(conf):
|
|||
print(k + ': ' + v)
|
||||
|
||||
def write_opt_file(conf, outpath='Marlin/apply_config.sh'):
|
||||
with open(outpath, 'w') as outfile:
|
||||
with open(outpath, 'w', encoding='utf-8') as outfile:
|
||||
for key, val in conf.items():
|
||||
if key in ('__INITIAL_HASH', 'VERSION'): continue
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ def write_opt_file(conf, outpath='Marlin/apply_config.sh'):
|
|||
def back_up_config(name):
|
||||
# Back up the existing file before modifying it
|
||||
conf_path = 'Marlin/' + name
|
||||
with open(conf_path, 'r') as f:
|
||||
with open(conf_path, 'r', encoding='utf-8') as f:
|
||||
# Write a filename.bak#.ext retaining the original extension
|
||||
parts = conf_path.split('.')
|
||||
nr = ''
|
||||
|
|
@ -59,7 +59,7 @@ def back_up_config(name):
|
|||
nr = 1 if nr == '' else nr + 1
|
||||
continue
|
||||
|
||||
with open(bak_path, 'w') as b:
|
||||
with open(bak_path, 'w', encoding='utf-8') as b:
|
||||
b.writelines(f.readlines())
|
||||
break
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ def main():
|
|||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
infile = open(args.config_file, 'r')
|
||||
infile = open(args.config_file, 'r', encoding='utf-8')
|
||||
except:
|
||||
print(f'No {args.config_file} found.')
|
||||
sys.exit(1)
|
||||
|
|
|
|||
|
|
@ -78,7 +78,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') as file:
|
||||
with open(conf_path, 'w', encoding="utf8") as file:
|
||||
file.write(modified_text)
|
||||
|
||||
if conf_modified:
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ def group_options(schema):
|
|||
def load_boards():
|
||||
bpath = Path("Marlin/src/core/boards.h")
|
||||
if bpath.is_file():
|
||||
with bpath.open() as bfile:
|
||||
with bpath.open(encoding='utf-8') as bfile:
|
||||
boards = []
|
||||
for line in bfile:
|
||||
if line.startswith("#define BOARD_"):
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ def format_pins(argv):
|
|||
file_text = sys.stdin.read()
|
||||
else:
|
||||
# Open and read the file src_file
|
||||
with open(src_file, 'r') as rf: file_text = rf.read()
|
||||
with open(src_file, 'r', encoding='utf-8') as rf: file_text = rf.read()
|
||||
|
||||
if len(file_text) == 0:
|
||||
print('No text to process')
|
||||
|
|
@ -80,7 +80,7 @@ def format_pins(argv):
|
|||
# Read from file or STDIN until it terminates
|
||||
filtered = process_text(file_text)
|
||||
if dst_file:
|
||||
with open(dst_file, 'w') as wf: wf.write(filtered)
|
||||
with open(dst_file, 'w', encoding='utf-8') as wf: wf.write(filtered)
|
||||
else:
|
||||
print(filtered)
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ def boards_checks(argv):
|
|||
logmsg('Checking boards file:', src_file)
|
||||
|
||||
# Open the file
|
||||
with open(src_file, 'r') as f:
|
||||
with open(src_file, 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# Get the board names and numbers
|
||||
|
|
@ -85,7 +85,7 @@ def boards_checks(argv):
|
|||
# Validate that pins.h has all the boards mentioned in it
|
||||
#
|
||||
pins_boards = []
|
||||
with open('Marlin/src/pins/pins.h', 'r') as f:
|
||||
with open('Marlin/src/pins/pins.h', 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
if_count = 0
|
||||
for line in lines:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue