Flow: added patterns kept their input when RootDir ends in /

This commit is contained in:
sarah committed 2026-10-09 10:59:48 +02:00
1 parent 6c472241d1
commit f1935a119b
1 file changed
+8 -2
+8 -2
View File
@@ -253,13 +253,19 @@ class Setup:
return None if not Root or Root == "Unset" else str(Root)
def Shorthand(self, PathText: str) -> str:
"""How a path is written into GlobalConf: %RootDir%/... when under RootDir."""
"""How a path is written into GlobalConf: %RootDir%/... when under RootDir.
Only when it parses back to the very same path: SaraSortd compares
ValidInputDirs as text, so RootDir = "/home/sarah/" must give
%RootDir%Downloads, not %RootDir%/Downloads (/home/sarah//Downloads)."""
Root = self.RootDir()
Call = self.Vars.get("VarCall", "%%")
if Root and len(Call) >= 2:
Root = Root.rstrip("/")
if PathText == Root or PathText.startswith(Root + "/"):
return f"{Call[0]}RootDir{Call[1]}{PathText[len(Root):]}"
Lookup = f"{Call[0]}RootDir{Call[1]}"
for Short in (Lookup + PathText[len(Root):], Lookup + PathText[len(Root) + 1:]):
if self.ParsePath(Short) == PathText:
return Short
return PathText
def ConfFolder(self, PathText: str) -> Path: