Beispiel #1
0
def inc_pathrnote(id):
    from copyright import text2html
    
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)
    
    html = text2html(path.rnote)
    return html
Beispiel #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)
Beispiel #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,
}
Beispiel #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)
Beispiel #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,
    }
Beispiel #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
Beispiel #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,
    }
Beispiel #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,
    }
Beispiel #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
Beispiel #10
0
def inc_pathrnote(id):
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)

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

    html = text2html(path.rnote)
    return html