mirror of
https://git.srhtnin.garden/sarah/SaraSort.git
synced 2026-10-14 10:48:11 +02:00
Follow SaraSortd 7.3: catch-alls as fallback, path parsing, nested variables
The tester tries specific patterns before catch-alls, directory paths only get %Name% lookups and date/time variables, and nested %Name%s resolve. Warnings for what 7.3 fixed are gone; a SaraSortd older than 7.3 gets a warning. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
28252e3101
commit
d0e5eb2086
2 files changed
+87
-60
No files matched your search
+5
-5
@@ -151,12 +151,12 @@ def Backup(Config: AppConfig) -> Optional[Path]:
|
||||
return BackupPath
|
||||
|
||||
|
||||
def _RemapList(TheSetup: Setup, Values, Remap: dict[str, str], Parent: Optional[str] = None) -> None:
|
||||
def _RemapList(TheSetup: Setup, Values, Remap: dict[str, str]) -> None:
|
||||
"""Points entries that resolve to a moved directory at its new path."""
|
||||
if not isinstance(Values, list):
|
||||
return
|
||||
for Index in range(len(Values)):
|
||||
Resolved = TheSetup.Parse(str(Values[Index]), Parent=Parent)
|
||||
Resolved = TheSetup.ParsePath(str(Values[Index]))
|
||||
if Resolved in Remap:
|
||||
Values[Index] = TheSetup.Shorthand(Remap[Resolved])
|
||||
|
||||
@@ -175,7 +175,7 @@ def ApplyBundle(Config: AppConfig, TheBundle: Bundle, Remap: dict[str, str]) ->
|
||||
# A moved directory keeps its own config file from [DirConfs] (SaraSortd 7.2).
|
||||
DirConfs = GlobalDoc.get("DirConfs")
|
||||
for Key in list(DirConfs.keys()) if DirConfs is not None else []:
|
||||
Resolved = TheSetup.Parse(str(Key)).rstrip("/")
|
||||
Resolved = TheSetup.ParsePath(str(Key)).rstrip("/")
|
||||
if Resolved in Remap:
|
||||
DirConfs[TheSetup.Shorthand(Remap[Resolved])] = DirConfs[Key]
|
||||
del DirConfs[Key]
|
||||
@@ -191,9 +191,9 @@ def ApplyBundle(Config: AppConfig, TheBundle: Bundle, Remap: dict[str, str]) ->
|
||||
Target = Remap.get(Entry.Directory, Entry.Directory)
|
||||
Document = tomlkit.parse(Entry.Content)
|
||||
Parent = os.path.basename(Entry.Directory)
|
||||
_RemapList(TheSetup, Document.get("ValidInputDirs"), Remap, Parent)
|
||||
_RemapList(TheSetup, Document.get("ValidInputDirs"), Remap)
|
||||
for FileEntry in Document.get("Files", []):
|
||||
_RemapList(TheSetup, FileEntry.get("ValidInputDirs"), Remap, Parent)
|
||||
_RemapList(TheSetup, FileEntry.get("ValidInputDirs"), Remap)
|
||||
NewName = os.path.basename(Target)
|
||||
if NewName != Parent:
|
||||
if "ParentDir" in Document:
|
||||
|
||||
Reference in new issue
Block a user