def flatten_style_sheet_contents(filenames): out = StringIO.StringIO() load_sequence = calcdeps.calc_load_sequence(filenames) # Stylesheets should be sourced from topmsot in, not inner-out. load_sequence.reverse() for module in load_sequence: for style_sheet in module.style_sheets: out.write(style_sheet.contents) if style_sheet.contents[-1] != '\n': out.write('\n') return out.getvalue()
def flatten_module_contents(filenames): out = StringIO.StringIO() load_sequence = calcdeps.calc_load_sequence(filenames) flattened_module_names = ["'%s'" % module.name for module in load_sequence] out.write(" if (!window.FLATTENED) window.FLATTENED = {};\n") for module in load_sequence: out.write(" window.FLATTENED['%s'] = true;\n" % module.name); for module in load_sequence: out.write(module.contents) if module.contents[-1] != '\n': out.write('\n') return out.getvalue()