[REF] openerp.report: use the recommended syntax to raise error and never use empty except:.

bzr revid: florent.xicluna@gmail.com-20120208170217-xsa5odzlhite0nda
This commit is contained in:
Florent Xicluna 2012-02-08 18:02:17 +01:00
parent 57ca8e4797
commit b5fa51f4a6
7 changed files with 11 additions and 11 deletions

View File

@ -267,7 +267,7 @@ class report_custom(report_int):
else: else:
try: try:
row.append(float(r[j])) row.append(float(r[j]))
except: except Exception:
row.append(r[j]) row.append(r[j])
results2.append(row) results2.append(row)
if report['type']=='pie': if report['type']=='pie':

View File

@ -44,8 +44,8 @@ class report_int(netsvc.Service):
def __init__(self, name): def __init__(self, name):
assert not self.exists(name), 'The report "%s" already exists!' % name assert not self.exists(name), 'The report "%s" already exists!' % name
super(report_int, self).__init__(name) super(report_int, self).__init__(name)
if name[0:7]<>'report.': if not name.startswith('report.'):
raise Exception, 'ConceptionError, bad report name, should start with "report."' raise Exception('ConceptionError, bad report name, should start with "report."')
self.name = name self.name = name
self.id = 0 self.id = 0
self.name2 = '.'.join(name.split('.')[1:]) self.name2 = '.'.join(name.split('.')[1:])

View File

@ -48,7 +48,7 @@ class report(object):
try: try:
while n.tag != txt.group(3): while n.tag != txt.group(3):
n = n.getparent() n = n.getparent()
except: except Exception:
n = node n = node
else: else:
n = node.getparent() n = node.getparent()

View File

@ -56,7 +56,7 @@ class report_printscreen_list(report_int):
def _parse_string(self, view): def _parse_string(self, view):
try: try:
dom = etree.XML(view.encode('utf-8')) dom = etree.XML(view.encode('utf-8'))
except: except Exception:
dom = etree.XML(view) dom = etree.XML(view)
return self._parse_node(dom) return self._parse_node(dom)

View File

@ -98,7 +98,7 @@ class _flowable(object):
try: try:
if new_child.get('style').find('terp_tblheader')!= -1: if new_child.get('style').find('terp_tblheader')!= -1:
new_node.tag = 'th' new_node.tag = 'th'
except: except Exception:
pass pass
process(node,new_node) process(node,new_node)
if new_node.get('colWidths',False): if new_node.get('colWidths',False):

View File

@ -424,7 +424,7 @@ class _rml_canvas(object):
flow.drawOn(self.canvas,infos['x'],infos['y']) flow.drawOn(self.canvas,infos['x'],infos['y'])
infos['height']-=h infos['height']-=h
else: else:
raise ValueError, "Not enough space" raise ValueError("Not enough space")
def _line_mode(self, node): def _line_mode(self, node):
ljoin = {'round':1, 'mitered':0, 'bevelled':2} ljoin = {'round':1, 'mitered':0, 'bevelled':2}

View File

@ -37,7 +37,7 @@ def _child_get(node, self=None, tagname=None):
if n.get('rml_except', False): if n.get('rml_except', False):
try: try:
eval(n.get('rml_except'), {}, self.localcontext) eval(n.get('rml_except'), {}, self.localcontext)
except: except Exception:
continue continue
if n.get('rml_tag'): if n.get('rml_tag'):
try: try:
@ -46,7 +46,7 @@ def _child_get(node, self=None, tagname=None):
n2.tag = tag n2.tag = tag
n2.attrib.update(attr) n2.attrib.update(attr)
yield n2 yield n2
except: except Exception:
yield n yield n
else: else:
yield n yield n
@ -55,7 +55,7 @@ def _child_get(node, self=None, tagname=None):
if self and self.localcontext and n.get('rml_except', False): if self and self.localcontext and n.get('rml_except', False):
try: try:
eval(n.get('rml_except'), {}, self.localcontext) eval(n.get('rml_except'), {}, self.localcontext)
except: except Exception:
continue continue
if (tagname is None) or (n.tag==tagname): if (tagname is None) or (n.tag==tagname):
yield n yield n
@ -73,7 +73,7 @@ def _process_text(self, txt):
if sps: if sps:
try: try:
txt2 = eval(sps.pop(0),self.localcontext) txt2 = eval(sps.pop(0),self.localcontext)
except: except Exception:
txt2 = '' txt2 = ''
if isinstance(txt2, (int, float)): if isinstance(txt2, (int, float)):
txt2 = str(txt2) txt2 = str(txt2)