summaryrefslogtreecommitdiff
path: root/addons/base_module_quality/wizard
diff options
context:
space:
mode:
authorMustufa Rangwala <mra@tinyerp.com>2008-12-05 14:57:33 +0530
committerMustufa Rangwala <mra@tinyerp.com>2008-12-05 14:57:33 +0530
commit4c505f51aa77b7c86fa41dc4a79af17988b4e4ca (patch)
tree1770474457a5e7f4d90bc925501098d3ecb7783f /addons/base_module_quality/wizard
parent6ddfabaf17d258c0c54749e663f88072e874802f (diff)
base module quality
bzr revid: mra@tinyerp.com-20081205092733-60b9iki2gxtgiolp
Diffstat (limited to 'addons/base_module_quality/wizard')
-rw-r--r--addons/base_module_quality/wizard/__init__.py27
-rw-r--r--addons/base_module_quality/wizard/module_quality_check.py85
-rw-r--r--addons/base_module_quality/wizard/pylint_test/__init__.py25
-rw-r--r--addons/base_module_quality/wizard/pylint_test/pylint_test.py162
4 files changed, 299 insertions, 0 deletions
diff --git a/addons/base_module_quality/wizard/__init__.py b/addons/base_module_quality/wizard/__init__.py
new file mode 100644
index 00000000000..a8454f95f3f
--- /dev/null
+++ b/addons/base_module_quality/wizard/__init__.py
@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import module_quality_check
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/base_module_quality/wizard/module_quality_check.py b/addons/base_module_quality/wizard/module_quality_check.py
new file mode 100644
index 00000000000..648b24366f6
--- /dev/null
+++ b/addons/base_module_quality/wizard/module_quality_check.py
@@ -0,0 +1,85 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import wizard
+import pooler
+import osv
+import netsvc
+
+import sys
+import tools
+import os
+import pylint
+
+form_check = '''<?xml version="1.0"?>
+<form string="Quality check">
+ <field name="test" />
+</form>'''
+
+fields_check = {
+ 'test': {
+ 'string':'Tests', 'type':'selection', 'size':64, 'required':True,
+ 'selection': [('pylint', 'Pylint'), ('othertest','other')],
+ 'default': lambda *args: 'pylint'
+ },
+ }
+view_form = """<?xml version="1.0"?>
+<form string="Check quality">
+ <group colspan="2" col="4">
+ <field name="module_info" nolabel="1" colspan="4"/>
+ </group>
+</form>"""
+
+view_field = {
+ "module_info": {'type': 'text', 'string': 'check quality',
+ 'readonly': True,},
+}
+
+class wiz_quality_check(wizard.interface):
+
+ def _check(self, cr, uid, data, context):
+ if data['form']['test'] == 'pylint':
+ pool=pooler.get_pool(cr.dbname)
+ module_data = pool.get('ir.module.module').browse(cr, uid, data['ids'])
+ from pylint_test import pylint_test
+ ad = tools.config['addons_path']
+ url = os.path.join(ad, module_data[0].name)
+ result = pylint_test._test_pylint(self, url)
+ string_ret = ''
+ for i in result:
+ string_ret = string_ret + i + ':\n' + result[i]
+
+ return {'module_info':string_ret}
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch':form_check, 'fields':fields_check, 'state':[('end','Cancel'),('do','Do Test')]}
+ },
+ 'do': {
+ 'actions': [_check],
+ 'result': {'type':'form', 'arch':view_form, 'fields':view_field, 'state':[('end','Ok')]},
+ },
+
+ }
+wiz_quality_check('base.module.quality')
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/base_module_quality/wizard/pylint_test/__init__.py b/addons/base_module_quality/wizard/pylint_test/__init__.py
new file mode 100644
index 00000000000..79bc02a75a6
--- /dev/null
+++ b/addons/base_module_quality/wizard/pylint_test/__init__.py
@@ -0,0 +1,25 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import pylint_test
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/base_module_quality/wizard/pylint_test/pylint_test.py b/addons/base_module_quality/wizard/pylint_test/pylint_test.py
new file mode 100644
index 00000000000..73e72307d29
--- /dev/null
+++ b/addons/base_module_quality/wizard/pylint_test/pylint_test.py
@@ -0,0 +1,162 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import netsvc
+from osv import fields, osv
+import os
+
+def _test_pylint(self, url):
+ list_files = os.listdir(url)
+ dict_files = {}
+ for file in list_files:
+ if file.split('.')[-1] == 'py':
+ save_file = file.split('.')[0]+".txt"
+ file_path = os.path.join(url, file)
+ a1 = os.system('pylint '+file_path+'>> '+save_file+' ')
+ a2 = os.system('cat '+save_file+' | tail -4 >> temp.txt')
+ fp = open('temp.txt','r')
+ result = fp.read()
+ fp.close()
+ str_result = ''
+ try:
+ for line in result:
+ str_result = str_result + line
+ finally:
+ fp = open('temp.txt','w')
+ fp.write('')
+ fp.close()
+ if str_result.startswith('Global'):
+ dict_files[file] = str_result
+ return dict_files
+#
+#class res_partner_contact(osv.osv):
+# _name = "res.partner.contact"
+# _description = "res.partner.contact"
+#
+# def _title_get(self,cr, user, context={}):
+# obj = self.pool.get('res.partner.title')
+# ids = obj.search(cr, user, [])
+# res = obj.read(cr, user, ids, ['shortcut', 'name','domain'], context)
+# res = [(r['shortcut'], r['name']) for r in res if r['domain']=='contact']
+# return res
+#
+# _columns = {
+# 'name': fields.char('Last Name', size=30,required=True),
+# 'first_name': fields.char('First Name', size=30),
+# 'mobile':fields.char('Mobile',size=30),
+# 'title': fields.selection(_title_get, 'Title'),
+# 'website':fields.char('Website',size=120),
+# 'lang_id':fields.many2one('res.lang','Language'),
+# 'job_ids':fields.one2many('res.partner.job','contact_id','Functions and Addresses'),
+# 'country_id':fields.many2one('res.country','Nationality'),
+# 'birthdate':fields.date('Birth Date'),
+# 'active' : fields.boolean('Active'),
+# 'partner_id':fields.related('job_ids','address_id','partner_id',type='many2one', relation='res.partner', string='Main Employer'),
+# 'function_id':fields.related('job_ids','function_id',type='many2one', relation='res.partner.function', string='Main Job'),
+# }
+# _defaults = {
+# 'active' : lambda *a: True,
+# }
+# def name_get(self, cr, user, ids, context={}):
+# #will return name and first_name.......
+# if not len(ids):
+# return []
+# res = []
+# for r in self.read(cr, user, ids, ['name','first_name','title']):
+# addr = r['title'] and str(r['title'])+" " or ''
+# addr +=str(r['name'] or '')
+# if r['name'] and r['first_name']:
+# addr += ' '
+# addr += str(r['first_name'] or '')
+# res.append((r['id'], addr))
+# return res
+#res_partner_contact()
+#
+#class res_partner_address(osv.osv):
+#
+# #overriding of the name_get defined in base in order to remove the old contact name
+# def name_get(self, cr, user, ids, context={}):
+# if not len(ids):
+# return []
+# res = []
+# for r in self.read(cr, user, ids, ['zip','city','partner_id', 'street']):
+# if context.get('contact_display', 'contact')=='partner':
+# res.append((r['id'], r['partner_id'][1]))
+# else:
+# addr = str('')
+# addr += str(r['street'] or '') + ' ' + str(r['zip'] or '') + ' ' + str(r['city'] or '')
+# res.append((r['id'], addr.strip() or '/'))
+# return res
+#
+# _name = 'res.partner.address'
+# _inherit='res.partner.address'
+# _description ='Partner Address'
+# _columns = {
+# 'job_ids':fields.one2many('res.partner.job', 'address_id', 'Contacts'),
+# }
+#res_partner_address()
+#
+#class res_partner_job(osv.osv):
+#
+# def name_get(self, cr, uid, ids, context={}):
+# if not len(ids):
+# return []
+# res = []
+# for r in self.browse(cr, uid, ids):
+# res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] +", "+ r.function_id.name))
+# return res
+#
+# def search(self, cr, user, args, offset=0, limit=None, order=None,
+# context=None, count=False):
+# for arg in args:
+# if arg[0]=='address_id':
+# self._order = 'sequence_partner'
+# if arg[0]=='contact_id':
+# self._order = 'sequence_contact'
+# return super(res_partner_job,self).search(cr, user, args, offset, limit, order, context, count)
+#
+# _name = 'res.partner.job'
+# _description ='Contact Job Title'
+# _order = 'sequence_contact'
+# _columns = {
+# 'name': fields.related('address_id','partner_id', type='many2one', relation='res.partner', string='Partner'),
+# 'address_id':fields.many2one('res.partner.address','Address'),
+# 'contact_id':fields.many2one('res.partner.contact','Contact', required=True, ondelete='cascade'),
+# 'function_id': fields.many2one('res.partner.function','Job Title'),
+# 'sequence_contact':fields.integer('Sequence',help='Order of importance of this address in the list of addresses of the linked contact'),
+# 'sequence_partner':fields.integer('Sequence',help='Order of importance of this job title in the list of job title of the linked partner'),
+# 'email': fields.char('E-Mail', size=240),
+# 'phone': fields.char('Phone', size=64),
+# 'date_start' : fields.date('Date Start'),
+# 'date_stop' : fields.date('Date Stop'),
+# 'state' : fields.selection([('past', 'Past'),('current', 'Current')], 'State', required=True),
+# }
+#
+# _defaults = {
+# 'sequence_contact' : lambda *a: 0,
+# 'state' : lambda *a: 'current',
+# }
+#res_partner_job()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+