from django.conf import settings

from compressor.filters import CompilerFilter
from compressor.filters.css_default import CssAbsoluteFilter


class LessFilter(CompilerFilter):

    def __init__(self, content, attrs, **kwargs):
        super(LessFilter, self).__init__(content,
                                         command='{lessc} {infile} {outfile}',
                                         **kwargs)

    def input(self, **kwargs):
        if "{lessc}" in self.command:
            options = list(self.options)
            lessc_path = 'lessc'
            filename = self.filename.split('/')[-1]
            # for handling the migration to Bootstrap 3
            if filename not in [
                'hqstyle-core.less',
                'hqstyle-mobile-c2.less',
                'app_manager.less',
                'core.less',
            ]:
                lessc_path = settings.LESS_FOR_BOOTSTRAP_3_BINARY
            options.append(('lessc', lessc_path))
            self.options = tuple(options)

        content = super(LessFilter, self).input(**kwargs)
        # process absolute file paths
        return CssAbsoluteFilter(content).input(**kwargs)


@@ -512,16 +512,17 @@
 ptions)%0A
+%0A
         
@@ -529,333 +529,59 @@
     
-lessc_path = 'lessc'%0A            filename = self.filename.split('/')%5B-1%5D%0A            # for handling the migration to Bootstrap 3%0A            if filename not in %5B%0A                'hqstyle-core.less',%0A                'hqstyle-mobile-c2.less',%0A                'app_manager.less',%0A                'core.less',%0A            %5D:%0A    
+# interim use b3 lessc path until final switchover%0A
     
@@ -637,16 +637,28 @@
 3_BINARY
+ or 'lessc'%0A
 %0A       

update lessc precompilers to not use old less files (use interim lessc location for right now)