Skip to content

Commit

Permalink
Automatic expand user for path, file_target etc #915
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Mar 7, 2018
1 parent 5f39f94 commit d88dd2f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sos/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import pkg_resources
from shlex import quote
import subprocess
from pathlib import Path
from pathlib import Path, WindowsPath, PosixPath

from collections.abc import Sequence, Iterable

Expand Down Expand Up @@ -424,6 +424,11 @@ class path(type(Path())):
'R': lambda x: x,
}

def __new__(cls, *args, **kwargs):
if cls is Path:
cls = WindowsPath if os.name == 'nt' else PosixPath

return cls._from_parts(*args, **kwargs).expanduser()

def is_external(self):
try:
Expand Down

0 comments on commit d88dd2f

Please sign in to comment.