Permalink
Browse files

merge `output/css.d/*` into one `output/base.css`

  • Loading branch information...
mahomahomaho authored and C Anthony Risinger committed Dec 19, 2012
1 parent 6e9b198 commit d36e81fe2f1ed10d8f1d79db36cf903dc855b74b
Showing with 19 additions and 0 deletions.
  1. +19 −0 pyjs/src/pyjs/browser.py
View
@@ -139,6 +139,25 @@ def merge_resources(self, dir_name):
self.merged_public.add(lib)
break
+ # merge all output/css.d/* files into one output/base.css file
+ css_d_path = os.path.join(self.output, 'css.d')
+ base_css_path = os.path.join(self.output, 'base.css')
+
+ if os.path.exists(css_d_path):
+ hdr = '/* name: %s\n * md5: %s\n */\n'
+ with open(base_css_path, 'w') as base_css:
+ for root, dirs, files in os.walk(css_d_path):
+ docroot = root.replace(root, '', 1).strip('/')
+ for frag in files:
+ frag_path = os.path.join(root, frag)
+ with open(frag_path) as fd:
+ csstxt = fd.read()
+ base_css.write(hdr % (
+ os.path.relpath(frag_path, self.output),
+ md5(csstxt).hexdigest(),
+ ))
+ base_css.write(csstxt)
+
def find_boilerplate(self, name):
if not self.top_module_path:
raise RuntimeError('Top module not found %r' % self.top_module)

0 comments on commit d36e81f

Please sign in to comment.