# Path: staticassets/settings.py
# DEBUG = getattr(settings, 'STATICASSETS_DEBUG', settings.DEBUG)
# MIMETYPES = {
#     '.css': 'text/css',
#     '.js': 'application/javascript'
# }
# DIRS = getattr(settings, 'STATICASSETS_DIRS', getattr(settings, 'STATICFILES_DIRS'))
# CACHE_DIR = os.path.join(getattr(settings, 'STATIC_ROOT', '/tmp'), 'staticassets-cache')
# FINDER = getattr(settings, 'STATICASSETS_FINDER', 'staticassets.finder.AssetFinder')
# PREPROCESSORS = getattr(settings, 'STATICASSETS_PREPROCESSORS', (
#     ('application/javascript', 'staticassets.processors.DirectiveProcessor'),
#     ('text/css', 'staticassets.processors.DirectiveProcessor')
# ))
# POSTPROCESSORS = getattr(settings, 'STATICASSETS_POSTPROCESSORS', (
#     ('text/css', 'staticassets.processors.ResolvePathsProcessor'),
#     ('application/javascript', 'staticassets.processors.CommonjsProcessor'),
# ))
# BUNDLEPROCESSORS = getattr(settings, 'STATICASSETS_BUNDLEPROCESSORS', tuple())
# COMPILERS = {
#     '.sass': 'staticassets.compilers.Sass',
#     '.scss': 'staticassets.compilers.Sass',
#     '.styl': 'staticassets.compilers.Stylus',
#     '.less': 'staticassets.compilers.Less',
#     '.jst': 'staticassets.compilers.Jst',
#     '.ejs': 'staticassets.compilers.Ejs',
#     '.coffee': 'staticassets.compilers.CoffeeScript'
# }
# COMPRESSION = getattr(settings, 'STATICASSETS_COMPRESSION', not DEBUG)
# COMPRESSORS = {
#     'application/javascript': 'staticassets.compressors.UglifyJSCompressor',
#     'text/css': 'staticassets.compressors.YUICompressor'
# }
# AVAILABLE_EXTENSIONS = MIMETYPES.keys() + COMPILERS.keys()
# MANIFESTS = getattr(settings, 'STATICASSETS_MANIFESTS', tuple())
# EJS_TEMPLATE_SETTINGS = getattr(settings, 'STATICASSETS_EJS_TEMPLATE_SETTINGS', '{}')
# 
# Path: staticassets/filters.py
# class BaseFilter(object):
#     method = None
#     options = {}
# 
#     def __init__(self, *args, **kwargs):
#         for option, default in self.options.items():
#             setattr(self, option, kwargs[option] if option in kwargs else default)
#         self.options.update(**kwargs)
# 
#     def __call__(self, asset):
#         if not self.method:
#             raise Exception("'%s' filter must specify a method to execute" % self.__class__.__name__)
# 
#         method = getattr(self, self.method)
#         if method:
#             method(asset)
# 
# class CommandMixin(object):
#     command = None
#     params = []
# 
#     def get_args(self, asset):
#         command = self.options.get('command', self.command)
#         if isinstance(command, dict):
#             args = command.pop('args', [])
#             if not isinstance(args, (tuple, list)):
#                 args = args.split(' ')
#             return list(args) + self.options.get('params', self.params), command
#         return command.split(' ') + self.options.get('params', self.params), {}
# 
#     def run(self, asset):
#         args, kwargs = self.get_args(asset)
#         kwargs.update({
#             'shell': True,
#             'cwd': os.getcwd(),
#             'stdin': PIPE,
#             'stdout': PIPE,
#             'stderr': PIPE
#         })
#         process = Popen(' '.join(args), **kwargs)
#         output, errors = process.communicate(input=asset.content.encode('utf-8'))
#         if process.returncode != 0:
#             raise Exception("'%s'\n%s" % (' '.join(args), errors))
#         return output.decode('utf-8')
# 
# def get_filter(filter_conf):
#     if isinstance(filter_conf, (tuple, list)):
#         filter_conf = list(filter_conf)
#     else:
#         filter_conf = [filter_conf]
#     import_path = filter_conf.pop(0)
#     args, kwargs = get_arguments(filter_conf)
#     key = ','.join(args) + ','.join(['%s:%s' % (k, v) for k, v in kwargs.items()])
#     return get_cached_filter(import_path, key, args, kwargs)


from django.utils.functional import memoize
from staticassets import settings
from staticassets.filters import BaseFilter, CommandMixin, get_filter



_preprocessors = {}
_postprocessors = {}
_bundleprocessors = {}


class BaseProcessor(BaseFilter):
    method = 'process'


class CommandProcessor(BaseFilter, CommandMixin):
    def process(self, asset):
        asset.content = self.run(asset)


def pre(content_type):
    return get_preprocessors(content_type, settings.PREPROCESSORS)


def post(content_type):
    return get_postprocessors(content_type, settings.POSTPROCESSORS)


def bundle(content_type):
    processors = list(settings.BUNDLEPROCESSORS)

# Path: staticassets/settings.py
# DEBUG = getattr(settings, 'STATICASSETS_DEBUG', settings.DEBUG)
# MIMETYPES = {
#     '.css': 'text/css',
#     '.js': 'application/javascript'
# }
# DIRS = getattr(settings, 'STATICASSETS_DIRS', getattr(settings, 'STATICFILES_DIRS'))
# CACHE_DIR = os.path.join(getattr(settings, 'STATIC_ROOT', '/tmp'), 'staticassets-cache')
# FINDER = getattr(settings, 'STATICASSETS_FINDER', 'staticassets.finder.AssetFinder')
# PREPROCESSORS = getattr(settings, 'STATICASSETS_PREPROCESSORS', (
#     ('application/javascript', 'staticassets.processors.DirectiveProcessor'),
#     ('text/css', 'staticassets.processors.DirectiveProcessor')
# ))
# POSTPROCESSORS = getattr(settings, 'STATICASSETS_POSTPROCESSORS', (
#     ('text/css', 'staticassets.processors.ResolvePathsProcessor'),
#     ('application/javascript', 'staticassets.processors.CommonjsProcessor'),
# ))
# BUNDLEPROCESSORS = getattr(settings, 'STATICASSETS_BUNDLEPROCESSORS', tuple())
# COMPILERS = {
#     '.sass': 'staticassets.compilers.Sass',
#     '.scss': 'staticassets.compilers.Sass',
#     '.styl': 'staticassets.compilers.Stylus',
#     '.less': 'staticassets.compilers.Less',
#     '.jst': 'staticassets.compilers.Jst',
#     '.ejs': 'staticassets.compilers.Ejs',
#     '.coffee': 'staticassets.compilers.CoffeeScript'
# }
# COMPRESSION = getattr(settings, 'STATICASSETS_COMPRESSION', not DEBUG)
# COMPRESSORS = {
#     'application/javascript': 'staticassets.compressors.UglifyJSCompressor',
#     'text/css': 'staticassets.compressors.YUICompressor'
# }
# AVAILABLE_EXTENSIONS = MIMETYPES.keys() + COMPILERS.keys()
# MANIFESTS = getattr(settings, 'STATICASSETS_MANIFESTS', tuple())
# EJS_TEMPLATE_SETTINGS = getattr(settings, 'STATICASSETS_EJS_TEMPLATE_SETTINGS', '{}')
# 
# Path: staticassets/filters.py
# class BaseFilter(object):
#     method = None
#     options = {}
# 
#     def __init__(self, *args, **kwargs):
#         for option, default in self.options.items():
#             setattr(self, option, kwargs[option] if option in kwargs else default)
#         self.options.update(**kwargs)
# 
#     def __call__(self, asset):
#         if not self.method:
#             raise Exception("'%s' filter must specify a method to execute" % self.__class__.__name__)
# 
#         method = getattr(self, self.method)
#         if method:
#             method(asset)
# 
# class CommandMixin(object):
#     command = None
#     params = []
# 
#     def get_args(self, asset):
#         command = self.options.get('command', self.command)
#         if isinstance(command, dict):
#             args = command.pop('args', [])
#             if not isinstance(args, (tuple, list)):
#                 args = args.split(' ')
#             return list(args) + self.options.get('params', self.params), command
#         return command.split(' ') + self.options.get('params', self.params), {}
# 
#     def run(self, asset):
#         args, kwargs = self.get_args(asset)
#         kwargs.update({
#             'shell': True,
#             'cwd': os.getcwd(),
#             'stdin': PIPE,
#             'stdout': PIPE,
#             'stderr': PIPE
#         })
#         process = Popen(' '.join(args), **kwargs)
#         output, errors = process.communicate(input=asset.content.encode('utf-8'))
#         if process.returncode != 0:
#             raise Exception("'%s'\n%s" % (' '.join(args), errors))
#         return output.decode('utf-8')
# 
# def get_filter(filter_conf):
#     if isinstance(filter_conf, (tuple, list)):
#         filter_conf = list(filter_conf)
#     else:
#         filter_conf = [filter_conf]
#     import_path = filter_conf.pop(0)
#     args, kwargs = get_arguments(filter_conf)
#     key = ','.join(args) + ','.join(['%s:%s' % (k, v) for k, v in kwargs.items()])
#     return get_cached_filter(import_path, key, args, kwargs)


# Path: staticassets/processors/base.py
from django.utils.functional import memoize
from staticassets import settings
from staticassets.filters import BaseFilter, CommandMixin, get_filter




_preprocessors = {}
_postprocessors = {}
_bundleprocessors = {}


class BaseProcessor(BaseFilter):
    method = 'process'


class CommandProcessor(BaseFilter, CommandMixin):
    def process(self, asset):
        asset.content = self.run(asset)


def pre(content_type):
    return get_preprocessors(content_type, settings.PREPROCESSORS)


def post(content_type):
    return get_postprocessors(content_type, settings.POSTPROCESSORS)


def bundle(content_type):
    processors = list(settings.BUNDLEPROCESSORS)

    if settings.COMPRESSION: