Convert glob to take a Path and a str pattern

This commit is contained in:
Joe Rickerby
2020-07-10 12:57:05 +01:00
parent 4c0af9f152
commit 44e3198880
3 changed files with 8 additions and 5 deletions
+5 -2
View File
@@ -1,5 +1,6 @@
import io
import json
import os
import shlex
import subprocess
import sys
@@ -103,11 +104,13 @@ class DockerContainer:
cwd=to_path
)
def glob(self, pattern: PurePath) -> List[PurePath]:
def glob(self, path: PurePath, pattern: str) -> List[PurePath]:
glob_pattern = os.path.join(str(path), pattern)
path_strs = json.loads(self.call([
self.UTILITY_PYTHON,
'-c',
f'import sys, json, glob; json.dump(glob.glob({str(pattern)!r}), sys.stdout)'
f'import sys, json, glob; json.dump(glob.glob({glob_pattern!r}), sys.stdout)'
], capture_output=True))
return [PurePath(p) for p in path_strs]