Skip to content

Commit

Permalink
More path fixes for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomaz-Vieira committed Apr 23, 2021
1 parent 5b290e9 commit f09f72a
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions ilastik/utility/data_url.py
Expand Up @@ -205,7 +205,10 @@ def from_string(cls, url: str) -> "SimpleDataPath":
return SimpleDataPath(Path(url))

def exists(self) -> bool:
return self.file_path.exists()
try:
return self.file_path.exists()
except OSError: # FIXME: remove this after python 3.8
return False

def relative_to(self, other: Path) -> "SimpleDataPath":
return SimpleDataPath(self.file_path.relative_to(other))
Expand Down Expand Up @@ -286,7 +289,11 @@ def relative_to(self: ADP, other: Path) -> ADP:
return self.__class__(self.file_path.relative_to(other), self.internal_path)

def glob(self, smart: bool = True) -> Sequence["ArchiveDataPath"]:
if smart and self.file_path.exists():
try:
external_path_exists = self.file_path.exists()
except OSError:
external_path_exists = False
if smart and external_path_exists:
externally_expanded_paths = [self]
else:
externally_expanded_paths = [
Expand Down Expand Up @@ -327,7 +334,10 @@ def glob_internal(self) -> Sequence["H5DataPath"]:
]

def exists(self) -> bool:
if not self.file_path.exists():
try:
if not self.file_path.exists():
return False
except OSError: # FIXME: remove this after python 3.8
return False
with h5py.File(str(self.file_path), "r") as f:
return self.internal_path.as_posix() in f
Expand All @@ -351,10 +361,16 @@ def glob_internal(self) -> Sequence["N5DataPath"]:
]

def exists(self) -> bool:
if not self.file_path.exists():
try:
if not self.file_path.exists():
return False
except OSError: # FIXME: remove this after python 3.8
return False
with z5py.N5File(str(self.file_path)) as f:
return self.internal_path.as_posix() in f
try:
return self.internal_path.as_posix() in f
except OSError: # FIXME: remove this after python 3.8
return False


class NpzDataPath(ArchiveDataPath, supported_extensions=["npz"]):
Expand All @@ -373,7 +389,10 @@ def glob_internal(self) -> Sequence["NpzDataPath"]:
]

def exists(self) -> bool:
if not self.file_path.exists():
try:
if not self.file_path.exists():
return False
except OSError: # FIXME: remove this after python 3.8
return False
return self.internal_path in NpzDataPath.list_internal_paths(self.file_path)

Expand Down

0 comments on commit f09f72a

Please sign in to comment.