From 0a32e87dfcbe0295ceecd77e4f80dccce89c2699 Mon Sep 17 00:00:00 2001 From: "Martin A. Brown" Date: Mon, 22 Feb 2016 13:04:03 -0800 Subject: [PATCH] moving isdirectory into utils --- tldp/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) 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)))