73e72307d2967386953dc0d7facf51b06a82daca
[odoo/odoo.git] / addons / base_module_quality / wizard / pylint_test / pylint_test.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6 #    $Id$
7 #
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.
12 #
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.
17 #
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/>.
20 #
21 ##############################################################################
22
23 import netsvc
24 from osv import fields, osv
25 import os
26
27 def _test_pylint(self, url):
28     list_files = os.listdir(url)
29     dict_files = {}
30     for file in list_files:
31         if file.split('.')[-1] == 'py':
32             save_file = file.split('.')[0]+".txt"
33             file_path = os.path.join(url, file)
34             a1 = os.system('pylint '+file_path+'>> '+save_file+' ')
35             a2 = os.system('cat '+save_file+' | tail -4 >> temp.txt')
36             fp = open('temp.txt','r')
37             result = fp.read()
38             fp.close()
39             str_result = ''
40             try:
41                 for line in result:
42                     str_result = str_result + line
43             finally:
44                 fp = open('temp.txt','w')
45                 fp.write('')
46                 fp.close()
47             if str_result.startswith('Global'):
48                 dict_files[file] = str_result
49     return dict_files
50 #
51 #class res_partner_contact(osv.osv):
52 #    _name = "res.partner.contact"
53 #    _description = "res.partner.contact"
54 #
55 #    def _title_get(self,cr, user, context={}):
56 #        obj = self.pool.get('res.partner.title')
57 #        ids = obj.search(cr, user, [])
58 #        res = obj.read(cr, user, ids, ['shortcut', 'name','domain'], context)
59 #        res = [(r['shortcut'], r['name']) for r in res if r['domain']=='contact']
60 #        return res
61 #
62 #    _columns = {
63 #        'name': fields.char('Last Name', size=30,required=True),
64 #        'first_name': fields.char('First Name', size=30),
65 #        'mobile':fields.char('Mobile',size=30),
66 #        'title': fields.selection(_title_get, 'Title'),
67 #        'website':fields.char('Website',size=120),
68 #        'lang_id':fields.many2one('res.lang','Language'),
69 #        'job_ids':fields.one2many('res.partner.job','contact_id','Functions and Addresses'),
70 #        'country_id':fields.many2one('res.country','Nationality'),
71 #        'birthdate':fields.date('Birth Date'),
72 #        'active' : fields.boolean('Active'),
73 #        'partner_id':fields.related('job_ids','address_id','partner_id',type='many2one', relation='res.partner', string='Main Employer'),
74 #        'function_id':fields.related('job_ids','function_id',type='many2one', relation='res.partner.function', string='Main Job'),
75 #    }
76 #    _defaults = {
77 #        'active' : lambda *a: True,
78 #    }
79 #    def name_get(self, cr, user, ids, context={}):
80 #        #will return name and first_name.......
81 #        if not len(ids):
82 #            return []
83 #        res = []
84 #        for r in self.read(cr, user, ids, ['name','first_name','title']):
85 #            addr = r['title'] and str(r['title'])+" " or ''
86 #            addr +=str(r['name'] or '')
87 #            if r['name'] and r['first_name']:
88 #                addr += ' '
89 #            addr += str(r['first_name'] or '')
90 #            res.append((r['id'], addr))
91 #        return res
92 #res_partner_contact()
93 #
94 #class res_partner_address(osv.osv):
95 #
96 #    #overriding of the name_get defined in base in order to remove the old contact name
97 #    def name_get(self, cr, user, ids, context={}):
98 #        if not len(ids):
99 #            return []
100 #        res = []
101 #        for r in self.read(cr, user, ids, ['zip','city','partner_id', 'street']):
102 #            if context.get('contact_display', 'contact')=='partner':
103 #                res.append((r['id'], r['partner_id'][1]))
104 #            else:
105 #                addr = str('')
106 #                addr += str(r['street'] or '') + ' ' + str(r['zip'] or '') + ' ' + str(r['city'] or '')
107 #                res.append((r['id'], addr.strip() or '/'))
108 #        return res
109 #
110 #    _name = 'res.partner.address'
111 #    _inherit='res.partner.address'
112 #    _description ='Partner Address'
113 #    _columns = {
114 #        'job_ids':fields.one2many('res.partner.job', 'address_id', 'Contacts'),
115 #    }
116 #res_partner_address()
117 #
118 #class res_partner_job(osv.osv):
119 #
120 #    def name_get(self, cr, uid, ids, context={}):
121 #        if not len(ids):
122 #            return []
123 #        res = []
124 #        for r in self.browse(cr, uid, ids):
125 #            res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] +", "+ r.function_id.name))
126 #        return res
127 #
128 #    def search(self, cr, user, args, offset=0, limit=None, order=None,
129 #            context=None, count=False):
130 #        for arg in args:
131 #            if arg[0]=='address_id':
132 #                self._order = 'sequence_partner'
133 #            if arg[0]=='contact_id':
134 #                self._order = 'sequence_contact'
135 #        return super(res_partner_job,self).search(cr, user, args, offset, limit, order, context, count)
136 #
137 #    _name = 'res.partner.job'
138 #    _description ='Contact Job Title'
139 #    _order = 'sequence_contact'
140 #    _columns = {
141 #        'name': fields.related('address_id','partner_id', type='many2one', relation='res.partner', string='Partner'),
142 #        'address_id':fields.many2one('res.partner.address','Address'),
143 #        'contact_id':fields.many2one('res.partner.contact','Contact', required=True, ondelete='cascade'),
144 #        'function_id': fields.many2one('res.partner.function','Job Title'),
145 #        'sequence_contact':fields.integer('Sequence',help='Order of importance of this address in the list of addresses of the linked contact'),
146 #        'sequence_partner':fields.integer('Sequence',help='Order of importance of this job title in the list of job title of the linked partner'),
147 #        'email': fields.char('E-Mail', size=240),
148 #        'phone': fields.char('Phone', size=64),
149 #        'date_start' : fields.date('Date Start'),
150 #        'date_stop' : fields.date('Date Stop'),
151 #        'state' : fields.selection([('past', 'Past'),('current', 'Current')], 'State', required=True),
152 #    }
153 #
154 #    _defaults = {
155 #        'sequence_contact' : lambda *a: 0,
156 #        'state' : lambda *a: 'current',
157 #    }
158 #res_partner_job()
159
160
161 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
162