Ejemplo n.º 1
0
def bracket_link(link):
    m = re.search(r"^/(thread)/([^/]+)/([0-9a-f]{8})$", link)
    if m is not None:
        title = md5.new(file_encode(m.group(1), m.group(2))).hexdigest()
        id = m.group(3)
        uri = '/%s/%s.html' % (title, id)
        return '<a href="' + uri + '">[[' + link + ']]</a>'

    m = re.search(r"^/(thread)/([^/]+)$", link)
    if m is not None:
        title = md5.new(file_encode(m.group(1), m.group(2))).hexdigest()
        uri = '/%s/' % title
        return '<a href="' + uri + '">[[' + link + ']]</a>'

    m = re.search(r"^([^/]+)/([0-9a-f]{8})$", link)
    if m is not None:
        title = md5.new(file_encode('thread', m.group(1))).hexdigest()
        id = m.group(2)
        uri = '/%s/%s.html' % (title, id)
        return '<a href="' + uri + '">[[' + link + ']]</a>'

    m = re.search(r"^([^/]+)$", link)
    if m is not None:
        title = md5.new(file_encode('thread', m.group(1))).hexdigest()
        uri = '/%s/' % title
        return '<a href="' + uri + '">[[' + link + ']]</a>'

    return "[[" + link + "]]"
Ejemplo n.º 2
0
def bracket_link(link):
    m = re.search(r"^/(thread)/([^/]+)/([0-9a-f]{8})$", link)
    if m is not None:
        title = md5.new(file_encode(m.group(1), m.group(2))).hexdigest()
        id = m.group(3)
        uri = '/%s/%s.html' % (title, id)
        return '<a href="' + uri + '">[[' + link + ']]</a>'

    m = re.search(r"^/(thread)/([^/]+)$", link)
    if m is not None:
        title = md5.new(file_encode(m.group(1), m.group(2))).hexdigest()
        uri = '/%s/' % title
        return '<a href="' + uri + '">[[' + link + ']]</a>'

    m = re.search(r"^([^/]+)/([0-9a-f]{8})$", link)
    if m is not None:
        title = md5.new(file_encode('thread', m.group(1))).hexdigest()
        id = m.group(2)
        uri = '/%s/%s.html' % (title, id)
        return '<a href="' + uri + '">[[' + link + ']]</a>'

    m = re.search(r"^([^/]+)$", link)
    if m is not None:
        title = md5.new(file_encode('thread', m.group(1))).hexdigest()
        uri = '/%s/' % title
        return '<a href="' + uri + '">[[' + link + ']]</a>'

    return "[[" + link + "]]"
Ejemplo n.º 3
0
def copy_attach(cache):
    title = md5.new(cache.datfile).hexdigest()
    srcdir = os.path.join(shingetsu.config.cache_dir, cache.datfile)
    srcdir = os.path.join(srcdir, 'attach')
    dstdir = os.path.join(archive_dir, title)
    if not os.path.isdir(dstdir):
        os.makedirs(dstdir)
    for f in os.listdir(srcdir):
        m = re.search(r'([0-9]+)_([0-9a-f]{32})\.(.*)', f)
        stamp, id, suffix = m.groups()
        stamp = int(stamp)
        srcfile = os.path.join(srcdir, f)
        dstfile = os.path.join(dstdir, '%sx.%s' % (id[:8], suffix))
        if not os.path.exists(dstfile):
            copy(srcfile, dstfile)
            os.utime(dstfile, (stamp, stamp))
Ejemplo n.º 4
0
def copy_attach(cache):
    title = md5.new(cache.datfile).hexdigest()
    srcdir = os.path.join(shingetsu.config.cache_dir, cache.datfile)
    srcdir = os.path.join(srcdir, 'attach')
    dstdir = os.path.join(archive_dir, title)
    if not os.path.isdir(dstdir):
        os.makedirs(dstdir)
    for f in os.listdir(srcdir):
        m = re.search(r'([0-9]+)_([0-9a-f]{32})\.(.*)', f)
        stamp, id, suffix = m.groups()
        stamp = int(stamp)
        srcfile = os.path.join(srcdir, f)
        dstfile = os.path.join(dstdir, '%sx.%s' % (id[:8], suffix))
        if not os.path.exists(dstfile):
            copy(srcfile, dstfile)
            os.utime(dstfile, (stamp, stamp))
Ejemplo n.º 5
0
def make_html(cache):
    title = md5.new(cache.datfile).hexdigest()
    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 = file(dstfile, 'wb')
            write_html(f, rec)
            f.close()
            os.utime(dstfile, (rec.stamp, rec.stamp))
            rec.free()
            count += 1
    return count
Ejemplo n.º 6
0
def make_html(cache):
    title = md5.new(cache.datfile).hexdigest()
    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 = file(dstfile, 'wb')
            write_html(f, rec)
            f.close()
            os.utime(dstfile, (rec.stamp, rec.stamp))
            rec.free()
            count += 1
    return count