File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 66 GMTTempFile ,
77 build_arg_string ,
88 fmt_docstring ,
9- kwargs_to_strings ,
9+ is_nonstr_iter ,
1010 use_alias ,
1111)
1212
1313
1414@fmt_docstring
1515@use_alias (G = "download" , V = "verbose" )
16- @kwargs_to_strings (fname = "sequence_space" )
1716def which (fname , ** kwargs ):
1817 r"""
1918 Find the full path to specified files.
@@ -63,6 +62,9 @@ def which(fname, **kwargs):
6362 FileNotFoundError
6463 If the file is not found.
6564 """
65+ if is_nonstr_iter (fname ): # Got a list of files
66+ fname = " " .join (fname )
67+
6668 with GMTTempFile () as tmpfile :
6769 with Session () as lib :
6870 lib .call_module (
Original file line number Diff line number Diff line change 11"""
22Test pygmt.which.
33"""
4- import os
4+ from pathlib import Path
55
66import pytest
77from pygmt import which
@@ -13,20 +13,20 @@ def test_which():
1313 Make sure `which` returns file paths for @files correctly without errors.
1414 """
1515 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
1919
2020
2121def test_which_multiple ():
2222 """
2323 Make sure `which` returns file paths for multiple @files correctly.
2424 """
2525 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" )
2727 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
3030
3131
3232def test_which_fails ():
You can’t perform that action at this time.
0 commit comments