[MERGE] openerp.report: remove unused imports and vars
bzr revid: stw@openerp.com-20120910143835-85lcla35odoeanbi
This commit is contained in:
commit
8dc0bcf21c
|
@ -21,7 +21,6 @@
|
|||
|
||||
import os
|
||||
import time
|
||||
import openerp.netsvc as netsvc
|
||||
|
||||
import openerp.tools as tools
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
|
@ -67,7 +66,6 @@ class report_custom(report_int):
|
|||
#
|
||||
def _row_get(self, cr, uid, objs, fields, conditions, row_canvas=None, group_by=None):
|
||||
result = []
|
||||
tmp = []
|
||||
for obj in objs:
|
||||
tobreak = False
|
||||
for cond in conditions:
|
||||
|
@ -108,7 +106,7 @@ class report_custom(report_int):
|
|||
key = levels.keys()
|
||||
for l in key:
|
||||
objs = eval('obj.'+l,{'obj': obj})
|
||||
if not isinstance(objs, browse_record_list) and type(objs) <> type([]):
|
||||
if not isinstance(objs, (browse_record_list, list)):
|
||||
objs = [objs]
|
||||
field_new = []
|
||||
cond_new = []
|
||||
|
@ -221,11 +219,9 @@ class report_custom(report_int):
|
|||
res_dic[prev].append(line)
|
||||
else:
|
||||
prev = line[groupby]
|
||||
if res_dic.has_key(line[groupby]):
|
||||
res_dic[line[groupby]].append(line)
|
||||
else:
|
||||
res_dic[line[groupby]] = []
|
||||
res_dic[line[groupby]].append(line)
|
||||
res_dic.setdefault(line[groupby], [])
|
||||
res_dic[line[groupby]].append(line)
|
||||
|
||||
#we use the keys in results since they are ordered, whereas in res_dic.heys() they aren't
|
||||
for key in filter(None, [x[groupby] for x in results]):
|
||||
row = []
|
||||
|
@ -267,7 +263,7 @@ class report_custom(report_int):
|
|||
else:
|
||||
try:
|
||||
row.append(float(r[j]))
|
||||
except:
|
||||
except Exception:
|
||||
row.append(r[j])
|
||||
results2.append(row)
|
||||
if report['type']=='pie':
|
||||
|
@ -365,7 +361,6 @@ class report_custom(report_int):
|
|||
order_date['Y'] = lambda x : x
|
||||
|
||||
abscissa = []
|
||||
tmp = {}
|
||||
|
||||
idx = 0
|
||||
date_idx = None
|
||||
|
@ -389,7 +384,7 @@ class report_custom(report_int):
|
|||
if date_idx != None:
|
||||
for r in results:
|
||||
key = process_date['Y'](r[date_idx])
|
||||
if not data_by_year.has_key(key):
|
||||
if key not in data_by_year:
|
||||
data_by_year[key] = []
|
||||
for i in range(len(r)):
|
||||
r[i] = fct[i](r[i])
|
||||
|
@ -407,14 +402,14 @@ class report_custom(report_int):
|
|||
for d in data_by_year[line]:
|
||||
for idx in range(len(fields)-1):
|
||||
fields_bar.append({})
|
||||
if fields_bar[idx].has_key(d[0]):
|
||||
if d[0] in fields_bar[idx]:
|
||||
fields_bar[idx][d[0]] += d[idx+1]
|
||||
else:
|
||||
fields_bar[idx][d[0]] = d[idx+1]
|
||||
for idx in range(len(fields)-1):
|
||||
data = {}
|
||||
for k in fields_bar[idx].keys():
|
||||
if data.has_key(k):
|
||||
if k in data:
|
||||
data[k] += fields_bar[idx][k]
|
||||
else:
|
||||
data[k] = fields_bar[idx][k]
|
||||
|
@ -488,7 +483,7 @@ class report_custom(report_int):
|
|||
if date_idx != None:
|
||||
for r in results:
|
||||
key = process_date['Y'](r[date_idx])
|
||||
if not data_by_year.has_key(key):
|
||||
if key not in data_by_year:
|
||||
data_by_year[key] = []
|
||||
for i in range(len(r)):
|
||||
r[i] = fct[i](r[i])
|
||||
|
@ -507,14 +502,14 @@ class report_custom(report_int):
|
|||
for d in data_by_year[line]:
|
||||
for idx in range(len(fields)-1):
|
||||
fields_bar.append({})
|
||||
if fields_bar[idx].has_key(d[0]):
|
||||
if d[0] in fields_bar[idx]:
|
||||
fields_bar[idx][d[0]] += d[idx+1]
|
||||
else:
|
||||
fields_bar[idx][d[0]] = d[idx+1]
|
||||
for idx in range(len(fields)-1):
|
||||
data = {}
|
||||
for k in fields_bar[idx].keys():
|
||||
if data.has_key(k):
|
||||
if k in data:
|
||||
data[k] += fields_bar[idx][k]
|
||||
else:
|
||||
data[k] = fields_bar[idx][k]
|
||||
|
|
|
@ -44,8 +44,8 @@ class report_int(netsvc.Service):
|
|||
def __init__(self, name):
|
||||
assert not self.exists(name), 'The report "%s" already exists!' % name
|
||||
super(report_int, self).__init__(name)
|
||||
if name[0:7]<>'report.':
|
||||
raise Exception, 'ConceptionError, bad report name, should start with "report."'
|
||||
if not name.startswith('report.'):
|
||||
raise Exception('ConceptionError, bad report name, should start with "report."')
|
||||
self.name = name
|
||||
self.id = 0
|
||||
self.name2 = '.'.join(name.split('.')[1:])
|
||||
|
@ -181,7 +181,7 @@ class report_rml(report_int):
|
|||
|
||||
def create_pdf(self, rml, localcontext = None, logo=None, title=None):
|
||||
if not localcontext:
|
||||
localcontext={}
|
||||
localcontext = {}
|
||||
localcontext.update({'internal_header':self.internal_header})
|
||||
if logo:
|
||||
self.bin_datas['logo'] = logo
|
||||
|
|
|
@ -48,7 +48,7 @@ class report(object):
|
|||
try:
|
||||
while n.tag != txt.group(3):
|
||||
n = n.getparent()
|
||||
except:
|
||||
except Exception:
|
||||
n = node
|
||||
else:
|
||||
n = node.getparent()
|
||||
|
|
|
@ -200,7 +200,7 @@ class document(object):
|
|||
else:
|
||||
args = []
|
||||
# get the object
|
||||
if attrs.has_key('model'):
|
||||
if 'model' in attrs:
|
||||
obj = self.pool.get(attrs['model'])
|
||||
else:
|
||||
if isinstance(browser, list):
|
||||
|
@ -209,7 +209,7 @@ class document(object):
|
|||
obj = browser._table
|
||||
|
||||
# get the ids
|
||||
if attrs.has_key('ids'):
|
||||
if 'ids' in attrs:
|
||||
ids = self.eval(browser, attrs['ids'])
|
||||
else:
|
||||
if isinstance(browser, list):
|
||||
|
@ -228,7 +228,7 @@ class document(object):
|
|||
if not isinstance(datas[atr['value']], (str, unicode)):
|
||||
txt = str(datas[atr['value']])
|
||||
else:
|
||||
txt = datas[atr['value']]
|
||||
txt = datas[atr['value']]
|
||||
el.text = txt
|
||||
else:
|
||||
for el_cld in node:
|
||||
|
|
|
@ -120,7 +120,7 @@ class report_printscreen_list(report_int):
|
|||
line[f]=round(line[f],precision)
|
||||
col = etree.SubElement(node_line, 'col', tree='no')
|
||||
if line[f] != None:
|
||||
col.text = tools.ustr(line[f] or '')
|
||||
col.text = tools.ustr(line[f] or '')
|
||||
else:
|
||||
col.text = '/'
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class report_printscreen_list(report_int):
|
|||
def _parse_string(self, view):
|
||||
try:
|
||||
dom = etree.XML(view.encode('utf-8'))
|
||||
except:
|
||||
except Exception:
|
||||
dom = etree.XML(view)
|
||||
return self._parse_node(dom)
|
||||
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
from openerp.report.render.rml2pdf import utils
|
||||
from lxml import etree
|
||||
import copy
|
||||
import openerp.pooler as pooler
|
||||
import base64
|
||||
import cStringIO
|
||||
import re
|
||||
|
|
|
@ -23,8 +23,7 @@ import mako
|
|||
from lxml import etree
|
||||
from mako.template import Template
|
||||
from mako.lookup import TemplateLookup
|
||||
import openerp.netsvc as netsvc
|
||||
import traceback, sys, os
|
||||
import os
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -126,9 +125,8 @@ class makohtml2html(object):
|
|||
final_html += self.format_header(etree_obj)
|
||||
final_html += self.format_body(etree_obj)
|
||||
return final_html
|
||||
except Exception,e:
|
||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
_logger.error('report :\n%s\n%s\n', tb_s, str(e))
|
||||
except Exception:
|
||||
_logger.exception('report :')
|
||||
|
||||
def parseNode(html, localcontext = {}):
|
||||
r = makohtml2html(html, localcontext)
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
##############################################################################
|
||||
|
||||
from openerp.report.render.rml2pdf import utils
|
||||
from lxml import etree
|
||||
import copy
|
||||
|
||||
class odt2odt(object):
|
||||
|
|
|
@ -39,7 +39,7 @@ import sys
|
|||
import cStringIO
|
||||
from lxml import etree
|
||||
import copy
|
||||
import utils
|
||||
|
||||
from openerp.report.render.rml2pdf import utils
|
||||
|
||||
class _flowable(object):
|
||||
|
@ -98,7 +98,7 @@ class _flowable(object):
|
|||
try:
|
||||
if new_child.get('style').find('terp_tblheader')!= -1:
|
||||
new_node.tag = 'th'
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
process(node,new_node)
|
||||
if new_node.get('colWidths',False):
|
||||
|
@ -232,7 +232,7 @@ class _rml_stylesheet(object):
|
|||
attr = {}
|
||||
attrs = ps.attrib
|
||||
for key, val in attrs.items():
|
||||
attr[key] = val
|
||||
attr[key] = val
|
||||
attrs = []
|
||||
for a in attr:
|
||||
if a in self._tags:
|
||||
|
@ -296,13 +296,13 @@ class _rml_template(object):
|
|||
frames[(posy,posx,tmpl.get('id'))] = _rml_tmpl_frame(posx, utils.unit_get(tmpl.get('width')))
|
||||
for tmpl in pt.findall('pageGraphics'):
|
||||
for n in tmpl:
|
||||
if n.tag == 'image':
|
||||
self.data = rc + utils._process_text(self, n.text)
|
||||
if n.tag in self._tags:
|
||||
t = self._tags[n.tag](n, self.style,self.localcontext)
|
||||
frames[(t.posy,t.posx,n.tag)] = t
|
||||
else:
|
||||
self.style.update(n)
|
||||
if n.tag == 'image':
|
||||
self.data = rc + utils._process_text(self, n.text)
|
||||
if n.tag in self._tags:
|
||||
t = self._tags[n.tag](n, self.style,self.localcontext)
|
||||
frames[(t.posy,t.posx,n.tag)] = t
|
||||
else:
|
||||
self.style.update(n)
|
||||
keys = frames.keys()
|
||||
keys.sort()
|
||||
keys.reverse()
|
||||
|
|
|
@ -82,7 +82,7 @@ class NumberedCanvas(canvas.Canvas):
|
|||
def showPage(self):
|
||||
self._currentPage +=1
|
||||
if not self._flag:
|
||||
self._pageCount += 1
|
||||
self._pageCount += 1
|
||||
else:
|
||||
self.pages.update({self._currentPage:self._pageCount})
|
||||
self._codes.append({'code': self._code, 'stack': self._codeStack})
|
||||
|
@ -424,7 +424,7 @@ class _rml_canvas(object):
|
|||
flow.drawOn(self.canvas,infos['x'],infos['y'])
|
||||
infos['height']-=h
|
||||
else:
|
||||
raise ValueError, "Not enough space"
|
||||
raise ValueError("Not enough space")
|
||||
|
||||
def _line_mode(self, node):
|
||||
ljoin = {'round':1, 'mitered':0, 'bevelled':2}
|
||||
|
|
|
@ -22,9 +22,7 @@
|
|||
|
||||
import sys
|
||||
import StringIO
|
||||
import copy
|
||||
from lxml import etree
|
||||
import base64
|
||||
|
||||
import utils
|
||||
|
||||
|
@ -336,8 +334,8 @@ class _rml_stylesheet(object):
|
|||
attr = {}
|
||||
attrs = ps.attributes
|
||||
for i in range(attrs.length):
|
||||
name = attrs.item(i).localName
|
||||
attr[name] = ps.get(name)
|
||||
name = attrs.item(i).localName
|
||||
attr[name] = ps.get(name)
|
||||
attrs = []
|
||||
for a in attr:
|
||||
if a in self._tags:
|
||||
|
|
|
@ -23,7 +23,6 @@ import copy
|
|||
import re
|
||||
import reportlab
|
||||
import reportlab.lib.units
|
||||
from lxml import etree
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
|
||||
_regex = re.compile('\[\[(.+?)\]\]')
|
||||
|
@ -38,7 +37,7 @@ def _child_get(node, self=None, tagname=None):
|
|||
if n.get('rml_except', False):
|
||||
try:
|
||||
eval(n.get('rml_except'), {}, self.localcontext)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
if n.get('rml_tag'):
|
||||
try:
|
||||
|
@ -47,7 +46,7 @@ def _child_get(node, self=None, tagname=None):
|
|||
n2.tag = tag
|
||||
n2.attrib.update(attr)
|
||||
yield n2
|
||||
except:
|
||||
except Exception:
|
||||
yield n
|
||||
else:
|
||||
yield n
|
||||
|
@ -56,7 +55,7 @@ def _child_get(node, self=None, tagname=None):
|
|||
if self and self.localcontext and n.get('rml_except', False):
|
||||
try:
|
||||
eval(n.get('rml_except'), {}, self.localcontext)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
if (tagname is None) or (n.tag==tagname):
|
||||
yield n
|
||||
|
@ -74,11 +73,11 @@ def _process_text(self, txt):
|
|||
if sps:
|
||||
try:
|
||||
txt2 = eval(sps.pop(0),self.localcontext)
|
||||
except:
|
||||
except Exception:
|
||||
txt2 = ''
|
||||
if type(txt2) == type(0) or type(txt2) == type(0.0):
|
||||
if isinstance(txt2, (int, float)):
|
||||
txt2 = str(txt2)
|
||||
if type(txt2)==type('') or type(txt2)==type(u''):
|
||||
if isinstance(txt2, basestring):
|
||||
result += txt2
|
||||
return result
|
||||
|
||||
|
|
|
@ -66,7 +66,6 @@ class simple(render.render):
|
|||
return self.result.getvalue()
|
||||
|
||||
if __name__=='__main__':
|
||||
import time
|
||||
s = simple()
|
||||
s.xml = '''<test>
|
||||
<author-list>
|
||||
|
@ -82,7 +81,7 @@ if __name__=='__main__':
|
|||
</author-list>
|
||||
</test>'''
|
||||
if s.render():
|
||||
print s.get()
|
||||
print s.get()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
Loading…
Reference in New Issue