<s> from __future__ import print_function <EOL> import os , subprocess <EOL> from webassets . filter import Filter , register_filter <EOL> from webassets . exceptions import FilterError <EOL> class Jade ( Filter ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> max_debug_level = None <EOL> options = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> argv = [ ] <EOL> def setup ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( Jade , self ) . setup ( ) <EOL> self . argv = [ self . jade or '<STR_LIT>' ] <EOL> self . argv . append ( '<STR_LIT>' ) <EOL> if self . jade_no_debug : <EOL> self . argv . append ( '<STR_LIT>' ) <EOL> if not self . js_var : <EOL> self . js_var = '<STR_LIT>' <EOL> def input ( self , _in , out , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> proc = subprocess . Popen ( self . argv , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> shell = ( os . name == '<STR_LIT>' ) ) <EOL> stdout , stderr = proc . communicate ( _in . read ( ) ) <EOL> if proc . returncode != <NUM_LIT:0> : <EOL> raise FilterError ( ( '<STR_LIT>' + <EOL> '<STR_LIT>' ) <EOL> % ( proc . returncode , stdout , stderr ) ) <EOL> elif stderr : <EOL> print ( '<STR_LIT>' , stderr ) <EOL> key = os . path . splitext ( os . path . basename ( kwargs [ '<STR_LIT>' ] ) ) [ <NUM_LIT:0> ] <EOL> preamble = "<STR_LIT>" % ( self . js_var , key ) <EOL> out . write ( '<STR_LIT>' % ( preamble , stdout . strip ( ) ) ) <EOL> def output ( self , _in , out , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if self . jade_runtime : <EOL> with open ( self . jade_runtime ) as file : <EOL> runtime = '<STR_LIT>' . join ( file . readlines ( ) ) <EOL> else : <EOL> runtime = '<STR_LIT>' <EOL> init = "<STR_LIT>" % ( self . js_var , self . js_var ) <EOL> out . write ( '<STR_LIT>' % ( runtime , init , _in . read ( ) ) ) <EOL> register_filter ( Jade ) </s>
