-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add module for preprocessing input args and data.
- Loading branch information
1 parent
9d21c8e
commit baa2b1f
Showing
2 changed files
with
30 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
|
||
def ensure_list(arg, arg_name): | ||
""" | ||
Ensure input argument is a list. | ||
""" | ||
if arg is None: | ||
return [] | ||
elif isinstance(arg, str): | ||
return [arg] | ||
elif isinstance(arg, list): | ||
return arg | ||
else: | ||
raise TypeError(f"{arg_name} must be a string or a list of strings.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters