mirror of
https://git.srhtnin.garden/sarah/SaraSortd.git
synced 2026-10-14 18:48:11 +02:00
7.1: optional ValidInputDirs per [[Files]] entry
An output directory can now take different patterns from different input directories. Entries without it behave as before. Also fixes the README's outdated Names section (InDirConfName/OutDirConfName), NextNum and LogFileName. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
16e6b7196e
commit
78216fc352
5 files changed
+36
-13
No files matched your search
+21
-2
@@ -6,7 +6,7 @@ import shutil
|
||||
import time
|
||||
import toml
|
||||
|
||||
# Version = "7.0"
|
||||
# Version = "7.1"
|
||||
|
||||
ConfPath = "./GlobalConf.toml"
|
||||
|
||||
@@ -276,6 +276,21 @@ def LogWrite(Text):
|
||||
File.write(f"{Parse(String = ConfLog['All'], Path = ConfPath)}{Text}\n")
|
||||
|
||||
|
||||
def FileInputValid(File, FilePath, ParentName):
|
||||
# A [[Files]] entry can have its own ValidInputDirs (since 7.1), so one output directory can take
|
||||
# different patterns from different input directories. Without one, the entry takes files from
|
||||
# every input directory the output directory's own ValidInputDirs allows.
|
||||
ValidInputDirs = File.get("ValidInputDirs")
|
||||
if ValidInputDirs is None:
|
||||
return True
|
||||
|
||||
for ValidInputDir in ValidInputDirs:
|
||||
if fnmatch.fnmatchcase(os.path.dirname(FilePath), Parse(String = ValidInputDir, Parent = ParentName)):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def DecideNewPath(FilePath):
|
||||
UnsortedFile = os.path.basename(FilePath)
|
||||
|
||||
@@ -287,7 +302,8 @@ def DecideNewPath(FilePath):
|
||||
OutDirConfName = Parse(String = ConfNames["OutDirConfName"], Path = ConfPath, Parent = ParentName)
|
||||
OutDirConfPath = f"{Output}/{OutDirConfName}.toml"
|
||||
|
||||
ValidInputDirs = GetConf("ValidInputDirs", OutDirConfPath)
|
||||
ValidInputDirs = GetConf("ValidInputDirs", OutDirConfPath) or []
|
||||
InputDirValid = False
|
||||
|
||||
for ValidInputDir in ValidInputDirs:
|
||||
ValidInputDir = Parse(String = ValidInputDir, Parent = GetConf("ParentDir", OutDirConfPath))
|
||||
@@ -323,6 +339,9 @@ def DecideNewPath(FilePath):
|
||||
continue
|
||||
|
||||
for File in FileConf:
|
||||
if not FileInputValid(File, FilePath, ParentName):
|
||||
continue
|
||||
|
||||
Pattern = File["Pattern"]
|
||||
|
||||
TextOutput = Parse(String = ConfLog["MatchPattern"], VarCall = f"{UnsortedFile} against {Pattern}")
|
||||
|
||||
Reference in new issue
Block a user