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