#!/usr/bin/python
#encoding=utf-8
import sys,os
import ConfigParser
import commands
import time
import codecs
htmlMap = {}
def processHtml(filename):
f = open(filename,"r")
if f is None:
raise Exception('open %s error!' % (filename))
newName = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1]) + os.sep + "core" + os.sep + "data"+os.sep+os.path.basename(filename) + "." + str(time.time())
#print newName
tmp = ""
flag=False
orig_num = 0
new_num = 0
for ln in f:
orig_num += 1
if ln.find("<script type=\"text/javascript\">") != -1 and ln.find("</script>") == -1:
flag=True
continue
if ln.find("<script type=\"text/javascript\">") != -1 and ln.find("</script>") != -1:
flag=False
continue
if ln.find("<script>") != -1 and ln.find("</script>") == -1:
flag=True
continue
if ln.find("<script>") != -1 and ln.find("</script>") != -1:
flag=False
continue
if ln.find("</script>") != -1:
flag=False
continue
if flag == True:
tmp += ln
new_num += 1
htmlMap[filename+os.sep+str(orig_num)]=newName + os.sep + str(new_num)
if tmp == "":
print ('[WARNING]file %s not contain js code' % (filename))
return ""
outfile = open(newName,"w")
if outfile is None:
raise Exception('open %s error!' % (newName))
outfile.write(tmp)
#print htmlMap
return newName
def clearTmpFiles():
dels=[]
for key in htmlMap.keys():
fn = os.sep.join(htmlMap[key].split(os.sep)[:-1])
if not fn in dels:
dels.append(fn)
#print dels
for item in dels:
os.remove(item)
def isHiddenFile(path):
itms = path.split(os.sep)
for itm in itms:
if itm != "" and itm != "." and itm != ".." and itm[0]==".":
return True
return False
'''
@input
a file (or a top dir) to be checked
@process
recuresively read all the files of a dir.only support .html and .js.
if it is a html file then we only check the code between <script></script>
if it is a js file then we check all the code
@return
file(or folder) to be checked
'''
def getFiles(paths):
#print paths
ret = []
omitpath = os.path.dirname(__file__) + os.sep + "conf" + os.sep + "omitfiles.conf"
for path in paths:
path = path.rstrip(os.sep)
if not os.path.isdir(path):
omitfiles = getOmitedFiles(omitpath,os.sep.join(path.split(os.sep)[:-1])+os.sep)
if (os.path.getsize(path)==0) or (path in omitfiles):
continue
if path.find(".js") != -1 and isHiddenFile(path)==False:
ret.append(path)
elif path.find(".html") != -1 and isHiddenFile(path)==False:
np = processHtml(path)
if np != "":
ret.append(np)
else:
omitfiles = getOmitedFiles(omitpath,path)
for root, dirs, files in os.walk(path):
for f in files:
if (os.path.getsize(root + os.sep + f)==0) or ((root + os.sep + f) in omitfiles):
continue
if f.find(".js") != -1 and isHiddenFile(root + os.sep + f) == False:
ret.append(root + os.sep + f)
elif f.find(".html") != -1 and isHiddenFile(root + os.sep + f) == False:
np=processHtml(root + os.sep + f)
if np != "":
ret.append(np)
else:
continue
return ret
def getopt(path):
_opt=[]
_predef=[]
conf = ConfigParser.ConfigParser()
conf.read(path)
for item in conf.options('option'):
_opt.append("%s=%s"%(item,conf.get('option',item)))
for item in conf.options('predef'):
_predef.append("%s=%s"%(item,conf.get('predef',item)))
return "%s %s"%(",".join(_opt),",".join(_predef))
def getBlackList(path):
lst={}
conf = ConfigParser.ConfigParser()
conf.read(path)
for item in conf.options('level'):
lst[item]=conf.get('level',item)
return lst
def printReport(rptstr):
if rptstr=="":
return
array = rptstr.split('\n')
for ln in array:
items = ln.split("***")
if items[1].find("Stopping") != -1:
print items[1]
else:
print "文件:%s\t错误原因:%s\t错误位置:第%s行\t错误语句:%s"%(items[0],items[1],items[2],items[4])
def processItem(item,blacklst,hp):
itm = item
for key in hp.keys():
if item[0]+os.sep+item[2] == hp[key]:
itm[0]=os.sep.join(key.split(os.sep)[:-1])
itm[2]=key.split(os.sep)[-1]
#print "====",itm,"======"
itm.append("error")
for err in blacklst.keys():
if itm[1].lower().find(err.lower())!=-1:
itm[5] = blacklst[err]
break
return itm
'''
parse jshint output
'''
def splitOutput(rptstr,blacklist,mp):
if rptstr=="":
return
array = rptstr.split('\n')
lst=[]
parsecnt = 0;
parsetotal=len(array)
for ln in array:
#print ln
if ln.find("***") == -1:
continue
items = processItem(ln.split("***"),blacklist,mp)
if items[1].find("Stopping") != -1:
print items[1]
else:
lst.append(items)
parsecnt = parsecnt + 1
return (lst,parsecnt,parsetotal)
'''
get the table body according to the result-list
'''
def getBody(lst):
files={}
error=0
warning=0
ignore=0;
count=0
for item in lst:
count = count + 1
if len(item)<6:
continue
if not files.has_key(item[0]):
if item[5] == "ignore":
ignore = ignore + 1
elif item[5] == "error":
error = error + 1
files[item[0]] = getLine(item,count)
else:
files[item[0]] = getLine(item,count)
warning = warning + 1
else:
if item[5] == "ignore":
ignore = ignore + 1
elif item[5] == "error":
error = error + 1
files[item[0]] = files[item[0]] + getLine(item,count)
else:
files[item[0]] = files[item[0]] + getLine(item,count)
warning = warning + 1
return (files,ignore,warning,error)
def generateHtml(rptstr,outfile,blacklst,mp):
print "start parsing jshint output..."
(lst,parsecnt,parsetotal) = splitOutput(rptstr,blacklst,mp)
print "prepare main tpl..."
tpl=""
tplPath=os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1])+os.sep+"core"+os.sep+"tpl"+os.sep+"toggle_tpl.html"
if not os.path.exists(tplPath):
raise Exception('%s file does not exists!'%(tplPath))
f=open(tplPath,"r")
if f is None:
raise Exception('open %s error!' % (tplPath))
for ln in f:
tpl+=ln
strStartTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
tpl=tpl.replace("{$pnumber}",str(len(lst)))
tpl=tpl.replace("{$timeData}",strStartTime)
f.close()
print "blacklist filtering..."
(files,ignore,warning,error) = getBody(lst)
tpl=tpl.replace("{$ignumber}","%s(%5.1f%%)"%(str(ignore),(float(ignore)/len(lst)*100)))
tpl=tpl.replace("{$errnumber}","%s(%5.1f%%)"%(str(error),(float(error)/len(lst)*100)))
tpl=tpl.replace("{$warnumber}","%s(%5.1f%%)"%(str(warning),(float(warning)/len(lst)*100)))
print "prepare body"
bodys=""
for key in files:
tblPath=os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1])+os.sep+"core"+os.sep+"tpl"+os.sep+"htmlpart.html"
if not os.path.exists(tblPath):
raise Exception('%s file does not exists!'%(tblPath))
f=open(tblPath,"r")
body=''''''
for ln in f:
body += ln
body = body.replace("{$title}",key)
body = body.replace("{$fname}",key)
f.close()
body = body.replace("[---to be replaced 2---]",files[key])
bodys = bodys + body
if bodys=="":
#raise Exception('no report generated')
bodys = "no informatin maybe they are filtered"
tpl=tpl.replace("[---to be replace 1---]",bodys)
ts=str(int(time.time()))
resf=open(outfile,"w")
if resf is None:
raise Exception('open %s error!' % (outfile))
resf.write(tpl)
resf.close()
print "generate html file %s OK!"%(outfile)
return ts
def getLine(item,no):
#print item
text = '''<tr><td width='10%%'>%s</td><td width='10%%'>%s</td><td width='20%%'>%s</td><td width='10%%'>%s</td><td width='50%%'>%s</td></tr>'''%(str(no),item[5],item[1],item[2],item[4].replace("<","<").replace(">",">"))
return text
def genReport(status,output,blackpath,outfile,htmlMap):
#if status == 0:
# print "[WARNING][NO ERROR DETECTED BY JSHUNTER]"
#else:
if output.find("open file") != -1:
raise Exception("File Not Found Error!")
print "[ERROR DETECTED BY JSHUNTER]"
blacklist = getBlackList(blackpath)
ts = generateHtml(output,outfile,blacklist,htmlMap)
return ts
def checkJavaExist():
cmd="java"
(status,output) = commands.getstatusoutput(cmd)
if status
没有合适的资源?快使用搜索试试~ 我知道了~
vue+ element ui 后台管理系统前端框架.zip
共855个文件
js:441个
png:90个
html:60个
需积分: 0 1 下载量 61 浏览量
2024-03-03
17:17:04
上传
评论
收藏 10.34MB ZIP 举报
温馨提示
vue+ element ui 后台管理系统前端框架.zip
资源推荐
资源详情
资源评论
收起资源包目录
vue+ element ui 后台管理系统前端框架.zip (855个子文件)
controller.ashx 3KB
getContent.ashx 1KB
ASPJson.class.asp 9KB
Uploader.Class.asp 6KB
MultiformProcessor.class.asp 4KB
PathFormatter.class.asp 3KB
action_list.asp 2KB
controller.asp 1KB
action_upload.asp 896B
action_crawler.asp 828B
config_loader.asp 543B
getContent.asp 420B
action_config.asp 161B
.babelrc 230B
cov.bat 70B
check.cfg 4KB
omitfiles.conf 185B
custcheck.conf 10B
Web.config 453B
UploadHandler.cs 5KB
CrawlerHandler.cs 3KB
ListFileHandler.cs 3KB
PathFormater.cs 2KB
Handler.cs 1KB
Config.cs 1KB
NotSupportedHandler.cs 455B
ConfigHandler.cs 332B
video-js.css 21KB
image.css 18KB
video.css 15KB
attachment.css 14KB
video-js.min.css 11KB
buttonicon.css 9KB
shCoreDefault.css 7KB
dialog.css 6KB
jscoverage.css 6KB
jscoverage.css 6KB
editor.css 4KB
qunit.css 4KB
qunit.css 4KB
scrawl.css 4KB
testsuite.css 3KB
codemirror.css 3KB
splitbutton.css 3KB
charts.css 3KB
colorpicker.css 2KB
tangramtest.css 2KB
background.css 2KB
uibase.css 2KB
pastepicker.css 2KB
jscoverage-ie.css 2KB
jscoverage-ie.css 2KB
emotion.css 2KB
dialogbase.css 2KB
music.css 2KB
combox.css 2KB
ueditor.css 2KB
popup.css 2KB
menubutton.css 2KB
message.css 1KB
cellalignpicker.css 1KB
button.css 1KB
edittable.css 1KB
jscoverage-highlight.css 1KB
jscoverage-highlight.css 1KB
paragraphpicker.css 1KB
template.css 1KB
tablepicker.css 1006B
menu.css 972B
multiMenu.css 656B
contextmenu.css 621B
webuploader.css 515B
autotypesetpicker.css 479B
toolbar.css 446B
index.css 392B
help.css 389B
separtor.css 230B
colorbutton.css 195B
shortcutmenu.css 188B
DEFAULT.css 152B
iframe.css 41B
npPlugintest.dll 1.12MB
.editorconfig 275B
.editorconfig 147B
vjs.eot 3KB
jscoverage.exe 1.04MB
UEditorSnapscreen.exe 508KB
wface.gif 49KB
jxface2.gif 40KB
yface.gif 28KB
bface.gif 27KB
icons.gif 20KB
file-icons.gif 20KB
file-icons.gif 20KB
tface.gif 19KB
fface.gif 18KB
cface.gif 8KB
icons-all.gif 4KB
videologo.gif 2KB
bg_button_span.gif 1KB
共 855 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
日刷百题
- 粉丝: 5365
- 资源: 951
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Pytorch-pytorch深度学习教程之逻辑回归.zip
- Pytorch-pytorch深度学习教程之双向循环网络.zip
- Pytorch-pytorch深度学习教程之卷积神经网络.zip
- Pytorch-pytorch深度学习教程之前馈神经网络.zip
- Pytorch-pytorch深度学习教程之线性回归.zip
- Pytorch-pytorch深度学习教程之基本操作.zip
- 基于QT的地图可视化桌面系统后台数据库为MySQL5.7源码.zip
- 基于simulink的PLL锁相环系统仿真【包括模型,文档,参考文献,操作步骤】
- 基于EM-GMM模型的目标跟踪和异常行为检测matlab仿真【包括程序,注释,参考文献,操作步骤,说明文档】
- 2109010044_胡晨燕_选课管理数据库设计与实现.prj
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功