Exemplo n.º 1
0
 def make_file(self, media_store, media_url, cache_root):
     """
     Creates a collection file and return its destination path and url
     """
     files = [os.path.join(cache_root, media_store[y]) for y in
         [x[len(media_url):] for x in self.media]
     ]
     
     out = StringIO()
     for f in files:
         fp = open(f, 'rb')
         out.write(fp.read())
         out.write('\n')
         fp.close()
     
     outurl = ('-%s' % files_checksum(*files)).join(
         os.path.splitext(self.path)
     )
     outfile = os.path.join(cache_root, outurl)
     
     fp = open(outfile, 'wb')
     fp.write(out.getvalue())
     fp.close()
     
     return outfile, outurl
Exemplo n.º 2
0
 def __media_version(self, path):
     media_path = path[len(self.__root)+1:]
     splited = os.path.splitext(media_path)
     version = files_checksum(path)
     return media_path, '%s-%s%s' % (splited[0], version, splited[1])