mirror of
https://git.srhtnin.garden/sarah/SaraSortd.git
synced 2026-10-13 18:38:11 +02:00
Added a parameter that specifies where a file has to be from to be valid
for sorting. E.G: If this file isn't from this directory, I don't want it in this output directory.
This commit is contained in:
1 parent
ca0dde695d
commit
33af48076f
3 files changed
+157
-98
No files matched your search
+1
-1
@@ -22,7 +22,7 @@ VarCall = "%%"
|
|||||||
|
|
||||||
[DirectoryPaths]
|
[DirectoryPaths]
|
||||||
RootDir = "Unset"
|
RootDir = "Unset"
|
||||||
InputDir = [ "%Pic%/Input"]
|
InputDir = [ "%RootDir%/Input"]
|
||||||
OutputDir = [ "%RootDir%/Output"]
|
OutputDir = [ "%RootDir%/Output"]
|
||||||
LogDir = "%RootDir%/.Logs"
|
LogDir = "%RootDir%/.Logs"
|
||||||
FailedDir = "%RootDir%/.Failed"
|
FailedDir = "%RootDir%/.Failed"
|
||||||
|
|||||||
+2
-1
@@ -1,10 +1,11 @@
|
|||||||
Title = "Unset"
|
Title = "Unset"
|
||||||
LastFile = "Unset"
|
LastFile = "Unset"
|
||||||
ParentDir = "Unset"
|
ParentDir = "Unset"
|
||||||
|
ValidInputDirs = ["*"]
|
||||||
|
|
||||||
[[Files]]
|
[[Files]]
|
||||||
Pattern = "*"
|
Pattern = "*"
|
||||||
NewFileName = "~^"
|
NewFileName = "~^"
|
||||||
NextNum = 1
|
NextNum = 1
|
||||||
NextChar = "A"
|
NextChar = "A"
|
||||||
CaseSensitive = 0
|
CaseSensitive = 0
|
||||||
+154
-96
@@ -1,4 +1,10 @@
|
|||||||
import toml, os, datetime, re, shutil, fnmatch, time
|
import datetime
|
||||||
|
import fnmatch
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import time
|
||||||
|
import toml
|
||||||
|
|
||||||
ConfPath = "./Config.toml"
|
ConfPath = "./Config.toml"
|
||||||
|
|
||||||
@@ -10,11 +16,12 @@ ConfLog = None
|
|||||||
|
|
||||||
Start = True
|
Start = True
|
||||||
|
|
||||||
|
|
||||||
def Clear():
|
def Clear():
|
||||||
if os.name == 'nt':
|
if os.name == "nt":
|
||||||
os.system('cls')
|
os.system("cls")
|
||||||
else:
|
else:
|
||||||
os.system('clear')
|
os.system("clear")
|
||||||
|
|
||||||
|
|
||||||
def LoadGlobalConf():
|
def LoadGlobalConf():
|
||||||
@@ -48,64 +55,64 @@ def CheckConf(Path = ConfPath):
|
|||||||
def GetConf(Parameter, *Paths):
|
def GetConf(Parameter, *Paths):
|
||||||
for Path in Paths:
|
for Path in Paths:
|
||||||
ConfData = toml.load(Path)
|
ConfData = toml.load(Path)
|
||||||
|
|
||||||
if Parameter in ConfData:
|
if Parameter in ConfData:
|
||||||
return (ConfData[Parameter])
|
return ConfData[Parameter]
|
||||||
|
|
||||||
for Key, Value in ConfData.items():
|
for Key, Value in ConfData.items():
|
||||||
if (isinstance(Value, dict)):
|
if isinstance(Value, dict):
|
||||||
if (Parameter in Value):
|
if Parameter in Value:
|
||||||
return Value[Parameter]
|
return Value[Parameter]
|
||||||
elif (isinstance(Value, list)):
|
elif isinstance(Value, list):
|
||||||
for Item in Value:
|
for Item in Value:
|
||||||
if (isinstance(Item, dict) and Parameter in Item):
|
if isinstance(Item, dict) and Parameter in Item:
|
||||||
return Item[Parameter]
|
return Item[Parameter]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def UpdateConf(Path, Parameter, Value, Append = False):
|
def UpdateConf(Path, Parameter, Value, Append = False):
|
||||||
ConfData = toml.load(Path)
|
ConfData = toml.load(Path)
|
||||||
|
|
||||||
def UpdateInData(Data):
|
def UpdateInData(Data):
|
||||||
if isinstance(Data, dict):
|
if isinstance(Data, dict):
|
||||||
if Parameter in Data:
|
if Parameter in Data:
|
||||||
if (not Append):
|
if not Append:
|
||||||
Data[Parameter] = Value
|
Data[Parameter] = Value
|
||||||
|
|
||||||
else:
|
else:
|
||||||
Data.setdefault(Parameter, [])
|
Data.setdefault(Parameter, [])
|
||||||
|
|
||||||
if (Value not in Data[Parameter]):
|
if Value not in Data[Parameter]:
|
||||||
Data[Parameter].append(Value)
|
Data[Parameter].append(Value)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
for Key, DataValue in Data.items():
|
for Key, DataValue in Data.items():
|
||||||
if (UpdateInData(DataValue)):
|
if UpdateInData(DataValue):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif (isinstance(Data, list)):
|
elif isinstance(Data, list):
|
||||||
for Item in Data:
|
for Item in Data:
|
||||||
if (UpdateInData(Item)):
|
if UpdateInData(Item):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
Updated = UpdateInData(ConfData)
|
Updated = UpdateInData(ConfData)
|
||||||
|
|
||||||
if (not Updated):
|
if not Updated:
|
||||||
if not Append:
|
if not Append:
|
||||||
ConfData[Parameter] = Value
|
ConfData[Parameter] = Value
|
||||||
|
|
||||||
else:
|
else:
|
||||||
ConfData.setdefault(Parameter, [])
|
ConfData.setdefault(Parameter, [])
|
||||||
if (Value not in ConfData[Parameter]):
|
if Value not in ConfData[Parameter]:
|
||||||
ConfData[Parameter].append(Value)
|
ConfData[Parameter].append(Value)
|
||||||
|
|
||||||
with open(Path, 'w', encoding='utf-8') as File:
|
with open(Path, "w", encoding="utf-8") as File:
|
||||||
toml.dump(ConfData, File)
|
toml.dump(ConfData, File)
|
||||||
|
|
||||||
TextOutput = Parse(String = ConfLog["ValueSet"], VarCall = f"{Parameter} to {Value}")
|
TextOutput = Parse(String = ConfLog["ValueSet"], VarCall = f"{Parameter} to {Value}")
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
@@ -113,38 +120,40 @@ def UpdateConf(Path, Parameter, Value, Append = False):
|
|||||||
|
|
||||||
def Error():
|
def Error():
|
||||||
global Start
|
global Start
|
||||||
if (Conf["SafeMode"] == 1):
|
if Conf["SafeMode"] == 1:
|
||||||
Start = False
|
Start = False
|
||||||
|
|
||||||
|
|
||||||
def Speak(Text):
|
def Speak(Text):
|
||||||
if (Conf["SilentMode"] != 1):
|
if Conf["SilentMode"] != 1:
|
||||||
print(Text)
|
print(Text)
|
||||||
|
|
||||||
|
|
||||||
def Parse(String = None, Path = ConfPath,
|
def Parse(
|
||||||
NextNum = None,
|
String = None,
|
||||||
NextChar = None,
|
Path = ConfPath,
|
||||||
Parent = None,
|
NextNum = None,
|
||||||
OrgFile = None,
|
NextChar = None,
|
||||||
VarCall = None):
|
Parent = None,
|
||||||
|
OrgFile = None,
|
||||||
|
VarCall = None,
|
||||||
|
):
|
||||||
|
|
||||||
def Replacer(Match):
|
def Replacer(Match):
|
||||||
Content = Match.group(1)
|
Content = Match.group(1)
|
||||||
|
|
||||||
if (Content == None or Content == ""):
|
if Content is None or Content == "":
|
||||||
if (VarCall != None):
|
if VarCall is not None:
|
||||||
return str(VarCall)
|
return str(VarCall)
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
Value = GetConf(Content, Path)
|
Value = GetConf(Content, Path)
|
||||||
if (Value != None):
|
if Value is not None:
|
||||||
return Value
|
return Value
|
||||||
|
|
||||||
|
|
||||||
Now = datetime.datetime.now()
|
Now = datetime.datetime.now()
|
||||||
if (OrgFile != None):
|
if OrgFile is not None:
|
||||||
OrgFileName, OrgFileType = os.path.splitext(OrgFile)
|
OrgFileName, OrgFileType = os.path.splitext(OrgFile)
|
||||||
else:
|
else:
|
||||||
OrgFileName = None
|
OrgFileName = None
|
||||||
@@ -162,7 +171,7 @@ def Parse(String = None, Path = ConfPath,
|
|||||||
ConfVars["Hour"]: str(Now.hour),
|
ConfVars["Hour"]: str(Now.hour),
|
||||||
ConfVars["Minute"]: str(Now.minute),
|
ConfVars["Minute"]: str(Now.minute),
|
||||||
ConfVars["Second"]: str(Now.second),
|
ConfVars["Second"]: str(Now.second),
|
||||||
ConfVars["VarCall"]: str(VarCall)
|
ConfVars["VarCall"]: str(VarCall),
|
||||||
}
|
}
|
||||||
|
|
||||||
for Key, Value in VarValues.items():
|
for Key, Value in VarValues.items():
|
||||||
@@ -185,36 +194,53 @@ def Clone(Source, Destination, NewName, Delete = False):
|
|||||||
BaseName = os.path.basename(Source)
|
BaseName = os.path.basename(Source)
|
||||||
shutil.move(os.path.join(Destination, BaseName), os.path.join(Destination, NewName))
|
shutil.move(os.path.join(Destination, BaseName), os.path.join(Destination, NewName))
|
||||||
|
|
||||||
if (Delete):
|
if Delete:
|
||||||
os.remove(Source)
|
os.remove(Source)
|
||||||
|
|
||||||
|
|
||||||
def Dir(Path, Output = True, CopyConf = True):
|
def Dir(Path, Output = True, CopyConf = True):
|
||||||
ParentName = os.path.basename(Path)
|
ParentName = os.path.basename(Path)
|
||||||
os.makedirs(Path, exist_ok=True)
|
os.makedirs(Path, exist_ok=True)
|
||||||
|
|
||||||
if (CopyConf):
|
|
||||||
NewDirConf = f"{Parse(String = ConfNames["DirConfName"], Path = ConfPath, Parent = ParentName)}.toml"
|
|
||||||
if (Conf["OverwriteDirConf"] == 1 or not os.path.exists(os.path.join(f"{Path}/{NewDirConf}"))):
|
|
||||||
Clone("DirConfig.toml", Path, NewDirConf)
|
|
||||||
UpdateConf(f"{Path}/{Parse(String = ConfNames["DirConfName"], Path = ConfPath, Parent = ParentName)}.toml", "ParentDir", ParentName)
|
|
||||||
UpdateConf(f"{Path}/{Parse(String = ConfNames["DirConfName"], Path = ConfPath, Parent = ParentName)}.toml", "Title", f"{ParentName} Config")
|
|
||||||
|
|
||||||
if (Output):
|
if CopyConf:
|
||||||
|
NewDirConf = f"{Parse(String = ConfNames['DirConfName'], Path = ConfPath, Parent = ParentName)}.toml"
|
||||||
|
if Conf["OverwriteDirConf"] == 1 or not os.path.exists(
|
||||||
|
os.path.join(f"{Path}/{NewDirConf}")
|
||||||
|
):
|
||||||
|
Clone("DirConfig.toml", Path, NewDirConf)
|
||||||
|
UpdateConf(
|
||||||
|
f"{Path}/{Parse(String = ConfNames['DirConfName'], Path = ConfPath, Parent = ParentName)}.toml",
|
||||||
|
"ParentDir",
|
||||||
|
ParentName,
|
||||||
|
)
|
||||||
|
UpdateConf(
|
||||||
|
f"{Path}/{Parse(String=ConfNames['DirConfName'], Path=ConfPath, Parent=ParentName)}.toml",
|
||||||
|
"Title",
|
||||||
|
f"{ParentName} Config",
|
||||||
|
)
|
||||||
|
|
||||||
|
if Output:
|
||||||
ParsedPath = Parse(String = Path)
|
ParsedPath = Parse(String = Path)
|
||||||
ParsedOutputs = [Parse(String = Dir) for Dir in ConfDirs["OutputDir"]]
|
ParsedOutputs = [Parse(String = Dir) for Dir in ConfDirs["OutputDir"]]
|
||||||
if (ParsedPath not in ParsedOutputs):
|
if ParsedPath not in ParsedOutputs:
|
||||||
UpdateConf(ConfPath, "OutputDir", Path, True)
|
UpdateConf(ConfPath, "OutputDir", Path, True)
|
||||||
|
|
||||||
|
|
||||||
def LogWrite(Text):
|
def LogWrite(Text):
|
||||||
if (GetConf("Logging", ConfPath) == 1):
|
if GetConf("Logging", ConfPath) == 1:
|
||||||
if (ConfDirs["LogDir"] != None and ConfNames != "Unset"):
|
if ConfDirs["LogDir"] is not None and ConfNames != "Unset":
|
||||||
if (ConfNames["LogFileName"] != None and ConfNames["LogFileName"] != "Unset"):
|
if (
|
||||||
Dir(Parse(String = ConfDirs["LogDir"], Path = ConfPath), Output = False, CopyConf = False)
|
ConfNames["LogFileName"] is not None
|
||||||
LogFile = f"{Parse(String = ConfDirs["LogDir"], Path = ConfPath)}/{Parse(String = ConfNames["LogFileName"], Path = ConfPath)}.log"
|
and ConfNames["LogFileName"] != "Unset"
|
||||||
with open(LogFile, "a", encoding="utf-8", buffering=1) as File:
|
):
|
||||||
File.write(f"{Parse(String = ConfLog["All"], Path = ConfPath)}{Text}\n")
|
Dir(
|
||||||
|
Parse(String=ConfDirs["LogDir"], Path=ConfPath),
|
||||||
|
Output=False,
|
||||||
|
CopyConf=False,
|
||||||
|
)
|
||||||
|
LogFile = f"{Parse(String=ConfDirs['LogDir'], Path=ConfPath)}/{Parse(String=ConfNames['LogFileName'], Path=ConfPath)}.log"
|
||||||
|
with open(LogFile, "a", encoding = "utf-8", buffering = 1) as File:
|
||||||
|
File.write(f"{Parse(String = ConfLog['All'], Path = ConfPath)}{Text}\n")
|
||||||
|
|
||||||
|
|
||||||
def DecideNewPath(FilePath):
|
def DecideNewPath(FilePath):
|
||||||
@@ -222,13 +248,27 @@ def DecideNewPath(FilePath):
|
|||||||
|
|
||||||
for Output in ConfDirs["OutputDir"]:
|
for Output in ConfDirs["OutputDir"]:
|
||||||
Output = Parse(String = Output, Path = ConfPath)
|
Output = Parse(String = Output, Path = ConfPath)
|
||||||
|
|
||||||
ParentName = os.path.basename(Output)
|
ParentName = os.path.basename(Output)
|
||||||
|
|
||||||
DirConfName = Parse(String = ConfNames["DirConfName"], Path = ConfPath, Parent = ParentName)
|
DirConfName = Parse(String = ConfNames["DirConfName"], Path = ConfPath, Parent = ParentName)
|
||||||
DirConfPath = f"{Output}/{DirConfName}.toml"
|
DirConfPath = f"{Output}/{DirConfName}.toml"
|
||||||
|
|
||||||
if not os.path.exists(DirConfPath):
|
ValidInputDirs = GetConf("ValidInputDirs", DirConfPath)
|
||||||
|
print(ValidInputDirs)
|
||||||
|
|
||||||
|
for ValidInputDir in ValidInputDirs:
|
||||||
|
ValidInputDir = Parse(String = ValidInputDir, Parent = GetConf("ParentDir", DirConfPath))
|
||||||
|
|
||||||
|
TextOutput = Parse(String = ConfLog["MatchPattern"], VarCall = f"{os.path.dirname(FilePath)} against {ValidInputDir}")
|
||||||
|
LogWrite(TextOutput)
|
||||||
|
Speak(TextOutput)
|
||||||
|
|
||||||
|
InputDirValid = fnmatch.fnmatchcase(os.path.dirname(FilePath), ValidInputDir)
|
||||||
|
if (InputDirValid):
|
||||||
|
break
|
||||||
|
|
||||||
|
if not os.path.exists(DirConfPath) or not InputDirValid:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
FileConf = GetConf("Files", DirConfPath)
|
FileConf = GetConf("Files", DirConfPath)
|
||||||
@@ -239,61 +279,77 @@ def DecideNewPath(FilePath):
|
|||||||
for File in FileConf:
|
for File in FileConf:
|
||||||
Pattern = File["Pattern"]
|
Pattern = File["Pattern"]
|
||||||
|
|
||||||
TextOutput = Parse(ConfLog["MatchPattern"], VarCall = f"{UnsortedFile} against {Pattern}")
|
TextOutput = Parse(String = ConfLog["MatchPattern"], VarCall = f"{UnsortedFile} against {Pattern}")
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
|
|
||||||
if (File["CaseSensitive"] == 1):
|
if File["CaseSensitive"] == 1:
|
||||||
Match = fnmatch.fnmatchcase(UnsortedFile, Pattern)
|
Match = fnmatch.fnmatchcase(UnsortedFile, Pattern)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
Match = fnmatch.fnmatch(UnsortedFile.lower(), Pattern.lower())
|
Match = fnmatch.fnmatch(UnsortedFile.lower(), Pattern.lower())
|
||||||
|
|
||||||
if Match:
|
if Match:
|
||||||
NewFileName = File["NewFileName"]
|
NewFileName = File["NewFileName"]
|
||||||
|
|
||||||
if (ConfVars["NextNum"] in NewFileName):
|
if ConfVars["NextNum"] in NewFileName:
|
||||||
UpdateConf(DirConfPath, "NextNum", (int(GetConf("NextNum", DirConfPath)) + 1))
|
UpdateConf(
|
||||||
|
DirConfPath,
|
||||||
|
"NextNum",
|
||||||
|
(int(GetConf("NextNum", DirConfPath)) + 1),
|
||||||
|
)
|
||||||
|
|
||||||
if (ConfVars["NextChar"] in NewFileName):
|
if ConfVars["NextChar"] in NewFileName:
|
||||||
CurrentChar = GetConf("NextChar", DirConfPath)
|
CurrentChar = GetConf("NextChar", DirConfPath)
|
||||||
if (CurrentChar and len(CurrentChar) == 1 and CurrentChar.isalpha()):
|
if CurrentChar and len(CurrentChar) == 1 and CurrentChar.isalpha():
|
||||||
NewChar = chr(((ord(CurrentChar.upper()) - 65 +1) % 26) +65)
|
NewChar = chr(((ord(CurrentChar.upper()) - 65 + 1) % 26) + 65)
|
||||||
UpdateConf(DirConfPath, "NextChar", NewChar)
|
UpdateConf(DirConfPath, "NextChar", NewChar)
|
||||||
|
|
||||||
NewFileName = Parse(String = NewFileName, Path = DirConfPath, OrgFile = UnsortedFile, NextNum = File["NextNum"], NextChar = File["NextChar"], Parent = ParentName)
|
NewFileName = Parse(
|
||||||
|
String = NewFileName,
|
||||||
|
Path = DirConfPath,
|
||||||
|
OrgFile = UnsortedFile,
|
||||||
|
NextNum = File["NextNum"],
|
||||||
|
NextChar = File["NextChar"],
|
||||||
|
Parent = ParentName,
|
||||||
|
)
|
||||||
return f"{Output}/{NewFileName}"
|
return f"{Output}/{NewFileName}"
|
||||||
|
|
||||||
|
|
||||||
def Sort(FilePath):
|
def Sort(FilePath):
|
||||||
NewPath = DecideNewPath(FilePath)
|
NewPath = DecideNewPath(FilePath)
|
||||||
|
|
||||||
if (NewPath == None):
|
if NewPath is None:
|
||||||
Dir(Parse(String = ConfDirs["FailedDir"]), Output = False, CopyConf = False)
|
Dir(Parse(String = ConfDirs["FailedDir"]), Output = False, CopyConf = False)
|
||||||
NewName = os.path.basename(FilePath)
|
NewName = os.path.basename(FilePath)
|
||||||
Clone(FilePath, Parse(String = ConfDirs["FailedDir"]), NewName, True)
|
Clone(FilePath, Parse(String = ConfDirs["FailedDir"]), NewName, True)
|
||||||
|
|
||||||
TextOutput = Parse(String = ConfLog["NotSorted"], VarCall = FilePath)
|
TextOutput = Parse(String = ConfLog["NotSorted"], VarCall = FilePath)
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
return
|
return
|
||||||
|
|
||||||
NewDirPath = os.path.dirname(NewPath)
|
NewDirPath = os.path.dirname(NewPath)
|
||||||
NewName = os.path.basename(NewPath)
|
NewName = os.path.basename(NewPath)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Clone(FilePath, NewDirPath, NewName, True)
|
Clone(FilePath, NewDirPath, NewName, True)
|
||||||
UpdateConf(f"{NewDirPath}/{Parse(String = ConfNames["DirConfName"], Parent = os.path.basename(NewDirPath))}.toml", "LastFile", NewName)
|
UpdateConf(
|
||||||
|
f"{NewDirPath}/{Parse(String = ConfNames['DirConfName'], Parent = os.path.basename(NewDirPath))}.toml",
|
||||||
|
"LastFile",
|
||||||
|
NewName,
|
||||||
|
)
|
||||||
|
|
||||||
TextOutput = Parse(String = ConfLog["Sorted"], VarCall = f"{FilePath} to {NewDirPath}/{NewName}")
|
TextOutput = Parse(
|
||||||
|
String = ConfLog["Sorted"], VarCall = f"{FilePath} to {NewDirPath}/{NewName}"
|
||||||
|
)
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
|
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
Dir(Parse(String = ConfDirs["FailedDir"]), Output = False, CopyConf = False)
|
Dir(Parse(String = ConfDirs["FailedDir"]), Output = False, CopyConf = False)
|
||||||
NewName = os.path.basename(NewPath)
|
NewName = os.path.basename(NewPath)
|
||||||
Clone(FilePath, Parse(String = ConfDirs["FailedDir"]), NewName, True)
|
Clone(FilePath, Parse(String = ConfDirs["FailedDir"]), NewName, True)
|
||||||
|
|
||||||
TextOutput = Parse(String = ConfLog["NotSorted"], VarCall = FilePath)
|
TextOutput = Parse(String = ConfLog["NotSorted"], VarCall = FilePath)
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
@@ -303,37 +359,39 @@ def Sort(FilePath):
|
|||||||
|
|
||||||
def Init():
|
def Init():
|
||||||
global Conf, ConfVars, ConfDirs, ConfNames, ConfLog
|
global Conf, ConfVars, ConfDirs, ConfNames, ConfLog
|
||||||
|
|
||||||
LoadGlobalConf()
|
LoadGlobalConf()
|
||||||
if (Conf != None):
|
if Conf is not None:
|
||||||
CheckConf()
|
CheckConf()
|
||||||
|
|
||||||
if (Start):
|
if Start:
|
||||||
TextOutput = Parse(String = ConfLog["Start"], Path = ConfPath)
|
TextOutput = Parse(String = ConfLog["Start"], Path = ConfPath)
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
|
|
||||||
Main()
|
Main()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
TextOutput = Parse(String = ConfLog["NotStart"])
|
TextOutput = Parse(String = ConfLog["NotStart"])
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("NO CONFIG FOUND! Make sure the 'Config.toml' is in the same directory as 'SaraSortd.py'")
|
print(
|
||||||
|
"NO CONFIG FOUND! Make sure the 'Config.toml' is in the same directory as 'SaraSortd.py'"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def Main():
|
def Main():
|
||||||
for Output in ConfDirs["OutputDir"]:
|
for Output in ConfDirs["OutputDir"]:
|
||||||
Output = Parse(String = Output)
|
Output = Parse(String = Output)
|
||||||
Dir(Output)
|
Dir(Output)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
for Input in ConfDirs["InputDir"]:
|
for Input in ConfDirs["InputDir"]:
|
||||||
InputPath = Parse(Input)
|
InputPath = Parse(Input)
|
||||||
|
|
||||||
if not os.path.exists(InputPath):
|
if not os.path.exists(InputPath):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -341,11 +399,11 @@ def Main():
|
|||||||
FilePath = os.path.join(InputPath, FileName)
|
FilePath = os.path.join(InputPath, FileName)
|
||||||
|
|
||||||
if os.path.isfile(FilePath):
|
if os.path.isfile(FilePath):
|
||||||
FileName = os.path.basename(FilePath)
|
FileName = os.path.basename(FilePath)
|
||||||
if (FileName.startswith(".") and Conf["DotFiles"] == 0):
|
if FileName.startswith(".") and Conf["DotFiles"] == 0:
|
||||||
continue
|
continue
|
||||||
Sort(FilePath)
|
Sort(FilePath)
|
||||||
|
|
||||||
time.sleep(Conf.get("CheckInput", 10))
|
time.sleep(Conf.get("CheckInput", 10))
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@@ -354,4 +412,4 @@ def Main():
|
|||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
|
|
||||||
|
|
||||||
Init()
|
Init()
|
||||||
Reference in new issue
Block a user