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]
+2 -2
View File
@@ -167,7 +167,7 @@ def build(options: BuildOptions) -> None:
*get_build_verbosity_extra_flags(options.build_verbosity)
], env=env)
built_wheel = docker.glob(built_wheel_dir / '*.whl')[0]
built_wheel = docker.glob(built_wheel_dir, '*.whl')[0]
repaired_wheel_dir = temp_dir / 'repaired_wheel'
docker.call(['rm', '-rf', repaired_wheel_dir])
@@ -179,7 +179,7 @@ def build(options: BuildOptions) -> None:
repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir)
docker.call(['sh', '-c', repair_command_prepared], env=env)
repaired_wheels = docker.glob(repaired_wheel_dir / '*.whl')
repaired_wheels = docker.glob(repaired_wheel_dir, '*.whl')
if options.test_command:
# set up a virtual environment to install and test from, to make sure
+1 -1
View File
@@ -138,7 +138,7 @@ def test_dir_operations(tmp_path: Path):
assert test_binary_data == bytes(output, encoding='utf8', errors='surrogateescape')
# test glob
assert container.glob(dst_dir / '*.dat') == [dst_file]
assert container.glob(dst_dir, '*.dat') == [dst_file]
# test copy dir out
new_test_dir = tmp_path / 'test_dir_new'