Commits

Anonymous committed 6f07009

added defaults to get_config()

Comments (0)

Files changed (1)

     blame = yaml.safe_load(open(blame_file, 'r').read())
     return blame
 
-def get_config(site_root, role=None):
-    """Returns merged site and role config.
-    Falls back to blame.yaml if no role given.
-    Falls back to just site.yaml if no role given and no blame file found"""
+def get_config(site_root=None, role=None):
+    """
+    Returns merged site and role config.  Tries hard to come up with
+    something if you don't pass in a role or site name.
+    """
+
+    # If no site_root given, then look above os.getcwd()
+    if site_root is None:
+        site_root = get_site_root(os.getcwd())
+
+    # If role is None, then try getting it from cmd line and/or env vars ourselves
+    role = role or get_role() 
+
+    # If role is still none, then look for a blame file, which doesn't require a role. 
     if role is None:
         try:
             return get_blame(site_root)[1]['config']
         except IOError:
+            # If no role and no blame file, give up.
             return get_site_config(site_root)
-    else:
-        config = get_site_config(site_root)
-        config.update(get_role_config(role))
-        return config
+
+    config = get_site_config(site_root)
+    config.update(get_role_config(role))
+    return config
 
 def get_template_path(template, site_root=None):
     """