Skip to content

Commit 66a424d

Browse files
committed
Allow spaces in directory names when looking for gain references
1 parent 3d747ad commit 66a424d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/murfey/instrument_server/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ def get_possible_gain_references(
237237
headers={"Authorization": f"Bearer {tokens[session_id]}"},
238238
).json()
239239
candidates = []
240-
for gf in secure_path(Path(machine_config["gain_reference_directory"])).glob(
241-
"**/*"
242-
):
240+
for gf in secure_path(
241+
Path(machine_config["gain_reference_directory"]), keep_spaces=True
242+
).glob("**/*"):
243243
if gf.is_file():
244244
candidates.append(
245245
File(

src/murfey/util/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ def sanitise_nonpath(in_string: str) -> str:
6262
return in_string
6363

6464

65-
def secure_path(in_path: Path) -> Path:
66-
secured_parts = [secure_filename(p) for p in in_path.parts]
65+
def secure_path(in_path: Path, keep_spaces: bool = False) -> Path:
66+
if keep_spaces:
67+
secured_parts = [secure_filename(p) for p in in_path.parts if " " not in p]
68+
else:
69+
secured_parts = [secure_filename(p) for p in in_path.parts]
6770
return Path("/".join(secured_parts))
6871

6972

0 commit comments

Comments
 (0)