diff --git a/tldp/utils.py b/tldp/utils.py index 40127ba..f370c52 100644 --- a/tldp/utils.py +++ b/tldp/utils.py @@ -24,6 +24,7 @@ def getLogger(**opts): logger = getLogger() + def firstfoundfile(locations): '''return the first existing file from a list of filenames (or None)''' for option in locations: @@ -32,6 +33,12 @@ def firstfoundfile(locations): return None +def isdirectory(d): + if os.path.exists(d): + return d + return None + + def stem_and_ext(name): '''return (stem, ext) for any relative or absolute filename''' return os.path.splitext(os.path.basename(os.path.normpath(name)))