Windows compatibility

This commit is contained in:
2026-08-20 12:01:31 +02:00
parent 7c366a9ca4
commit ac4ab782b2
20 changed files with 634 additions and 134 deletions
+9 -8
View File
@@ -1,11 +1,15 @@
import re
from pathlib import Path
from platform_utils import validate_windows_labels
def natural_key(text):
return [int(c) if c.isdigit() else c.lower() for c in re.split(r'(\d+)', str(text))]
def read_all_labels(base_dir):
return list(filter(None, (Path(base_dir) / "labels").read_text().splitlines()))
labels = list(filter(None, (Path(base_dir) / "labels").read_text().splitlines()))
validate_windows_labels(labels)
return labels
def enonce_total(base_dir):
text_dir = Path(base_dir) / 'Text'
@@ -25,18 +29,15 @@ def enonce_total(base_dir):
import os
import shlex
from platform_utils import open_path
def edit_file_and_enter(file):
editor = os.environ.get("EDITOR")
try:
if editor:
subprocess.run(shlex.split(editor) + [str(file)])
subprocess.run(shlex.split(editor, posix=os.name != "nt") + [str(file)])
else:
if sys.platform.startswith("linux"):
subprocess.run(["xdg-open", str(file)])
elif sys.platform == "darwin":
subprocess.run(["open", str(file)])
else:
os.startfile(str(file))
open_path(file)
input("Press ENTER here once you have saved and closed the text file...")
except Exception as e:
print(f"Error running editor: {e}")