Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
maybe fixes #110: recognize pathlib.Path objects when given to uproot…
Browse files Browse the repository at this point in the history
….open, uproot.iterate, uproot.numentries, and uproot.lazyarrays
  • Loading branch information
jpivarski committed Aug 7, 2018
1 parent 59b23cc commit b261b7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions uproot/rootio.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
################################################################ high-level interface

def open(path, localsource=MemmapSource.defaults, xrootdsource=XRootDSource.defaults, httpsource=HTTPSource.defaults, **options):
if path.__class__.__module__ == "pathlib":
import pathlib
if isinstance(path, pathlib.Path):
path = str(path)

parsed = urlparse(path)
if _bytesid(parsed.scheme) == b"file" or len(parsed.scheme) == 0:
path = parsed.netloc + parsed.path
Expand Down
4 changes: 4 additions & 0 deletions uproot/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def _delayedraise(excinfo):
raise err.with_traceback(trc)

def _filename_explode(x):
if x.__class__.__module__ == "pathlib":
import pathlib
if isinstance(x, pathlib.Path):
x = str(x)
parsed = urlparse(x)
if _bytesid(parsed.scheme) == b"file" or len(parsed.scheme) == 0:
pattern = os.path.expanduser(parsed.netloc + parsed.path)
Expand Down

0 comments on commit b261b7a

Please sign in to comment.