Example #1
0
def globcat(src, dst):
    f = opentext(dst, 'w')
    files = glob(src)
    files.sort()
    for i in files:
        f.write(opentext(i).read())
    f.close()
Example #2
0
def globcat(src, dst):
    f = opentext(dst, 'w')
    files = glob(src)
    files.sort()
    for i in files:
        f.write(opentext(i).read())
    f.close()
Example #3
0
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)
Example #4
0
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)
Example #5
0
    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')
Example #6
0
    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')
Example #7
0
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))
Example #8
0
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))
Example #9
0
    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
Example #10
0
    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
Example #11
0
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
Example #12
0
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
Example #13
0
def write_sitemap():
    f = opentext(os.path.join(docroot, 'sitemap.txt'), 'w')
    for i in get_links():
        f.write(i + "\n")
    f.close()
Example #14
0
def write_sitemap():
    f = opentext(os.path.join(docroot, 'sitemap.txt'), 'w')
    for i in get_links():
        f.write(i + "\n")
    f.close()