Allow find_libraries to accept lists or strings (#3363)

* Allow find_libraries to accept lists or strings

* Convert one more example from list to string
This commit is contained in:
Adam J. Stewart
2017-03-04 11:23:57 -06:00
committed by GitHub
parent 192a4b30f0
commit a2d70a45fb
10 changed files with 30 additions and 28 deletions

View File

@@ -568,20 +568,22 @@ def find_libraries(args, root, shared=True, recurse=False):
"""Returns an iterable object containing a list of full paths to
libraries if found.
Args:
args: iterable object containing a list of library names to \
search for (e.g. 'libhdf5')
root: root folder where to start searching
shared: if True searches for shared libraries, otherwise for static
recurse: if False search only root folder, if True descends top-down \
from the root
:param args: Library name(s) to search for
:type args: str or collections.Sequence
:param str root: The root directory to start searching from
:param bool shared: if True searches for shared libraries,
otherwise for static
:param bool recurse: if False search only root folder,
if True descends top-down from the root
Returns:
list of full paths to the libraries that have been found
:returns: The libraries that have been found
:rtype: LibraryList
"""
if not isinstance(args, collections.Sequence) or isinstance(args, str):
message = '{0} expects a sequence of strings as first argument'
message += ' [got {1} instead]'
if isinstance(args, str):
args = [args]
elif not isinstance(args, collections.Sequence):
message = '{0} expects a string or sequence of strings as the '
message += 'first argument [got {1} instead]'
raise TypeError(message.format(find_libraries.__name__, type(args)))
# Construct the right suffix for the library