Merge pull request #826 from mannaandpoem/dev_compatible_with_windows_path

modify re.sub(r"\\+", '/') to as_posix()
This commit is contained in:
geekan 2024-02-02 16:03:39 +08:00 committed by GitHub
commit 0118712ff8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,23 +60,22 @@ class DependencyFile:
root = self._filename.parent
try:
key = Path(filename).relative_to(root)
key = Path(filename).relative_to(root).as_posix()
except ValueError:
key = filename
skey = re.sub(r"\\+", "/", str(key)) # Compatible with windows path
key = str(key)
if dependencies:
relative_paths = []
for i in dependencies:
try:
s = str(Path(i).relative_to(root))
s = str(Path(i).relative_to(root).as_posix())
except ValueError:
s = str(i)
s = re.sub(r"\\+", "/", s) # Compatible with windows path
relative_paths.append(s)
self._dependencies[skey] = relative_paths
elif skey in self._dependencies:
del self._dependencies[skey]
self._dependencies[key] = relative_paths
elif key in self._dependencies:
del self._dependencies[key]
if persist:
await self.save()