mercurial/hgweb/common.py
changeset 3276 db9d2a624521
parent 3244 f045b049a704
child 3853 c0b449154a90
--- a/mercurial/hgweb/common.py	Fri Oct 06 16:24:14 2006 +0200
+++ b/mercurial/hgweb/common.py	Fri Oct 06 18:28:50 2006 +0200
@@ -42,3 +42,20 @@
     except (TypeError, OSError):
         # illegal fname or unreadable file
         return ""
+
+def style_map(templatepath, style):
+    """Return path to mapfile for a given style.
+
+    Searches mapfile in the following locations:
+    1. templatepath/style/map
+    2. templatepath/map-style
+    3. templatepath/map
+    """
+    locations = style and [os.path.join(style, "map"), "map-"+style] or []
+    locations.append("map")
+    for location in locations:
+        mapfile = os.path.join(templatepath, location)
+        if os.path.isfile(mapfile):
+            return mapfile
+    raise RuntimeError("No hgweb templates found in %r" % templatepath)
+