Exemplo n.º 1
0
 def process(self, stream):
     datas = []
     ball = FileMeta(self.filename, os.curdir)
     for item in stream:
         datas.append(item.data.read())
     ball.data = FileDataBlob(self.joinstr.join(datas))
     return [ball]
Exemplo n.º 2
0
    def process(self, stream):
        if self.maps:
            maps = []
            js_files = []
            coffee = []
            with tempd() as tmp:
                for item in stream:
                    fullpath = os.path.join(tmp, item.filename)
                    root, filename = os.path.split(fullpath)

                    cmd = ['coffee', '-c', '-m', filename]
                    item.data.as_file(fullpath)
                    run_cmd(cmd, cwd=root)

                    coffee.append(item)

                    js_item = FileMeta(item.filename, item.path)
                    js_item.setext('.js')
                    with open(os.path.join(tmp, js_item.filename), 'r') as ifile:
                        js_item.data = FileDataBlob(ifile.read())
                    js_files.append(js_item)

                    mapfile = FileMeta(item.filename, item.path)
                    mapfile.setext('.map')
                    with open(os.path.join(tmp, mapfile.filename), 'r') as ifile:
                        mapfile.data = FileDataBlob(ifile.read())
                    maps.append(mapfile)
            return {
                'default': js_files,
                'map': maps,
                'coffee': coffee,
            }
        else:
            ret = []
            cmd = ['coffee', '-p', '-s']
            for item in stream:
                item.data = FileDataBlob(run_cmd(cmd, item.data.read()))
                item.setext('.js')
                ret.append(item)
            return ret