Skip to content

Commit

Permalink
Fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
cphyc committed Feb 15, 2022
1 parent 97d60de commit 859292a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions yt/frontends/ramses/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def check_standard_files(folder, iout):
return ok

@staticmethod
def _match_output_and_group(path: Path) -> Tuple[Path, Optional[Path], Optional[int]]:
def _match_output_and_group(path: Path) -> Tuple[Path, Optional[Path], Optional[str]]:
iout_match = OUTPUT_DIR_RE.match(path.name)

if not iout_match:
Expand All @@ -115,6 +115,7 @@ def _match_output_and_group(path: Path) -> Tuple[Path, Optional[Path], Optional[
# Two cases:
# 1. regular structure (all files in the output_XXXXX folder)
# 2. group structure (files spread in group_YYYYY folders)
group_dir: Optional[Path]

if iout_match.group(1) == "output":
# Case 1, unless the current folder contains a group folder itself
Expand All @@ -135,32 +136,36 @@ def _match_output_and_group(path: Path) -> Tuple[Path, Optional[Path], Optional[


@classmethod
def test_with_folder_name(cls, output_dir) -> Tuple[bool, Optional[Path], Optional[Path], Optional[Path]]:
def test_with_folder_name(cls, output_dir: Path) -> Tuple[bool, Optional[Path], Optional[Path], Optional[Path]]:
output_dir, group_dir, iout = cls._match_output_and_group(output_dir)

ok = output_dir.is_dir() and iout is not None

info_fname: Optional[Path]

if ok:
ok &= cls.check_standard_files(group_dir or output_dir, iout)
info_fname = (group_dir or output_dir) / f"info_{iout}.txt"
else:
output_dir, group_dir, info_fname = None, None, None
info_fname = None

return ok, output_dir, group_dir, info_fname

@classmethod
def test_with_standard_file(cls, filename) -> Tuple[bool, Optional[Path], Optional[Path], Optional[Path]]:
def test_with_standard_file(cls, filename: Path) -> Tuple[bool, Optional[Path], Optional[Path], Optional[Path]]:
output_dir, group_dir, iout = cls._match_output_and_group(filename.parent)
ok = (
filename.is_file()
and STANDARD_FILE_RE.match(filename.name) is not None
and iout is not None
)

info_fname: Optional[Path]

if ok:
ok &= cls.check_standard_files(group_dir or output_dir, iout)
info_fname = (group_dir or output_dir) / f"info_{iout}.txt"
else:
output_dir, group_dir, info_fname = None, None, None
info_fname = None

return ok, output_dir, group_dir, info_fname

Expand Down

0 comments on commit 859292a

Please sign in to comment.