def write_out(self): try: lib_dirs = get_source_dirs(self.dirs) if self.lib_dirs: lib_dirs += self.lib_dirs lib_dirs = distinct(lib_dirs) compiler = SassCompiler(lib_dirs=lib_dirs) for sf in self.source_files: #print "Reading %s" % os.path.abspath(sf) compiler.read_sass_file(sf) normal_output = compiler.get_css() if 'normal' in self.outfiles: normal_out_filename = os.path.abspath(self.outfiles['normal']) print "Writing %s" % normal_out_filename with open(normal_out_filename, 'w') as of: of.write(normal_output) if 'minified' in self.outfiles: minified_out_filename = os.path.abspath(self.outfiles['minified']) print "Writing %s" % minified_out_filename with open(minified_out_filename, 'w') as of: of.write(minify(normal_output)) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback)
def build(sass): compiler = SassCompiler(lib_dirs=args.lib_dirs) compiler.read_string(sass) if args.scss: return compiler.get_scss() else: return compiler.get_css()
def process_task(self, taskname, extensions=".sass,.scss"): task = self[taskname] head_includes, tail_includes = None, None dirs = [] files = [] for s in task.sources: if os.path.isfile(s): files.append(s) else: dirs.append(s) lib_dirs = get_source_dirs(dirs) if lib_dirs: lib_dirs += lib_dirs lib_dirs = distinct(lib_dirs) source_files = get_source_files(dirs, extensions=extensions) if files: source_files += files compiler = SassCompiler(lib_dirs=lib_dirs, head_includes=task.include.head, tail_includes=task.include.tail) for sf in source_files: #print "Reading %s" % os.path.abspath(sf) if sf.endswith('.scss'): compiler.read_scss_file(sf) else: compiler.read_sass_file(sf) normal_output = compiler.get_css() if isinstance(task.output, basestring): task.output = {'normal': task.output} if 'normal' in task.output: normal_out_filename = os.path.abspath(task.output['normal']) print "Writing %s" % normal_out_filename with open(normal_out_filename, 'w') as of: of.write(normal_output) if 'minified' in task.output: minified_out_filename = os.path.abspath(task.output['minified']) print "Writing %s" % minified_out_filename with open(minified_out_filename, 'w') as of: of.write(minify(normal_output))