1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
26 from base_module_quality import base_module_quality
30 class quality_test(base_module_quality.abstract_quality_check):
34 # This test checks the quality of __terp__.py file in the selected module.
36 super(quality_test, self).__init__()
37 self.name = _("Terp Test")
38 self.bool_installed_only = False
44 def run_test(self, cr, uid, module_path):
45 list_files = os.listdir(module_path)
47 path = os.path.join(module_path, i)
48 if os.path.isdir(path):
49 for j in os.listdir(path):
50 list_files.append(os.path.join(i, j))
56 if '__terp__.py' not in list_files:
59 self.result += "The module does not contain the __terp__.py file"
61 terp_file = os.path.join(module_path,'__terp__.py')
62 res = eval(tools.file_open(terp_file).read())
64 terp_keys = ['category', 'name', 'description', 'author', 'website', 'update_xml', 'init_xml', 'depends', 'version', 'active', 'installable', 'demo_xml']
69 if isinstance(res[key],(str,unicode)):
73 if key == 'description' and res[key] and len(str(res[key]))>=25:
75 if res['description'].count('\n') >= 4:# description contains minimum 5 lines
78 ptrn = re.compile('https?://[\w\.]*') # reg ex matching on temporary basis.
79 result = ptrn.search(str(res[key]))
85 self.score = round((feel_good_factor) / float(feel_good_factor + feel_bad_factor),2)
86 self.result += "\nThis test checks if the module satisfies the current coding standard for __terp__.py file used by OpenERP."
87 # self.result += "__terp__.py : "+ str(self.score) + "/10\n"
90 def get_result(self, cr, uid, module_path, module_state):
91 # self.run_test(cr, uid, module_path)
92 # summary = "\n===TERP Test===:\n"
95 The module does not contain the __terp__.py file.\n\n """
98 # This test checks if the module satisfies the current coding standard for __terp__.py file used by OpenERP.
99 # """ + "Score: " + str(self.score) + "/10\n"
102 def get_result_details(self):
103 detail = "\n===TERP Test===\n" + self.result
108 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: