def globcat(src, dst): f = opentext(dst, 'w') files = glob(src) files.sort() for i in files: f.write(opentext(i).read()) f.close()
def check_date(date, filename): rssdate = os.path.join(docroot, filename) try: olddate = opentext(rssdate).read().strip() except IOError: olddate = "" if date and date == olddate: sys.exit() else: opentext(rssdate, 'w').write(date)
def save(self): try: with util.opentext(self.file, 'w') as f: for stamp, filekey in self.datkey2filekey.items(): f.write(str(stamp) + '<>' + filekey + '\n') except IOError: utils.log('keylib._DatkeyTable.save fails')
def save(self): try: with util.opentext(self.file, 'w') as f: for stamp, filekey in self.datkey2filekey.items(): f.write(str(stamp) + '<>' + filekey + '\n') except OSError: utils.log('keylib._DatkeyTable.save fails')
def make_sitemap(): f = opentext(os.path.join(archive_dir, 'sitemap.txt'), 'w') f.write('%s\n' % archive_uri) for d in os.listdir(archive_dir): if (len(d) != 32) or \ (not os.path.isdir(os.path.join(archive_dir, d))): continue for html in os.listdir(os.path.join(archive_dir, d)): if (len(html) != 8 + 5) or (not html.endswith('.html')): continue f.write('%s%s/%s\n' % (archive_uri, d, html))
def make_sitemap(): f = opentext(os.path.join(archive_dir, 'sitemap.txt'), 'w') f.write('%s\n' % archive_uri) for d in os.listdir(archive_dir): if (len(d) != 32) or \ (not os.path.isdir(os.path.join(archive_dir, d))): continue for html in os.listdir(os.path.join(archive_dir, d)): if (len(html) != 8+5) or (not html.endswith('.html')): continue f.write('%s%s/%s\n' % (archive_uri, d, html))
def load(self): try: with util.opentext(self.file, 'r') as f: for line in f: try: # format -> `12345<>thread_FFFF\n` stamp, filekey = line.strip().split('<>', 1) stamp = int(stamp) except ValueError: continue self.set_entry(stamp, filekey) except IOError: pass
def load(self): try: with util.opentext(self.file, 'r') as f: for line in f: try: # format -> `12345<>thread_FFFF\n` stamp, filekey = line.strip().split('<>', 1) stamp = int(stamp) except ValueError: continue self.set_entry(stamp, filekey) except OSError: pass
def make_html(cache): title = md5digest(cache.datfile) dstdir = os.path.join(archive_dir, title) if not os.path.isdir(dstdir): os.makedirs(dstdir) count = 0 for rec in cache: sid = rec.id[:8] dstfile = '%s/%s/%s.html' % (archive_dir, title, sid) if not os.path.exists(dstfile): rec.load_body() f = opentext(dstfile, 'w') write_html(f, rec) f.close() os.utime(dstfile, (rec.stamp, rec.stamp)) rec.free() count += 1 return count
def write_sitemap(): f = opentext(os.path.join(docroot, 'sitemap.txt'), 'w') for i in get_links(): f.write(i + "\n") f.close()