示例#1
0
def inc_pathrnote(id):
    from copyright import text2html
    
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)
    
    html = text2html(path.rnote)
    return html
示例#2
0
def api_package_list():
    ScanPathes = get_model("scanpathes")
    pathes = ScanPathes.filter(ScanPathes.c.package_root==True).order_by(ScanPathes.c.path.asc())
    l = []
    for p in pathes:
        d = p.to_dict()
        d['csstag'] = crtype2csstag(d['crtype'])
        d['rnote'] = text2html(d['rnote'])
        l.append(d)
    return json(l)
示例#3
0
def crsnippet(pathid):
    import os
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(pathid)
    fp = os.path.join(settings.SCAN.DIR,path.path)
    snappet_txt = get_snappet(fp,path.cribegin,path.criend)
    snappet = text2html(tagcopyright(snappet_txt))
    return {
    "fpath":path.path,
    "snappet":snappet,
}
示例#4
0
def api_package_list():
    ScanPathes = get_model("scanpathes")
    pathes = ScanPathes.filter(ScanPathes.c.package_root == True).order_by(
        ScanPathes.c.path.asc())
    l = []
    for p in pathes:
        d = p.to_dict()
        d['csstag'] = crtype2csstag(d['crtype'])
        d['rnote'] = text2html(d['rnote'])
        l.append(d)
    return json(l)
示例#5
0
def crsnippet(pathid):
    import os
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(pathid)
    fp = os.path.join(settings.SCAN.DIR, path.path)
    snappet_txt = get_snappet(fp, path.cribegin, path.criend)
    snappet = text2html(tagcopyright(snappet_txt))
    return {
        "fpath": path.path,
        "snappet": snappet,
    }
示例#6
0
def inc_ftxt(id):
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)
    if path and path.type=='f':
        fp = os.path.join(settings.SCAN.DIR,path.path)
        f = open(fp)
        content = text2html(tagcopyright(f.read(1024)))
        b = f.read(1)
        if b!="":
            content += '<br/><a href="/file/%d">...<br/>click to show whole file</a>'%(id)
    else:
        content = ""
    return content
示例#7
0
def file(id):
    import os
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)
    assert(path.type=='f')
    fp = os.path.join(settings.SCAN.DIR,path.path)
    f = open(fp)
    content = text2html(tagcopyright(f.read()))
    f.close()
    return {
        'path':path,
        'fp':fp,
        'content':content,
    }
示例#8
0
def file(id):
    import os
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)
    assert (path.type == 'f')
    fp = os.path.join(settings.SCAN.DIR, path.path)
    f = open(fp)
    content = text2html(tagcopyright(f.read()))
    f.close()
    return {
        'path': path,
        'fp': fp,
        'content': content,
    }
示例#9
0
def inc_ftxt(id):
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)
    if path and path.type == 'f':
        fp = os.path.join(settings.SCAN.DIR, path.path)
        f = open(fp)
        content = text2html(tagcopyright(f.read(1024)))
        b = f.read(1)
        if b != "":
            content += '<br/><a href="/file/%d">...<br/>click to show whole file</a>' % (
                id)
    else:
        content = ""
    return content
示例#10
0
def inc_pathrnote(id):
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)

    html = text2html(path.rnote)
    return html
示例#11
0
def inc_pathrnote(id):
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)

    html = text2html(path.rnote)
    return html