Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Jan 12, 2018
2 parents 545f450 + b591785 commit 4dd5984
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
docs
masonite.egg-info
venv
venv
.vscode
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# LaraPy
# Masonite
Core files for the python framework

To get started with this repo, [read the CONTRIBUTING.md file on the masonite repo](https://github.com/josephmancuso/masonite/blob/master/CONTRIBUTING.md)
39 changes: 22 additions & 17 deletions masonite/storage.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
from config import storage, application
import os
import sass

class Storage(object):

def __init__(self):
pass

# this function will compile sass files only if the libsass module installed
def compile_sass(self):
matches = []
for files in storage.SASSFILES['importFrom']:
for root, dirnames, filenames in os.walk(os.path.join(application.BASE_DIRECTORY, files)):
for filename in filenames:
if filename.endswith(('.sass', '.scss')) and not filename.startswith('_'):
matches.append(os.path.join(root, filename))
try:
import sass
except ImportError as e:
pass
else:
matches = []
for files in storage.SASSFILES['importFrom']:
for root, dirnames, filenames in os.walk(os.path.join(application.BASE_DIRECTORY, files)):
for filename in filenames:
if filename.endswith(('.sass', '.scss')) and not filename.startswith('_'):
matches.append(os.path.join(root, filename))

for filename in matches:
with open(filename) as f:
compiled_sass = sass.compile(
string=f.read(), include_paths=storage.SASSFILES['includePaths']
)
name = filename.split(os.sep)[-1].replace('.scss', '').replace('.sass', '')
write_file = os.path.join(os.path.join(application.BASE_DIRECTORY,
storage.SASSFILES['compileTo']), '{0}.css'.format(name))
with open(write_file, 'w') as r:
r.write(compiled_sass)
for filename in matches:
with open(filename) as f:
compiled_sass = sass.compile(
string=f.read(), include_paths=storage.SASSFILES['includePaths']
)
name = filename.split(os.sep)[-1].replace('.scss', '').replace('.sass', '')
write_file = os.path.join(os.path.join(application.BASE_DIRECTORY,
storage.SASSFILES['compileTo']), '{0}.css'.format(name))
with open(write_file, 'w') as r:
r.write(compiled_sass)

0 comments on commit 4dd5984

Please sign in to comment.