File tree 2 files changed +11
-9
lines changed
2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 6
6
GMTTempFile ,
7
7
build_arg_string ,
8
8
fmt_docstring ,
9
- kwargs_to_strings ,
9
+ is_nonstr_iter ,
10
10
use_alias ,
11
11
)
12
12
13
13
14
14
@fmt_docstring
15
15
@use_alias (G = "download" , V = "verbose" )
16
- @kwargs_to_strings (fname = "sequence_space" )
17
16
def which (fname , ** kwargs ):
18
17
r"""
19
18
Find the full path to specified files.
@@ -63,6 +62,9 @@ def which(fname, **kwargs):
63
62
FileNotFoundError
64
63
If the file is not found.
65
64
"""
65
+ if is_nonstr_iter (fname ): # Got a list of files
66
+ fname = " " .join (fname )
67
+
66
68
with GMTTempFile () as tmpfile :
67
69
with Session () as lib :
68
70
lib .call_module (
Original file line number Diff line number Diff line change 1
1
"""
2
2
Test pygmt.which.
3
3
"""
4
- import os
4
+ from pathlib import Path
5
5
6
6
import pytest
7
7
from pygmt import which
@@ -13,20 +13,20 @@ def test_which():
13
13
Make sure `which` returns file paths for @files correctly without errors.
14
14
"""
15
15
for fname in ["tut_quakes.ngdc" , "tut_bathy.nc" ]:
16
- cached_file = which (f"@{ fname } " , download = "c" )
17
- assert os . path . exists (cached_file )
18
- assert os . path . basename (cached_file ) == fname
16
+ cached_file = which (fname = f"@{ fname } " , download = "c" )
17
+ assert Path ( cached_file ). exists ()
18
+ assert Path (cached_file ). name == fname
19
19
20
20
21
21
def test_which_multiple ():
22
22
"""
23
23
Make sure `which` returns file paths for multiple @files correctly.
24
24
"""
25
25
filenames = ["ridge.txt" , "tut_ship.xyz" ]
26
- cached_files = which (fname = [f"@{ fname } " for fname in filenames ], download = "c" )
26
+ cached_files = which ([f"@{ fname } " for fname in filenames ], download = "c" )
27
27
for cached_file in cached_files :
28
- assert os . path . exists (cached_file )
29
- assert os . path . basename (cached_file ) in filenames
28
+ assert Path ( cached_file ). exists ()
29
+ assert Path (cached_file ). name in filenames
30
30
31
31
32
32
def test_which_fails ():
You can’t perform that action at this time.
0 commit comments