custom/processors.py @ 1f29d302c82d

Add node_modules to .hgignore.
author Steve Losh <steve@stevelosh.com>
date Sun, 28 Feb 2016 11:52:32 +0000
parents 1ddb600eeb22
children (none)
import os
import sys
from django.conf import settings
from hydeengine.file_system import File
from subprocess import check_output, CalledProcessError

class Wisp:
    @staticmethod
    def process(resource):
        wisp = settings.WISP_PATH
        if not wisp or not os.path.exists(wisp):
            raise ValueError("Wisp cannot be found at [%s]" % wisp)

        try:
            data = check_output([wisp, "-c", resource.source_file.path]).decode('utf-8')
        except CalledProcessError, e:
            print 'Syntax Error when calling Wisp:', e
            return None

        out_file = File(resource.source_file.path_without_extension + ".js")
        resource.source_file = out_file
        resource.source_file.write(data)