Commits

Steve Losh committed ce39b01

lesscss: get the lesscss functionality up and running.

  • Participants
  • Parent commits f9bb5ad

Comments (0)

Files changed (1)

garter/lesscss.py

-def _render_less_css():
-    for fn in less_files:
-        css_path = os.path.join(static_dir, fn + '.css')
-        less_path = os.path.join(static_dir, fn + '.less')
-        css_mtime, less_mtime = os.path.getmtime(css_path), os.path.getmtime(less_path)
-        if less_mtime >= css_mtime:
-            subprocess.call(['lessc', css_path, less_path], shell=False)
+import os, subprocess
 
 def lesscss(app):
-    app.before_request(_render_less_css)
+    if app.debug:
+        @app.before_request
+        def _render_less_css():
+            static_dir = app.root_path + app.static_path
+            
+            less_paths = []
+            for path, subdirs, filenames in os.walk(static_dir):
+                less_paths.extend([
+                    os.path.join(path, f)
+                    for f in filenames if os.path.splitext(f)[1] == '.less'
+                ])
+            
+            for less_path in less_paths:
+                css_path = os.path.splitext(less_path)[0] + '.css'
+                css_mtime, less_mtime = os.path.getmtime(css_path), os.path.getmtime(less_path)
+                if less_mtime >= css_mtime:
+                    print 'UPDATING %s' % less_path
+                    subprocess.call(['lessc', less_path, css_path], shell=False)