Commits

Anonymous committed 4739342

Extracted first_existing_subdir() from first_existing_home_subdir()

Comments (0)

Files changed (1)

app_sizer/utils.py

             flash("{0} - {1}"
                     .format(getattr(form, field).label.text, error), category)
 
-def first_existing_home_subdir(*paths):
+def first_existing_subdir(roots, *paths):
     paths_tried = []
     for path in paths:
-        for root in [os.environ[x] for x in ["HOME", "USERPROFILE"] if x in os.environ]:
+        for root in roots:
             ep = os.path.join(root, path)
             paths_tried.append(ep)
             if os.path.exists(ep):
                 return os.path.normpath(ep)
     return None
+
+def first_existing_home_subdir(*paths):
+    roots = [os.environ[x] for x in ["HOME", "USERPROFILE"] if x in os.environ]
+    return first_existing_subdir(roots, *paths)
+