Skip to content

Commit

Permalink
Correctly handle file modes when detecting placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
jdidion committed Jun 14, 2019
1 parent 372b7f4 commit 45f87c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

v4.1.2 (2019.06.14)
--------------------
* Correctly handle file modes when detecting placeholders

v4.1.1 (2019.06.14)
--------------------
* Correctly handle placeholder strings ('-', '_') as arguments to xopen
Expand Down
8 changes: 6 additions & 2 deletions xphyle/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
)
import warnings
from xphyle.types import (
FileMode,
ModeArg,
ModeAccess,
ModeAccessArg,
Permission,
Expand Down Expand Up @@ -198,14 +200,16 @@ def as_pure_path(


def convert_std_placeholder(
path: str, access: Optional[ModeAccessArg] = None
path: str, access: Optional[Union[ModeArg, ModeAccessArg]] = None
) -> Union[str, PurePath]:
if path == STDERR_STR:
return STDERR
elif path == STDIN_OR_STDOUT_STR:
if access:
if isinstance(access, str):
access_val = ModeAccess(access)
access_val = FileMode(access)
elif isinstance(access, FileMode):
access_val = cast(FileMode, access)
else:
access_val = cast(ModeAccess, access)
return STDIN if access_val.readable else STDOUT
Expand Down

0 comments on commit 45f87c0

Please sign in to comment.