def _getCacheFileName(self): """Base this on the directories...same set of directories should give same cache""" hash = md5.md5(''.join(self._dirs)).hexdigest() from reportlab.lib.utils import get_rl_tempfile fn = get_rl_tempfile('fonts_%s.dat' % hash) return fn
def _getCacheFileName(self): """Base this on the directories...same set of directories should give same cache""" hash = md5(''.join(self._dirs)).hexdigest() from reportlab.lib.utils import get_rl_tempfile fn = get_rl_tempfile('fonts_%s.dat' % hash) return fn
def expandTGZ(tgzName,tarName=None): '''Expands tgz archives Warning this only handles regular files''' import tarfile, gzip if not tarName: from reportlab.lib.utils import get_rl_tempfile tarName = get_rl_tempfile() g = gzip.GzipFile(tgzName) t = open(tarName, 'wb') while 1: data = g.read(1024) if not data: break t.write(data) g.close() t.close() t = tarfile.TarFile(tarName) m = t.getmembers() for d in filter(lambda x, t=tarfile.REGTYPE: x.type==t, m): n = d.name.split('/') if n[0]=='.': del n[0] if len(n)>1: dn = os.sep.join(n[:-1]) if not isDir(dn): os.makedirs(dn) open(os.sep.join(n),'wb').write(t.readstr(d)) t.close() remove(tarName)
def _getCacheFileName(self): """Base this on the directories...same set of directories should give same cache""" fsEncoding = self._fsEncoding hash = md5(b''.join(asBytes(_,enc=fsEncoding) for _ in sorted(self._dirs))).hexdigest() from reportlab.lib.utils import get_rl_tempfile fn = get_rl_tempfile('fonts_%s.dat' % hash) return fn
def _getCacheFileName(self): """Base this on the directories...same set of directories should give same cache""" fsEncoding = self._fsEncoding hash = md5(b''.join( asBytes(_, enc=fsEncoding) for _ in sorted(self._dirs))).hexdigest() from reportlab.lib.utils import get_rl_tempfile fn = get_rl_tempfile('fonts_%s.dat' % hash) return fn
def makeTGZ(tgzName, archDir,AFL=(),tarName=None): #AR the tar module I found is Python 2.2 only and chokes #when gzipping; had to handle that myself AFL = AFL or listAllFiles(archDir,rel=0) from rlextra.utils import tarfile if not tarName: from reportlab.lib.utils import get_rl_tempfile tarName = get_rl_tempfile() arch = tarfile.TarFileCompat(tarName, 'w', compression=tarfile.TAR_PLAIN) for fn in AFL: arch.write(fn) arch.close() import gzip if tgzName[:-4]!='.tgz': tgzName = tgzName + '.tgz' remove(tgzName) g = gzip.GzipFile(tgzName, 'wb', 9) f = open(tarName, 'rb') while 1: chunk = f.read(1024) if not chunk: break g.write(chunk) g.close() f.close() remove(tarName)