From 993e9cc1e29eabbce7785dcae7bf9022e77442af Mon Sep 17 00:00:00 2001 From: Chris Fane Date: Sun, 16 Feb 2014 15:02:12 +0000 Subject: [PATCH] Altered compile script to compile from local folders into assets folder. This should allow the creation of new widgets --- compile.py | 58 ++++++++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/compile.py b/compile.py index b5b649b..49c80ef 100644 --- a/compile.py +++ b/compile.py @@ -1,8 +1,10 @@ import os - import logging import shutil import subprocess +import argparse +import StringIO + from scss import Scss log = logging.getLogger('PydashieCompiler') @@ -15,43 +17,20 @@ log.setLevel(logging.INFO) # def main(): - #Options - refreshDashingCode=True - - - #Check out dashing into temp directory + current_directory = os.getcwd() + + logging.info("Compiling from local files ...") + dashing_dir = os.path.join(current_directory, 'pydashie') + logging.info("Using walk path : %s" % dashing_dir) - tmp_dir = os.path.join(current_directory, 'tmp') - if not os.path.exists(tmp_dir): - log.info('Creating tmp dir %s' % tmp_dir) - os.mkdir(tmp_dir) - - tmp_build_dir = os.path.join(tmp_dir, 'bin') - if not os.path.exists(tmp_build_dir): - log.info('Creating bin dir %s' % tmp_build_dir) - os.mkdir(tmp_build_dir) - - dashing_dir = os.path.join(current_directory, 'tmp', 'dashing') - if refreshDashingCode: - if os.path.exists(dashing_dir): - log.info('Removing old Dashing Clone') - shutil.rmtree(dashing_dir) - - log.info('Creating dashing tmp dir %s' % dashing_dir) - os.mkdir(dashing_dir) - - os.chdir(dashing_dir) - if refreshDashingCode: - log.info('Cloning Dashing Code') - subprocess.call("git clone https://github.com/Shopify/dashing", shell=True) fileList = [] for root, subFolders, files in os.walk(dashing_dir): for fileName in files: if 'scss' in fileName: fileList.append(os.path.join(root, fileName)) log.info('Found SCSS to compile: %s' % fileName) - import StringIO + css_output = StringIO.StringIO() css = Scss() css_output.write('\n'.join([css.compile(open(filePath).read()) for filePath in fileList])) @@ -59,14 +38,19 @@ def main(): fileList = [] for root, subFolders, files in os.walk(dashing_dir): for fileName in files: - if 'css' in fileName and 'scss' not in fileName: - fileList.append(os.path.join(root, fileName)) - log.info('Found CSS to append: %s' % fileName) + if 'css' in fileName and 'scss' not in fileName: + if not fileName.endswith('~'): + # discard any temporary files + fileList.append(os.path.join(root, fileName)) + log.info('Found CSS to append: %s' % fileName) css_output.write('\n'.join([open(filePath).read() for filePath in fileList])) - - with open(os.path.join(tmp_build_dir, 'application.css'), 'w') as outfile: + + app_css_filepath = os.path.join(current_directory, 'pydashie/assets/stylesheets/application.css') + with open(app_css_filepath, 'w') as outfile: outfile.write(css_output.getvalue()) - log.info('Wrote CSS out') + log.info('Wrote CSS out to : %s' % app_css_filepath ) + if __name__ == '__main__': - main() \ No newline at end of file + + main()