[IMP] base_module_quality: styles on different tests
bzr revid: mra@tinyerp.com-20090929122027-8e01uw61dwax00h3
This commit is contained in:
parent
6898b2230a
commit
34645503b7
|
@ -161,6 +161,38 @@ class abstract_quality_check(object):
|
|||
def add_quatation(self, x_no, y_no):
|
||||
return x_no/y_no
|
||||
|
||||
def get_style(self):
|
||||
# This function return style tag with specified styles for html pages
|
||||
style = '''
|
||||
<style>
|
||||
.divstyle {
|
||||
border:1px solid #aaaaaa;
|
||||
background-color:#f9f9f9;
|
||||
padding:5px;
|
||||
}
|
||||
.tablestyle
|
||||
{
|
||||
border:1px dashed gray;
|
||||
}
|
||||
.tdatastyle
|
||||
{
|
||||
border:0.5px solid gray;
|
||||
}
|
||||
.head
|
||||
{
|
||||
color: black;
|
||||
background: none;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
padding-top: .5em;
|
||||
padding-bottom: .17em;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
}
|
||||
</style> '''
|
||||
return style
|
||||
|
||||
|
||||
class module_quality_check(osv.osv):
|
||||
_name = 'module.quality.check'
|
||||
_columns = {
|
||||
|
|
|
@ -40,7 +40,6 @@ Test checks for fields, views, security rules, dependancy level
|
|||
return None
|
||||
|
||||
def run_test(self, cr, uid, module_path):
|
||||
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
module_name = module_path.split('/')[-1]
|
||||
obj_list = self.get_objects(cr, uid, module_name)
|
||||
|
@ -184,24 +183,9 @@ Test checks for fields, views, security rules, dependancy level
|
|||
def get_result_details(self, dict_obj):
|
||||
res = ""
|
||||
if dict_obj != {}:
|
||||
str_html = '''<html><strong> Fields Result</strong><head>
|
||||
<style>
|
||||
.bstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:dashed;
|
||||
border-color: gray;
|
||||
}
|
||||
.btstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:solid;
|
||||
border-color: gray;
|
||||
}
|
||||
}
|
||||
</style></head><body>'''
|
||||
str_html = '''<html><strong> Fields Result</strong><head>%s</head><body>'''%(self.get_style())
|
||||
res += str_html
|
||||
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('Field name'), _('Suggestion')])
|
||||
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('Field name'), _('Suggestion')])
|
||||
if not self.error:
|
||||
for key in dict_obj.keys():
|
||||
data_list = []
|
||||
|
@ -211,34 +195,18 @@ Test checks for fields, views, security rules, dependancy level
|
|||
for i in data_list:
|
||||
count = count + 1
|
||||
final_dict[key + str(count)] = i
|
||||
res_str = '<table class="bstyle">' + self.format_html_table(header, data_list=final_dict) + '</table><br>'
|
||||
res += res_str.replace('''<td''', '''<td class="btstyle" ''')
|
||||
res_str = '<table class="tablestyle">' + self.format_html_table(header, data_list=final_dict) + '</table><br>'
|
||||
res += res_str.replace('''<td''', '''<td class="tdatastyle" ''')
|
||||
return res + '</body></html>'
|
||||
return ""
|
||||
|
||||
def get_result_general(self, dict_obj, name=''):
|
||||
str_html = '''<html><strong> %s Result</strong><head>
|
||||
<style>
|
||||
.bstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:dashed;
|
||||
border-color: gray;
|
||||
}
|
||||
.btstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:solid;
|
||||
border-color: gray;
|
||||
}
|
||||
}
|
||||
</style></head><body><table class="bstyle">'''% (name)
|
||||
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('Suggestion')])
|
||||
str_html = '''<html><strong> %s Result</strong><head>%s</head><body><table class="tablestyle">'''% (name, self.get_style())
|
||||
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('Suggestion')])
|
||||
if not self.error:
|
||||
res = str_html + self.format_html_table(header, data_list=dict_obj) + '</table></body></html>'
|
||||
res = res.replace('''<td''', '''<td class="btstyle" ''')
|
||||
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
|
||||
return res
|
||||
return ""
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -271,27 +271,11 @@ PEP-8 Test , copyright of py files check, method can not call from loops
|
|||
return ""
|
||||
|
||||
def get_result_general(self, dict_obj):
|
||||
str_html = '''<html><strong>Result</strong><head>
|
||||
<style>
|
||||
.bstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:dashed;
|
||||
border-color: gray;
|
||||
}
|
||||
.btstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:solid;
|
||||
border-color: gray;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head><body><table class="bstyle">'''
|
||||
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('Line number'), _('Suggestion')])
|
||||
str_html = '''<html><strong>Result</strong><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
|
||||
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('Line number'), _('Suggestion')])
|
||||
if not self.error:
|
||||
res = str_html + self.format_html_table(header, data_list=dict_obj) + '</table></body></html>'
|
||||
res = res.replace('''<td''', '''<td class="btstyle" ''')
|
||||
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
|
||||
return res
|
||||
return ""
|
||||
|
||||
|
|
|
@ -48,29 +48,7 @@ class quality_test(base_module_quality.abstract_quality_check):
|
|||
score = 0.0
|
||||
dict_py = {}
|
||||
flag = False
|
||||
self.result_details += '''<html><body><head>
|
||||
<style>
|
||||
.bstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:dashed;
|
||||
border-color: gray;
|
||||
}
|
||||
.btstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:solid;
|
||||
border-color: gray;
|
||||
}
|
||||
.head
|
||||
{
|
||||
color: black;background: none;font-weight: normal;margin: 0;padding-top: .5em;
|
||||
padding-bottom: .17em; border-bottom: 1px solid #aaa;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
'''
|
||||
self.result_details += '''<html><body><head>%s</head>'''%(self.get_style())
|
||||
for file_py in list_files:
|
||||
if file_py.split('.')[-1] == 'py' and not file_py.endswith('__init__.py') and not file_py.endswith('__terp__.py'):
|
||||
if not flag:
|
||||
|
@ -104,17 +82,18 @@ class quality_test(base_module_quality.abstract_quality_check):
|
|||
dict_py[file_py] = [file_py, _("Unable to parse the result. Check the details.")]
|
||||
replace_string = ''
|
||||
replace_string += res
|
||||
replace_string = replace_string.replace('''<div''', '''<div style="border:1px solid #aaaaaa;background-color:#f9f9f9;padding:5px;"''')
|
||||
replace_string = replace_string.replace('''<div''', '''<div class="divstyle" ''')
|
||||
replace_string = replace_string.replace('''<h1''', '''<h1 style="font-size:188%" class="head" ''')
|
||||
replace_string = replace_string.replace('''<h2''', '''<h2 style="font-size:150%" class="head" ''')
|
||||
replace_string = replace_string.replace('''<h3''', '''<h3 style="font-size:132%" class="head" ''')
|
||||
replace_string = replace_string.replace('''<h4''', '''<h4 style="font-size:116%" class="head" ''')
|
||||
replace_string = replace_string.replace('''<h5''', '''<h5 style="font-size:100%" class="head" ''')
|
||||
replace_string = replace_string.replace('''<h6''', '''<h6 style="font-size:80%" class="head" ''')
|
||||
replace_string = replace_string.replace('''<table''', '''<table class="bstyle" ''')
|
||||
replace_string = replace_string.replace('''<th''', '''<th class="btstyle" ''')
|
||||
replace_string = replace_string.replace('''<td''', '''<td class="btstyle" ''')
|
||||
replace_string = replace_string.replace('''<table''', '''<table class="tablestyle" ''')
|
||||
replace_string = replace_string.replace('''<th''', '''<th class="tdatastyle" ''')
|
||||
replace_string = replace_string.replace('''<td''', '''<td class="tdatastyle" ''')
|
||||
self.result_details += replace_string
|
||||
|
||||
if not flag:
|
||||
self.error = True
|
||||
self.result = _("No python file found")
|
||||
|
@ -133,5 +112,4 @@ class quality_test(base_module_quality.abstract_quality_check):
|
|||
return self.format_table(header, data_list=dict_py)
|
||||
return ""
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -125,26 +125,11 @@ This test checks the speed of the module. Note that at least 5 demo data is need
|
|||
return ""
|
||||
|
||||
def get_result_details(self, dict_speed):
|
||||
str_html = '''<html><head>
|
||||
<style>
|
||||
.bstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:dashed;
|
||||
border-color: gray;
|
||||
}
|
||||
.btstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:solid;
|
||||
border-color: gray;
|
||||
}
|
||||
}
|
||||
</style></head><body><table class="bstyle">'''
|
||||
header = ('<tr><th class="btstyle" >%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('N (Number of Records)'), _('1'), _('N/2'), _('N'), _('Reading Complexity')])
|
||||
str_html = '''<html><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
|
||||
header = ('<tr><th class="tdatastyle" >%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('N (Number of Records)'), _('1'), _('N/2'), _('N'), _('Reading Complexity')])
|
||||
if not self.error:
|
||||
res = str_html + self.format_html_table(header, data_list=dict_speed) + '</table></body></html>'
|
||||
res = res.replace('''<td''', '''<td class="btstyle" ''')
|
||||
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
|
||||
return res
|
||||
return ""
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import os
|
|||
|
||||
from tools.translate import _
|
||||
from base_module_quality import base_module_quality
|
||||
import pooler
|
||||
|
||||
class quality_test(base_module_quality.abstract_quality_check):
|
||||
|
||||
|
@ -135,7 +136,6 @@ This test checks if the module satisfy tiny structure
|
|||
self.module_score += final_score
|
||||
self.score = self.module_score / (self.count)
|
||||
self.result = self.get_result({ module_name: [module_name, int(self.score*100)]})
|
||||
# self.result_details += self.get_result_details(self.result_dict)
|
||||
return None
|
||||
|
||||
def run_test(self, cr, uid, module_path):
|
||||
|
@ -170,28 +170,12 @@ This test checks if the module satisfy tiny structure
|
|||
return score
|
||||
|
||||
def get_result_details(self, dict_struct):
|
||||
str_html = '''<html><head>
|
||||
<style>
|
||||
.bstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:dashed;
|
||||
border-color: gray;
|
||||
}
|
||||
.btstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:solid;
|
||||
border-color: gray;
|
||||
}
|
||||
}
|
||||
</style></head><body><table class="bstyle">'''
|
||||
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('File Name'), _('Feedback about structure of module')])
|
||||
str_html = '''<html><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
|
||||
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('File Name'), _('Feedback about structure of module')])
|
||||
if not self.error:
|
||||
res = str_html + self.format_html_table(header, data_list=dict_struct) + '</table></body></html>'
|
||||
res = res.replace('''<td''', '''<td class="btstyle" ''')
|
||||
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
|
||||
return res
|
||||
return ""
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -26,7 +26,6 @@ import re
|
|||
import tools
|
||||
from tools.translate import _
|
||||
from base_module_quality import base_module_quality
|
||||
import pooler
|
||||
|
||||
class quality_test(base_module_quality.abstract_quality_check):
|
||||
|
||||
|
@ -116,6 +115,7 @@ class quality_test(base_module_quality.abstract_quality_check):
|
|||
|
||||
if result_dict1 or result_dict1:
|
||||
score = round((feel_good_factor) / float(feel_good_factor + feel_bad_factor), 2)
|
||||
|
||||
self.result_details += self.get_result_details(result_dict)
|
||||
self.result_details += self.get_result_details(result_dict1)
|
||||
return [_('__terp__.py file'), score]
|
||||
|
@ -137,26 +137,11 @@ class quality_test(base_module_quality.abstract_quality_check):
|
|||
|
||||
def get_result_details(self, dict_terp):
|
||||
if dict_terp:
|
||||
str_html = '''<html><head>
|
||||
<style>
|
||||
.bstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:dashed;
|
||||
border-color: gray;
|
||||
}
|
||||
.btstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:solid;
|
||||
border-color: gray;
|
||||
}
|
||||
}
|
||||
</style></head><body><table class="bstyle">'''
|
||||
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Tag Name'), _('Feed back About terp file of Module')])
|
||||
str_html = '''<html><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
|
||||
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Tag Name'), _('Feed back About terp file of Module')])
|
||||
if not self.error:
|
||||
res = str_html + self.format_html_table(header, data_list=dict_terp) + '</table><newline/></body></html>'
|
||||
res = res.replace('''<td''', '''<td class="btstyle" ''')
|
||||
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
|
||||
return res
|
||||
return ""
|
||||
|
||||
|
|
|
@ -23,6 +23,4 @@
|
|||
import module_quality_check
|
||||
import quality_save_report
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -134,26 +134,11 @@ class quality_test(base_module_quality.abstract_quality_check):
|
|||
return ""
|
||||
|
||||
def get_result_details(self, dict_wf):
|
||||
str_html = '''<html><head>
|
||||
<style>
|
||||
.bstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:dashed;
|
||||
border-color: gray;
|
||||
}
|
||||
.btstyle
|
||||
{
|
||||
border-width:2px;
|
||||
border-style:solid;
|
||||
border-color: gray;
|
||||
}
|
||||
}
|
||||
</style></head><body><table class="bstyle">'''
|
||||
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('Feed back About Workflow of Module')])
|
||||
str_html = '''<html><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
|
||||
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('Feed back About Workflow of Module')])
|
||||
if not self.error:
|
||||
res = str_html + self.format_html_table(header, data_list=dict_wf) + '</table><newline/></body></html>'
|
||||
res = res.replace('''<td''', '''<td class="btstyle" ''')
|
||||
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
|
||||
return res
|
||||
return ""
|
||||
|
||||
|
|
Loading…
Reference in New Issue