Skip to content

Commit

Permalink
Allow Path to paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrachuk committed Aug 26, 2019
1 parent 90a25f7 commit d3a853e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lightweight/files.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from glob import iglob
from pathlib import Path
from typing import Iterator, Optional
from typing import Iterator, Optional, Union


def create_file(path: Path, *, content: str):
Expand All @@ -9,10 +9,12 @@ def create_file(path: Path, *, content: str):
f.write(content)


def paths(glob_path: str) -> Iterator[Path]:
def paths(glob_path: Union[str, Path]) -> Iterator[Path]:
"""An iterator of paths matching the provided `glob`_ pattern.
_glob: https://en.wikipedia.org/wiki/Glob_(programming)"""
if isinstance(glob_path, Path):
return iter([glob_path])
return map(Path, iglob(glob_path, recursive=True))


Expand Down

0 comments on commit d3a853e

Please sign in to comment.