forked from pmarti/pydashie
-
Notifications
You must be signed in to change notification settings - Fork 3
/
compile.py
56 lines (42 loc) · 1.75 KB
/
compile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import logging
import StringIO
from scss import Scss
log = logging.getLogger('PydashieCompiler')
logging.basicConfig()
log.setLevel(logging.INFO)
#Requirements:
#pip install pyScss
#
def main():
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)
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)
css_output = StringIO.StringIO()
css = Scss()
css_output.write('\n'.join([css.compile(open(filePath).read()) for filePath in fileList]))
fileList = []
for root, subFolders, files in os.walk(dashing_dir):
for fileName in files:
if 'css' in fileName and 'scss' not in fileName:
if (not fileName.endswith('~') and
not fileName == "application.css"):
# discard any temporary files
# ignore the base application.css (duplication issues)
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]))
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 to : %s' % app_css_filepath)
if __name__ == '__main__':
main()