# Path: management/shell.py
# def cat(*args):
#     data = ""
#     for path in args:
#         if type(path) == list:
#             for p in path:
#                 if os.path.exists(p):
#                     data = data + open(p,'r').read()
#         elif os.path.exists(path):
#             data = data + open(path,'r').read()
#     return stream(data)
# 
# Path: management/settings.py
# class settings(object):
#     def __init__(self,package,strip_leading=0):
#         if strip_leading > 0:
#             self._scope = '.'.join(package.split('.')[strip_leading:])
#         else:
#             self._scope = package
# 
#     def default(self, keys):
#         update_default(self._scope,keys)
# 
#     def __getattr__(self, name):
#         return get_key(self._scope,name)
# 
#     def __setattr__(self, name, value):
#         if name == '_scope':
#             super(settings,self).__setattr__(name,value)
#         else:
#             set_key(self._scope,name,value)
#             
#     def __str__(self):
#         s = _settings.get(self._scope,None)
#         return str(s)


import os
    import sass
from fabric.api import task
from management.shell import cat
from management.settings import settings

conf = settings(__package__,strip_leading=1)

try:
    sass = sass.compile
except Exception as e:
    sass=os.path.join(os.path.dirname(__file__),"sass.sh")

@task
def buildcss(target_dir=None):
    if target_dir is None:
        target_dir = conf.css_asset_dir
    css_stream = cat(conf.css_files)
    for s in conf.sass_files:

# Path: management/shell.py
# def cat(*args):
#     data = ""
#     for path in args:
#         if type(path) == list:
#             for p in path:
#                 if os.path.exists(p):
#                     data = data + open(p,'r').read()
#         elif os.path.exists(path):
#             data = data + open(path,'r').read()
#     return stream(data)
# 
# Path: management/settings.py
# class settings(object):
#     def __init__(self,package,strip_leading=0):
#         if strip_leading > 0:
#             self._scope = '.'.join(package.split('.')[strip_leading:])
#         else:
#             self._scope = package
# 
#     def default(self, keys):
#         update_default(self._scope,keys)
# 
#     def __getattr__(self, name):
#         return get_key(self._scope,name)
# 
#     def __setattr__(self, name, value):
#         if name == '_scope':
#             super(settings,self).__setattr__(name,value)
#         else:
#             set_key(self._scope,name,value)
#             
#     def __str__(self):
#         s = _settings.get(self._scope,None)
#         return str(s)


# Path: management/web/stylesheets.py
import os
    import sass
from fabric.api import task
from management.shell import cat
from management.settings import settings


conf = settings(__package__,strip_leading=1)

try:
    sass = sass.compile
except Exception as e:
    sass=os.path.join(os.path.dirname(__file__),"sass.sh")

@task
def buildcss(target_dir=None):
    if target_dir is None:
        target_dir = conf.css_asset_dir
    css_stream = cat(conf.css_files)
    for s in conf.sass_files:

        css_stream.append(cat(s).pipe(sass,cwd=os.path.dirname(s)))