Merge lp:~anybox/aeroo/fix-upgrade into lp:aeroo

Proposed by Georges Racinet
Status: Superseded
Proposed branch: lp:~anybox/aeroo/fix-upgrade
Merge into: lp:aeroo
Diff against target: 11765 lines (+11131/-0) (has conflicts)
114 files modified
report_aeroo/ExtraFunctions.py (+664/-0)
report_aeroo/__init__.py (+52/-0)
report_aeroo/__openerp__.py (+82/-0)
report_aeroo/barcode/EANBarCode.py (+159/-0)
report_aeroo/barcode/__init__.py (+34/-0)
report_aeroo/barcode/barcode.py (+63/-0)
report_aeroo/barcode/code128.py (+189/-0)
report_aeroo/barcode/code39.py (+166/-0)
report_aeroo/check_deps.py (+52/-0)
report_aeroo/ctt_languages/__init__.py (+3/-0)
report_aeroo/ctt_languages/en_US/__init__.py (+91/-0)
report_aeroo/ctt_languages/en_US/currencies/__init__.py (+3/-0)
report_aeroo/ctt_languages/en_US/currencies/eur.py (+19/-0)
report_aeroo/ctt_languages/en_US/currencies/ltl.py (+19/-0)
report_aeroo/ctt_languages/en_US/currencies/lvl.py (+19/-0)
report_aeroo/ctt_languages/en_US/currencies/mxn.py (+19/-0)
report_aeroo/ctt_languages/en_US/currencies/trl.py (+19/-0)
report_aeroo/ctt_languages/en_US/currencies/usd.py (+19/-0)
report_aeroo/ctt_languages/es_ES/__init__.py (+102/-0)
report_aeroo/ctt_languages/es_ES/currencies/__init__.py (+3/-0)
report_aeroo/ctt_languages/es_ES/currencies/eur.py (+19/-0)
report_aeroo/ctt_languages/es_ES/currencies/mxn.py (+19/-0)
report_aeroo/ctt_languages/es_ES/currencies/usd.py (+19/-0)
report_aeroo/ctt_languages/lt_LT/__init__.py (+107/-0)
report_aeroo/ctt_languages/lt_LT/currencies/__init__.py (+3/-0)
report_aeroo/ctt_languages/lt_LT/currencies/eur.py (+25/-0)
report_aeroo/ctt_languages/lt_LT/currencies/ltl.py (+25/-0)
report_aeroo/ctt_languages/lt_LT/currencies/lvl.py (+25/-0)
report_aeroo/ctt_languages/lt_LT/currencies/uah.py (+25/-0)
report_aeroo/ctt_languages/lt_LT/currencies/usd.py (+25/-0)
report_aeroo/ctt_languages/lv_LV/__init__.py (+101/-0)
report_aeroo/ctt_languages/lv_LV/currencies/__init__.py (+3/-0)
report_aeroo/ctt_languages/lv_LV/currencies/eur.py (+22/-0)
report_aeroo/ctt_languages/lv_LV/currencies/ltl.py (+25/-0)
report_aeroo/ctt_languages/lv_LV/currencies/lvl.py (+25/-0)
report_aeroo/ctt_languages/lv_LV/currencies/mxn.py (+22/-0)
report_aeroo/ctt_languages/lv_LV/currencies/rub.py (+25/-0)
report_aeroo/ctt_languages/lv_LV/currencies/trl.py (+25/-0)
report_aeroo/ctt_languages/lv_LV/currencies/uah.py (+24/-0)
report_aeroo/ctt_languages/lv_LV/currencies/usd.py (+25/-0)
report_aeroo/ctt_languages/ru_RU/__init__.py (+110/-0)
report_aeroo/ctt_languages/ru_RU/currencies/__init__.py (+3/-0)
report_aeroo/ctt_languages/ru_RU/currencies/eur.py (+22/-0)
report_aeroo/ctt_languages/ru_RU/currencies/ltl.py (+23/-0)
report_aeroo/ctt_languages/ru_RU/currencies/lvl.py (+23/-0)
report_aeroo/ctt_languages/ru_RU/currencies/rub.py (+23/-0)
report_aeroo/ctt_languages/ru_RU/currencies/uah.py (+23/-0)
report_aeroo/ctt_languages/ru_RU/currencies/usd.py (+23/-0)
report_aeroo/ctt_languages/tr_TR/__init__.py (+93/-0)
report_aeroo/ctt_languages/tr_TR/currencies/__init__.py (+3/-0)
report_aeroo/ctt_languages/tr_TR/currencies/eur.py (+21/-0)
report_aeroo/ctt_languages/tr_TR/currencies/lvl.py (+21/-0)
report_aeroo/ctt_languages/tr_TR/currencies/trl.py (+21/-0)
report_aeroo/ctt_languages/tr_TR/currencies/usd.py (+21/-0)
report_aeroo/ctt_languages/uk_UA/__init__.py (+112/-0)
report_aeroo/ctt_languages/uk_UA/currencies/__init__.py (+3/-0)
report_aeroo/ctt_languages/uk_UA/currencies/eur.py (+21/-0)
report_aeroo/ctt_languages/uk_UA/currencies/ltl.py (+23/-0)
report_aeroo/ctt_languages/uk_UA/currencies/lvl.py (+23/-0)
report_aeroo/ctt_languages/uk_UA/currencies/rub.py (+23/-0)
report_aeroo/ctt_languages/uk_UA/currencies/uah.py (+23/-0)
report_aeroo/ctt_languages/uk_UA/currencies/usd.py (+23/-0)
report_aeroo/ctt_objects.py (+161/-0)
report_aeroo/currency_to_text.py (+491/-0)
report_aeroo/data/report_aeroo_data.xml (+25/-0)
report_aeroo/domain_parser.py (+49/-0)
report_aeroo/installer.py (+79/-0)
report_aeroo/installer.xml (+56/-0)
report_aeroo/report_aeroo.py (+859/-0)
report_aeroo/report_view.xml (+322/-0)
report_aeroo/report_xml.py (+680/-0)
report_aeroo/security/ir.model.access.csv (+5/-0)
report_aeroo/translate.py (+352/-0)
report_aeroo/wizard/__init__.py (+38/-0)
report_aeroo/wizard/add_print_button.py (+111/-0)
report_aeroo/wizard/add_print_button_view.xml (+40/-0)
report_aeroo/wizard/remove_print_button.py (+97/-0)
report_aeroo/wizard/remove_print_button_view.xml (+37/-0)
report_aeroo/wizard/report_actions.py (+149/-0)
report_aeroo/wizard/report_import_wizard.py (+152/-0)
report_aeroo/wizard/report_print_actions.py (+183/-0)
report_aeroo/wizard/report_print_by_action.py (+63/-0)
report_aeroo_direct_print/__init__.py (+40/-0)
report_aeroo_direct_print/__openerp__.py (+76/-0)
report_aeroo_direct_print/check_deps.py (+51/-0)
report_aeroo_direct_print/data/report_aeroo_direct_data.xml (+17/-0)
report_aeroo_direct_print/installer.py (+152/-0)
report_aeroo_direct_print/installer.xml (+62/-0)
report_aeroo_direct_print/report_aeroo_direct_print.py (+299/-0)
report_aeroo_direct_print/report_aeroo_direct_print_view.xml (+158/-0)
report_aeroo_direct_print/security/ir.model.access.csv (+2/-0)
report_aeroo_direct_print/security/security_rules.xml (+14/-0)
report_aeroo_ooo/DocumentConverter.py (+221/-0)
report_aeroo_ooo/__init__.py (+80/-0)
report_aeroo_ooo/__openerp__.py (+64/-0)
report_aeroo_ooo/check_deps.py (+52/-0)
report_aeroo_ooo/data/report_aeroo_data.xml (+47/-0)
report_aeroo_ooo/installer.py (+165/-0)
report_aeroo_ooo/installer.xml (+72/-0)
report_aeroo_ooo/report.py (+95/-0)
report_aeroo_ooo/report_view.xml (+31/-0)
report_aeroo_ooo/tests/__init__.py (+4/-0)
report_aeroo_ooo/tests/test_service.py (+34/-0)
report_aeroo_printscreen/__init__.py (+32/-0)
report_aeroo_printscreen/__openerp__.py (+52/-0)
report_aeroo_printscreen/data/report_aeroo_printscreen_data.xml (+21/-0)
report_aeroo_printscreen/parser.py (+77/-0)
report_aeroo_printscreen/static/src/js/report_aeroo_printscreen.js (+41/-0)
report_aeroo_sample/__init__.py (+33/-0)
report_aeroo_sample/__openerp__.py (+48/-0)
report_aeroo_sample/report/__init__.py (+34/-0)
report_aeroo_sample/report/lorem.py (+1982/-0)
report_aeroo_sample/report/parser.py (+49/-0)
report_aeroo_sample/report/report_sample.xml (+30/-0)
Conflict adding file report_aeroo.  Moved existing file to report_aeroo.moved.
Conflict adding file report_aeroo_direct_print.  Moved existing file to report_aeroo_direct_print.moved.
Conflict adding file report_aeroo_ooo.  Moved existing file to report_aeroo_ooo.moved.
Conflict adding file report_aeroo_printscreen.  Moved existing file to report_aeroo_printscreen.moved.
Conflict adding file report_aeroo_sample.  Moved existing file to report_aeroo_sample.moved.
To merge this branch: bzr merge lp:~anybox/aeroo/fix-upgrade
Reviewer Review Type Date Requested Status
Christophe Combelles thorough ! Pending
Review via email: mp+214388@code.launchpad.net

This proposal has been superseded by a proposal from 2014-04-05.

Description of the change

To test, take any customer project using an earlier version of aeroo (no restart_ooo_cmd column in oo_config table), and perform an upgrade with the upgrade script provided by the recipe.

A quicker test is to check if the server starts *without -u report_aeroo_ooo*

Note that I am also tempted by fixing the bare excepts once the fix itself is more mature.

I'm asking ccomb, but any comments are welcome, and especially further tests by the Anybox team on customer projects.

To post a comment you must log in.
lp:~anybox/aeroo/fix-upgrade updated
38. By Georges Racinet <email address hidden>

Removed some bare excepts

This did not change the behaviour for me. But exception treatment is so
messy in aeroo that I could not see the warning in the except: block

I could see parts of the module that systematically wrap and reraise everything
as Exception

39. By Pierre Verkest

use exception message

40. By Pierre Verkest

[FIX]use Message instead message from uno exception

41. By Georges Racinet

[FIX] (temp) graceful instantiation of OOo service depended on bare except

put a big comment in check_deps indicating how a proper fix of this terrible
entanglement should look

Unmerged revisions

41. By Georges Racinet

[FIX] (temp) graceful instantiation of OOo service depended on bare except

put a big comment in check_deps indicating how a proper fix of this terrible
entanglement should look

40. By Pierre Verkest

[FIX]use Message instead message from uno exception

39. By Pierre Verkest

use exception message

38. By Georges Racinet <email address hidden>

Removed some bare excepts

This did not change the behaviour for me. But exception treatment is so
messy in aeroo that I could not see the warning in the except: block

I could see parts of the module that systematically wrap and reraise everything
as Exception

37. By Georges Racinet <email address hidden>

[FIX] made startup sequence more robust in upgrade situations

See explanations in OpenOffice_service docstring
This fixes in particular upgrades done with anybox.recipe.openerp's
standard upgrade scripts, which will act only after the database has been
loaded.

36. By fjouatte <email address hidden>

[FIX] Fix report visualization from openerp ui

35. By Mathieu Vatel - Julius Network Solutions

[FIX] - remove a cr.rollback() which leads to not computing parent_left parent_right in ir_ui_menu when OpenOfficeService is not working

34. By Mathieu Vatel - Julius Network Solutions

[IMP] simple code cleaning

33. By Mathieu Vatel - Julius Network Solutions

[FIX] - error on loading

32. By Mathieu Vatel - Julius Network Solutions

[IMP] - improve the last commit to get the last version of lp:aeroo

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'report_aeroo'
=== renamed directory 'report_aeroo' => 'report_aeroo.moved'
=== added file 'report_aeroo/ExtraFunctions.py'
--- report_aeroo/ExtraFunctions.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ExtraFunctions.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,664 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (c) 2009-2013 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
5# General contacts <info@alistek.com>
6#
7# WARNING: This program as such is intended to be used by professional
8# programmers who take the whole responsability of assessing all potential
9# consequences resulting from its eventual inadequacies and bugs
10# End users who are looking for a ready-to-use solution with commercial
11# garantees and support are strongly adviced to contract a Free Software
12# Service Company
13#
14# This program is Free Software; you can redistribute it and/or
15# modify it under the terms of the GNU General Public License
16# as published by the Free Software Foundation; either version 3
17# of the License, or (at your option) any later version.
18#
19# This module is GPLv3 or newer and incompatible
20# with OpenERP SA "AGPL + Private Use License"!
21#
22# This program is distributed in the hope that it will be useful,
23# but WITHOUT ANY WARRANTY; without even the implied warranty of
24# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25# GNU General Public License for more details.
26#
27# You should have received a copy of the GNU General Public License
28# along with this program; if not, write to the Free Software
29# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30#
31##############################################################################
32
33from .barcode import barcode
34from openerp.tools import translate
35#from .currency_to_text import currency_to_text
36from .ctt_objects import supported_language
37import logging
38_logger = logging.getLogger(__name__)
39import base64
40import StringIO
41try:
42 from PIL import Image
43except:
44 _logger.warning("ERROR IMPORTING PIL, if not installed, please install it:"
45 " get it here: https://pypi.python.org/pypi/PIL")
46from openerp import pooler
47import time
48from openerp.osv import orm
49from openerp.report import report_sxw
50from openerp.tools.translate import _
51from openerp import netsvc
52from openerp.tools.safe_eval import safe_eval as eval
53from aeroolib.plugins.opendocument import _filter
54
55try:
56 from docutils.examples import html_parts # use python-docutils library
57except ImportError, e:
58 _logger.warning("ERROR IMPORTING docutils, if not installed, please install it:"
59 " e.g.: apt-get install python-docutils")
60 rest_ok = False
61else:
62 rest_ok = True
63
64try:
65 import nltk
66except:
67 _logger.warning("ERROR IMPORTING nltk, if not installed, please install it:"
68 " e.g.: apt-get install python-nltk")
69
70try:
71 import markdown
72 from markdown import Markdown # use python-markdown library
73 from markdown.inlinepatterns import AutomailPattern
74
75 class AutomailPattern_mod (AutomailPattern, object):
76 def __init__(self, *args, **kwargs):
77 super(AutomailPattern_mod, self).__init__(*args, **kwargs)
78
79 def handleMatch(self, m):
80 el = super(AutomailPattern_mod, self).handleMatch(m)
81 href = ''.join([chr(int(a.replace(markdown.AMP_SUBSTITUTE+'#', ''))) for a in el.get('href').split(';') if a])
82 el.set('href', href)
83 return el
84
85 markdown.inlinepatterns.AutomailPattern = AutomailPattern_mod # easy hack for correct displaying in Joomla
86
87except ImportError, e:
88 markdown_ok = False
89 _logger.warning("ERROR IMPORTING markdown, if not installed, please install it:"
90 " e.g.: apt-get install python-markdown")
91else:
92 markdown_ok = True
93
94try:
95 from mediawiki import wiki2html # use python-mediawiki library
96except ImportError, e:
97 wikitext_ok = False
98else:
99 wikitext_ok = True
100
101from .domain_parser import domain2statement
102
103class ExtraFunctions(object):
104 """ This class contains some extra functions which
105 can be called from the report's template.
106 """
107 def __init__(self, cr, uid, report_id, context):
108 self.cr = cr
109 self.uid = uid
110 self.pool = pooler.get_pool(self.cr.dbname)
111 self.report_id = report_id
112 self.context = context
113 self.functions = {
114 'report_context': self.context,
115 'asarray':self._asarray,
116 'asimage':self._asimage,
117 'html_embed_image':self._embed_image,
118 'get_attachments':self._get_attachments,
119 'get_name':self._get_name,
120 'get_label':self._get_label,
121 'getLang':self._get_lang,
122 'get_selection_item':self._get_selection_items('item'),
123 'safe':self._get_safe,
124 'countif':self._countif,
125 'count':self._count,
126 'sumif':self._sumif,
127 'sum_field':self._sum,
128 'max_field':self._max,
129 'min_field':self._min,
130 'average':self._average,
131 'large':self._large,
132 'small':self._small,
133 'count_blank':self._count_blank,
134 '_':self._translate_text,
135 'gettext':self._translate_text,
136 'currency_to_text':self._currency2text(context['company'].currency_id.name), #self._currency2text(context['company'].currency_id.code),
137 'barcode':barcode.make_barcode,
138 'debugit':self.debugit,
139 'dec_to_time':self._dec2time,
140 'chunks':self._chunks,
141 'browse':self._browse,
142 'search':self._search,
143 'search_ids':self._search_ids,
144 'field_size':self._field_size,
145 'field_accuracy':self._field_accuracy,
146 'bool_as_icon':self._bool_as_icon,
147 'time':time,
148 'report_xml': self._get_report_xml(),
149 'get_log': self._perm_read(self.cr, self.uid),
150 'get_selection_items': self._get_selection_items(),
151 'itemize': self._itemize,
152 'html_escape': self._html_escape,
153 'html_remove': self._html_remove,
154 'http_prettyuri': self._http_prettyuri,
155 'http_builduri': self._http_builduri,
156 'text_markdown': markdown_ok and self._text_markdown or \
157 self._text_plain('"markdown" format is not supported! Need to be installed "python-markdown" package.'),
158 'text_restruct': rest_ok and self._text_restruct or \
159 self._text_plain('"reStructuredText" format is not supported! Need to be installed "python-docutils" package.'),
160 'text_wiki': wikitext_ok and self._text_wiki or \
161 self._text_plain('"wikimarkup" format is not supported! Need to be installed "python-mediawiki" package.'),
162 'text_markup': self._text_markup,
163 '__filter': self.__filter, # Don't use in the report template!
164 'specific_lang': self._specific_lang,
165 'sort_by':self._sort_by,
166 'group_by':self._group_by,
167 'invoice_lines': self._invoice_lines,
168 'location_name': self._location,
169 }
170
171 def __filter(self, val):
172 if isinstance(val, orm.browse_null):
173 return ''
174 elif isinstance(val, orm.browse_record):
175 return val.name_get({'lang':self._get_lang()})[0][1]
176 return _filter(val)
177
178 def _perm_read(self, cr, uid):
179 def get_log(obj, field=None):
180 if field:
181 return obj.perm_read(self.uid, [obj.id])[0][field]
182 else:
183 return obj.perm_read(self.uid, [obj.id])[0]
184 return get_log
185
186 def _get_report_xml(self):
187 return self.pool.get('ir.actions.report.xml').browse(self.cr, self.uid, self.report_id)
188
189 def _get_lang(self, source='current'):
190 if source=='current':
191 return self.context['lang'] or self.context['user_lang']
192 elif source=='company':
193 return self.context['user'].company_id.partner_id.lang
194 elif source=='user':
195 return self.context['user_lang']
196
197 def _bool_as_icon(self, val, kind=0):
198 if isinstance(kind, (list, tuple)):
199 if val==True:
200 return kind [0]
201 elif val==False:
202 return kind[1]
203 else:
204 return kind[2]
205 bool_kind = {0:{True:self._translate_text('True'), False:self._translate_text('False'), None:""},
206 1:{True:self._translate_text('T'), False:self._translate_text('F'), None:""},
207 2:{True:self._translate_text('Yes'), False:self._translate_text('No'), None:""},
208 3:{True:self._translate_text('Y'), False:self._translate_text('N'), None:""},
209 4:{True:'+', False:'-', None:""},
210 5:{True:'[ + ]', False:'[ - ]', None:"[ ]"},
211 6:{True:'[ x ]', False:'[ ]', None:"[ ]"},
212 7:{True:'x', False:'', None:""},
213 }
214 return bool_kind.get(kind, {}).get(val, val)
215
216 def _dec2time(self, dec, h_format, min_format):
217 if dec==0.0:
218 return None
219 elif int(dec)==0:
220 return min_format.replace('%M', str(int(round((dec-int(dec))*60))))
221 elif dec-int(dec)==0.0:
222 return h_format.replace('%H', str(int(dec)))
223 else:
224 return h_format.replace('%H', str(int(dec)))+min_format.replace('%M', str(int(round((dec-int(dec))*60))))
225
226 def _currency2text(self, currency):
227 def c_to_text(sum, currency=currency, language=None):
228 return unicode(supported_language.get(language or self._get_lang()).currency_to_text(sum, currency), "UTF-8")
229 return c_to_text
230
231 def _translate_text(self, source):
232 trans_obj = self.pool.get('ir.translation')
233 trans = trans_obj.search(self.cr,self.uid,[('res_id','=',self.report_id),('type','=','report'),('src','=',source),('lang','=',self.context['lang'] or self.context['user_lang'])])
234 if not trans:
235 #trans_obj.create(self.cr, self.uid, {'src':source,'type':'report','lang':self._get_lang(),'res_id':self.report_id,'name':('ir.actions.report.xml,%s' % source)[:128]})
236 trans_obj.create(self.cr, self.uid, {'src':source,'type':'report','lang':self._get_lang(),'res_id':self.report_id,'name':'ir.actions.report.xml'})
237 return translate(self.cr, 'ir.actions.report.xml', 'report', self._get_lang(), source) or source
238
239 def _countif(self, attr, domain):
240 statement = domain2statement(domain)
241 expr = "for o in objects:\n\tif%s:\n\t\tcount+=1" % statement
242 localspace = {'objects':attr, 'count':0}
243 exec expr in localspace
244 return localspace['count']
245
246 def _count_blank(self, attr, field):
247 expr = "for o in objects:\n\tif not o.%s:\n\t\tcount+=1" % field
248 localspace = {'objects':attr, 'count':0}
249 exec expr in localspace
250 return localspace['count']
251
252 def _count(self, attr):
253 return len(attr)
254
255 def _sumif(self, attr, sum_field, domain):
256 statement = domain2statement(domain)
257 expr = "for o in objects:\n\tif%s:\n\t\tsumm+=float(o.%s)" % (statement, sum_field)
258 localspace = {'objects':attr, 'summ':0}
259 exec expr in localspace
260 return localspace['summ']
261
262 def _sum(self, attr, sum_field):
263 expr = "for o in objects:\n\tsumm+=float(o.%s)" % sum_field
264 localspace = {'objects':attr, 'summ':0}
265 exec expr in localspace
266 return localspace['summ']
267
268 def _max(self, attr, field):
269 expr = "for o in objects:\n\tvalue_list.append(o.%s)" % field
270 localspace = {'objects':attr, 'value_list':[]}
271 exec expr in localspace
272 return max(localspace['value_list'])
273
274 def _min(self, attr, field):
275 expr = "for o in objects:\n\tvalue_list.append(o.%s)" % field
276 localspace = {'objects':attr, 'value_list':[]}
277 exec expr in localspace
278 return min(localspace['value_list'])
279
280 def _average(self, attr, field):
281 expr = "for o in objects:\n\tvalue_list.append(o.%s)" % field
282 localspace = {'objects':attr, 'value_list':[]}
283 exec expr in localspace
284 return float(sum(localspace['value_list']))/float(len(localspace['value_list']))
285
286 def _asarray(self, attr, field):
287 expr = "for o in objects:\n\tvalue_list.append(o.%s)" % field
288 localspace = {'objects':attr, 'value_list':[]}
289 exec expr in localspace
290 return localspace['value_list']
291
292 def _get_name(self, obj):
293 if obj.__class__== orm.browse_record:
294 return self.pool.get(obj._table_name).name_get(self.cr, self.uid, [obj.id], {'lang':self._get_lang()})[0][1]
295 elif type(obj)==str: # only for fields in root record
296 model = self.context['model']
297 field, rec_id = obj.split(',')
298 rec_id = int(rec_id)
299 if rec_id:
300 field_data = self.pool.get(model).fields_get(self.cr, self.uid, [field], context=self.context)
301 return self.pool.get(field_data[field]['relation']).name_get(self.cr, self.uid, [rec_id], {'lang':self._get_lang()})[0][1]
302 else:
303 return ''
304 return ''
305
306 def _get_label(self, obj, field):
307 if not obj:
308 return ''
309 try:
310 if isinstance(obj, report_sxw.browse_record_list):
311 obj = obj[0]
312 if isinstance(obj, (str,unicode)):
313 model = obj
314 else:
315 model = obj._table_name
316 if isinstance(obj, (str,unicode)) or hasattr(obj, field):
317 labels = self.pool.get(model).fields_get(self.cr, self.uid, allfields=[field], context=self.context)
318 return labels[field]['string']
319 except Exception, e:
320 return ''
321
322 def _field_size(self, obj, field):
323 try:
324 if isinstance(obj, report_sxw.browse_record_list):
325 obj = obj[0]
326 if isinstance(obj, (str,unicode)):
327 model = obj
328 else:
329 model = obj._table_name
330 if isinstance(obj, (str,unicode)) or hasattr(obj, field):
331 size = self.pool.get(model)._columns[field].size
332 return size
333 except Exception, e:
334 return ''
335
336 def _field_accuracy(self, obj, field):
337 try:
338 if isinstance(obj, report_sxw.browse_record_list):
339 obj = obj[0]
340 if isinstance(obj, (str,unicode)):
341 model = obj
342 else:
343 model = obj._table_name
344 if isinstance(obj, (str,unicode)) or hasattr(obj, field):
345 digits = self.pool.get(model)._columns[field].digits
346 return digits or [16,2]
347 except Exception:
348 return []
349
350 def _get_selection_items(self, kind='items'):
351 def get_selection_item(obj, field, value=None):
352 try:
353 if isinstance(obj, report_sxw.browse_record_list):
354 obj = obj[0]
355 if isinstance(obj, (str,unicode)):
356 model = obj
357 field_val = value
358 else:
359 model = obj._table_name
360 field_val = getattr(obj, field)
361 if kind=='item':
362 if field_val:
363 return dict(self.pool.get(model).fields_get(self.cr, self.uid, allfields=[field], context=self.context)[field]['selection'])[field_val]
364 elif kind=='items':
365 return self.pool.get(model).fields_get(self.cr, self.uid, allfields=[field], context=self.context)[field]['selection']
366 return ''
367 except Exception:
368 return ''
369 return get_selection_item
370
371 def _get_attachments(self, o, index=None, raw=False):
372 attach_obj = self.pool.get('ir.attachment')
373 srch_param = [('res_model','=',o._name),('res_id','=',o.id)]
374 if type(index)==str:
375 srch_param.append(('name','=',index))
376 attachments = attach_obj.search(self.cr,self.uid,srch_param)
377 res = [x['datas'] for x in attach_obj.read(self.cr,self.uid,attachments,['datas']) if x['datas']]
378 convert = raw and base64.decodestring or (lambda a: a)
379 if type(index)==int:
380 return convert(res[index])
381 return convert(len(res)==1 and res[0] or res)
382
383 def _asimage(self, field_value, rotate=None, size_x=None, size_y=None, uom='px', hold_ratio=False):
384 def size_by_uom(val, uom, dpi):
385 if uom=='px':
386 result=str(val/dpi)+'in'
387 elif uom=='cm':
388 result=str(val/2.54)+'in'
389 elif uom=='in':
390 result=str(val)+'in'
391 return result
392 ##############################################
393 if not field_value:
394 return StringIO.StringIO(), 'image/png'
395 field_value = base64.decodestring(field_value)
396 tf = StringIO.StringIO(field_value)
397 tf.seek(0)
398 try:
399 im=Image.open(tf)
400 format = im.format.lower()
401 dpi_x, dpi_y = map(float, im.info.get('dpi', (96, 96)))
402 except Exception, e:
403 raise orm.except_orm('Error', e)
404 try:
405 if rotate!=None:
406 im=im.rotate(int(rotate))
407 tf.seek(0)
408 im.save(tf, format)
409 except Exception, e:
410 raise orm.except_orm('Error', e)
411
412 if hold_ratio:
413 img_ratio = im.size[0] / float(im.size[1]) # width / height
414 if size_x and not size_y:
415 size_y = size_x / img_ratio
416 elif not size_x and size_y:
417 size_x = size_y * img_ratio
418 elif size_x and size_y:
419 size_y2 = size_x / img_ratio
420 size_x2 = size_y * img_ratio
421 if size_y2 > size_y:
422 size_x = size_x2
423 elif size_x2 > size_x:
424 size_y = size_y2
425
426 size_x = size_x and size_by_uom(size_x, uom, dpi_x) or str(im.size[0]/dpi_x)+'in'
427 size_y = size_y and size_by_uom(size_y, uom, dpi_y) or str(im.size[1]/dpi_y)+'in'
428 return tf, 'image/%s' % format, size_x, size_y
429
430 def _embed_image(self, extention, img, width=0, height=0, raw=False):
431 "Transform a DB image into an embeded HTML image"
432 if not img:
433 return ''
434 try:
435 if width :
436 width = ' width="%spx"'%(width)
437 else :
438 width = ''
439 if height :
440 height = 'height="%spx" '%(height)
441 else :
442 height = ''
443 if raw:
444 toreturn = 'data:image/%s;base64,%s' % (extention, ''.join(str(img).splitlines()))
445 else:
446 toreturn = '<img%s %ssrc="data:image/%s;base64,%s">' % (width, height, extention, str(img))
447 return toreturn
448 except Exception, exp:
449 return 'No image'
450
451 def _large(self, attr, field, n):
452 array=self._asarray(attr, field)
453 try:
454 n-=1
455 while(n):
456 array.remove(max(array))
457 n-=1
458 return max(array)
459 except ValueError, e:
460 return None
461
462 def _small(self, attr, field, n):
463 array=self._asarray(attr, field)
464 try:
465 n-=1
466 while(n):
467 array.remove(min(array))
468 n-=1
469 return min(array)
470 except ValueError, e:
471 return None
472
473 def _chunks(self, l, n):
474 """ Yield successive n-sized chunks from l.
475 """
476 for i in xrange(0, len(l), n):
477 yield l[i:i+n]
478
479 def _search_ids(self, model, domain):
480 obj = self.pool.get(model)
481 return obj.search(self.cr, self.uid, domain)
482
483 def _search(self, model, domain, context=None):
484 obj = self.pool.get(model)
485 ids = obj.search(self.cr, self.uid, domain)
486 if context is None:
487 context = {}
488 context['lang'] = self._get_lang()
489 return obj.browse(self.cr, self.uid, ids, context=context)
490
491 def _browse(self, *args):
492 if not args or (args and not args[0]):
493 return None
494 if len(args)==1:
495 model, id = args[0].split(',')
496 id = int(id)
497 elif len(args)==2:
498 model, id = args
499 else:
500 raise None
501 return self.pool.get(model).browse(self.cr, self.uid, id)
502
503 def _get_safe(self, expression, obj):
504 try:
505 return eval(expression, {'o':obj})
506 except Exception, e:
507 return None
508
509 def debugit(self, object):
510 """ Run the server from command line and
511 call 'debugit' from the template to inspect variables.
512 """
513 import pdb;pdb.set_trace()
514 return
515
516 def _itemize(self, array, purefalse = False, base_num = 1):
517 it = iter(array)
518 falseval = purefalse and False or ''
519 e = it.next()
520 lind = 0
521 while True:
522 lind += 1
523 is_even = lind%2 == 0 or falseval
524 is_odd = not is_even or falseval
525 is_first = lind == 1 or falseval
526 try:
527 nxt = it.next()
528 yield (lind-1, lind+base_num-1, e, is_even, is_odd, is_first, falseval)
529 e = nxt
530 except StopIteration:
531 yield (lind-1, lind+base_num-1, e, is_even, is_odd, is_first, True)
532 break
533
534 def _html_escape(self, s):
535 toesc={ '<': '&lt;',
536 '>': '&gt;',
537 '&': '&amp;',
538 '"': '&quot;',
539 "'": '&apos;' }
540
541 if type(s) is str:
542 s.decode()
543 try:
544 return ''.join(map(lambda a: toesc.get(a, a), s))
545 except TypeError:
546 return s
547
548 def _html_remove(self, s):
549 def replace_specifics(s):
550 list_to_change = {
551 '&lt;': '<',
552 '&gt;': '>',
553 '&amp;': '&' ,
554 '&quot;': '"',
555 '&apos;': "'"
556 }
557 for key1 in list_to_change.keys():
558 s = s.replace(key1, list_to_change[key1])
559 return s
560 try:
561 return replace_specifics(nltk.clean_html(s))
562 except Exception, e:
563 raise orm.except_orm('Error', e)
564
565 def _http_prettyuri(self, s):
566 def do_filter(c):
567 # filter out reserved and "unsafe" characters
568 pos = '''<>$&+,/\:;=?@'"#%{}|^~[]()`'''.find(c)
569 if pos >= 0: return False
570
571 # filter out ASCII Control characters and unhandled Non-ASCII characters
572 ordc = ord(c)
573 if (ordc >= 0 and ordc <= 31) or (ordc >= 127 and ordc <= 255): return False
574 return c
575
576 if type(s) is str: s.decode()
577 # tranlate specific latvian characters into latin and whitespace into dash
578 tt = dict(zip(map(ord, 'āčēģīķļņōŗšūžĀČĒĢĪĶĻŅŌŖŠŪŽ '.decode()), 'acegiklnorsuzACEGIKLNORSUZ-'.decode()))
579 try:
580 s = s.translate(tt)
581 return (filter(do_filter, s)).lower()
582 except TypeError:
583 return s
584
585 def _http_builduri(self, *dicts):
586 d = {}
587 for ind in dicts:
588 d.update(ind)
589 result = ''
590 for pair in d.iteritems():
591 result += '&%s=%s' % pair
592 return result
593
594 def _text_restruct(self, text):
595 output = html_parts(unicode(text), doctitle=False)
596 return output['body']
597
598 def _text_markdown(self, text):
599 md = Markdown()
600 return md.convert(text)
601
602 def _text_wiki(self, text):
603 return wiki2html(text, True)
604
605 def _text_plain(self, msg):
606 def text_plain(text):
607 _logger.info(msg)
608 return text
609 return text_plain
610
611 def _text_markup(self, text):
612 lines = text.splitlines()
613 first_line = lines.pop(0)
614 if first_line=='text/x-markdown':
615 return self._text_markdown('\n'.join(lines))
616 elif first_line=='text/x-wiki':
617 return self._text_wiki('\n'.join(lines))
618 elif first_line=='text/x-rst':
619 return self._text_rest('\n'.join(lines))
620 return text
621
622 def _specific_lang(self, model, id, lang=False):
623 context = self.context
624 context['lang'] = lang or self._get_lang()
625 obj = self.pool.get(model)
626 return obj.browse(self.cr, self.uid, id, context=context)
627
628 def _invoice_lines(self, lines):
629 result = []
630 res = {}
631 for entry in lines:
632 flag = False
633 for res in result:
634 if entry.product_id == res.product_id and entry.price_unit == res.price_unit \
635 and entry.invoice_line_tax_id == res.invoice_line_tax_id and entry.discount == res.discount:
636 res.quantity += entry.quantity
637 res.price_subtotal += entry.price_subtotal
638 flag = True
639 if flag == False:
640 result.append(entry)
641 return result
642
643 def _location(self):
644 if self.context is None:
645 self.context = {}
646 location_name = ''
647 if self.context.get('location'):
648 location_name = self.pool.get('stock.location').read(self.cr, self.uid,
649 self.context.get('location'), ['name'], context = self.context)['name']
650 return location_name
651
652 def _sort_by(self, attr, field):
653 expr = "for o in objects:\n\tdict_vals[o] = o.%s or ''" % field
654 localspace = {'objects':attr, 'dict_vals':{}}
655 exec expr in localspace
656 return [o for o, val in sorted(localspace['dict_vals'].items(), key=lambda x: x[1])]
657
658 def _group_by(self, attr, field):
659 expr = "for o in objects:\n\tdict_vals.setdefault(o.%s or '', [])\n\tdict_vals[o.%s or ''].append(o)" % (field, field)
660 localspace = {'objects':attr, 'dict_vals':{}}
661 exec expr in localspace
662 return sorted(localspace['dict_vals'].items(), key=lambda x: x[0])
663
664# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0665
=== added file 'report_aeroo/__init__.py'
--- report_aeroo/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,52 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (c) 2009-2012 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
5# General contacts <info@alistek.com>
6#
7# WARNING: This program as such is intended to be used by professional
8# programmers who take the whole responsability of assessing all potential
9# consequences resulting from its eventual inadequacies and bugs
10# End users who are looking for a ready-to-use solution with commercial
11# garantees and support are strongly adviced to contract a Free Software
12# Service Company
13#
14# This program is Free Software; you can redistribute it and/or
15# modify it under the terms of the GNU General Public License
16# as published by the Free Software Foundation; either version 3
17# of the License, or (at your option) any later version.
18#
19# This module is GPLv3 or newer and incompatible
20# with OpenERP SA "AGPL + Private Use License"!
21#
22# This program is distributed in the hope that it will be useful,
23# but WITHOUT ANY WARRANTY; without even the implied warranty of
24# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25# GNU General Public License for more details.
26#
27# You should have received a copy of the GNU General Public License
28# along with this program; if not, write to the Free Software
29# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30#
31##############################################################################
32
33import aeroolib
34from genshi.template import NewTextTemplate
35
36check_list = [
37 'import aeroolib',
38 'import genshi',
39 'from genshi.template import NewTextTemplate',
40 'from xml.dom import minidom',
41]
42
43from check_deps import check_deps
44check_deps(check_list)
45
46import installer
47import translate
48import report_xml
49import report_aeroo
50import wizard
51
52# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
053
=== added file 'report_aeroo/__openerp__.py'
--- report_aeroo/__openerp__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/__openerp__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,82 @@
1# -*- coding: utf-8 -*-
2########################################################################
3#
4# Copyright (C) 2009 Domsense s.r.l.
5# @authors: Simone Orsi
6# Copyright (C) 2009-2013 Alistek Ltd
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 module is GPLv3 or newer and incompatible
14# with OpenERP SA "AGPL + Private Use License"!
15#
16#This program is distributed in the hope that it will be useful,
17#but WITHOUT ANY WARRANTY; without even the implied warranty of
18#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19#GNU General Public License for more details.
20#
21#You should have received a copy of the GNU General Public License
22#along with this program. If not, see <http://www.gnu.org/licenses/>.
23########################################################################
24
25{
26 'name': 'Aeroo Reports',
27 'version': '1.2',
28 'category': 'Generic Modules/Aeroo Reporting',
29 'description': """
30Aeroo Reports for OpenERP is a comprehensive reporting engine based on Aeroo Library.
31
32Report templates can be created directly in of following formats:
33=================================================================
34* Open Document Format (ODF) - .odt, .ods;
35* Other ASCII based formats, like HTML, CSV, etc.
36
37Output formats:
38=================================================================
39* Open Document Format (ODF) - .odt, .ods;
40* Other ASCII based formats, like HTML, CSV, etc.
41* with report_aeroo_ooo [1] module - PDF, DOC, XLS, CSV.
42
43Reporting engine features:
44=================================================================
45* Add reports from UI "on the fly";
46* Install reports from module;
47* Dynamic template load/unload;
48* Extra Functions - set of functions for rapid template development;
49* Use templates stored on filesystem, database or elsewhere;
50* Same button - different templates;
51* Powerful stylesheet system for ODF templates;
52* Global or local stylesheets;
53* Template preloading for performance concerns;
54* User defined parsers;
55* Report deactivation;
56* Tunable format fallback;
57* Add/Remove print button wizards;
58* Test report on particular object ID, directly from Report form;
59* Translatable reports;
60* Translation export;
61* Number of copies;
62* Universal Report wizard;
63* Override report file extension (for direct printing, etc);
64* Separate input/output format selections;
65
66[1] For more information on available template -> output pairs and other features, see description of report_aeroo_ooo module.
67
68=> You need to install python-nltk on your machine
69""",
70 'author': 'Alistek Ltd, Simone Orsi - Domsense',
71 'website': 'http://www.alistek.com',
72 'complexity': "easy",
73 'depends': ['base'],
74 "init_xml" : [],
75 'update_xml': ["installer.xml", "report_view.xml", "data/report_aeroo_data.xml", "wizard/add_print_button_view.xml", "wizard/remove_print_button_view.xml", "security/ir.model.access.csv"],
76 "license" : "GPL-3 or any later version",
77 'installable': True,
78 'active': False,
79 'application': True,
80}
81
82# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
083
=== added directory 'report_aeroo/barcode'
=== added file 'report_aeroo/barcode/EANBarCode.py'
--- report_aeroo/barcode/EANBarCode.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/barcode/EANBarCode.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,159 @@
1# Copyright (c) 2009-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
2# General contacts <info@alistek.com>
3
4from openerp.tools import config, ustr
5fontsize = 15
6
7"""
8This class generate EAN bar code, it required PIL (python imaging library)
9installed.
10
11If the code has not checksum (12 digits), it added automatically.
12
13Create bar code sample :
14 from EANBarCode import EanBarCode
15 bar = EanBarCode()
16 bar.getImage("9782212110708",50,"gif")
17
18"""
19
20class EanBarCode:
21 """ Compute the EAN bar code """
22 def __init__(self):
23 A = {0 : "0001101", 1 : "0011001", 2 : "0010011", 3 : "0111101", 4 : "0100011",
24 5 : "0110001", 6 : "0101111", 7 : "0111011", 8 : "0110111", 9 : "0001011"}
25 B = {0 : "0100111", 1 : "0110011", 2 : "0011011", 3 : "0100001", 4 : "0011101",
26 5 : "0111001", 6 : "0000101", 7 : "0010001", 8 : "0001001", 9 : "0010111"}
27 C = {0 : "1110010", 1 : "1100110", 2 : "1101100", 3 : "1000010", 4 : "1011100",
28 5 : "1001110", 6 : "1010000", 7 : "1000100", 8 : "1001000", 9 : "1110100"}
29 self.groupC = C
30
31 self.family = {0 : (A,A,A,A,A,A), 1 : (A,A,B,A,B,B), 2 : (A,A,B,B,A,B), 3 : (A,A,B,B,B,A), 4 : (A,B,A,A,B,B),
32 5 : (A,B,B,A,A,B), 6 : (A,B,B,B,A,A), 7 : (A,B,A,B,A,B), 8 : (A,B,A,B,B,A), 9 : (A,B,B,A,B,A)}
33
34
35 def makeCode(self, code):
36 """ Create the binary code
37 return a string which contains "0" for white bar, "1" for black bar, "L" for long bar """
38
39 # Convert code string in integer list
40 self.EAN13 = []
41 for digit in code:
42 self.EAN13.append(int(digit))
43
44 # If the code has already a checksum
45 if len(self.EAN13) == 13:
46 # Verify checksum
47 self.verifyChecksum(self.EAN13)
48 # If the code has not yet checksum
49 elif len(self.EAN13) == 12:
50 # Add checksum value
51 self.EAN13.append(self.computeChecksum(self.EAN13))
52
53 # Get the left codage class
54 left = self.family[self.EAN13[0]]
55
56 # Add start separator
57 strCode = 'L0L'
58
59 # Compute the left part of bar code
60 for i in range(0,6):
61 strCode += left[i][self.EAN13[i+1]]
62
63 # Add middle separator
64 strCode += '0L0L0'
65
66 # Compute the right codage class
67 for i in range (7,13):
68 strCode += self.groupC[self.EAN13[i]]
69
70 # Add stop separator
71 strCode += 'L0L'
72
73 return strCode
74
75
76 def computeChecksum(self, arg):
77 """ Compute the checksum of bar code """
78 # UPCA/EAN13
79 weight=[1,3]*6
80 magic=10
81 sum = 0
82
83 for i in range(12): # checksum based on first 12 digits.
84 sum = sum + int(arg[i]) * weight[i]
85 z = ( magic - (sum % magic) ) % magic
86 if z < 0 or z >= magic:
87 return None
88 return z
89
90
91 def verifyChecksum(self, bits):
92 """ Verify the checksum """
93 computedChecksum = self.computeChecksum(bits[:12])
94 codeBarChecksum = bits[12]
95
96 if codeBarChecksum != computedChecksum:
97 raise Exception ("Bad checksum is %s and should be %s"%(codeBarChecksum, computedChecksum))
98
99
100 def getImage(self, value, height = 50, xw=1, rotate=None, extension = "PNG"):
101 """ Get an image with PIL library
102 value code barre value
103 height height in pixel of the bar code
104 extension image file extension"""
105 from PIL import Image, ImageFont, ImageDraw
106 import os
107 from string import lower, upper
108
109 # Get the bar code list
110 bits = self.makeCode(value)
111
112 # Get thee bar code with the checksum added
113 code = ""
114 for digit in self.EAN13:
115 code += "%d"%digit
116
117 # Create a new image
118 position = 8
119 im = Image.new("1",(len(bits)+position,height))
120
121 # Load font
122 ad = os.path.abspath(os.path.join(ustr(config['root_path']), u'addons'))
123 mod_path_list = map(lambda m: os.path.abspath(ustr(m.strip())), config['addons_path'].split(','))
124 mod_path_list.append(ad)
125
126 for mod_path in mod_path_list:
127 font_file = mod_path+os.path.sep+ \
128 "report_aeroo"+os.path.sep+"barcode"+os.path.sep+"FreeMonoBold.ttf"
129 if os.path.lexists(font_file):
130 font = ImageFont.truetype(font_file, fontsize)
131
132 # Create drawer
133 draw = ImageDraw.Draw(im)
134
135 # Erase image
136 draw.rectangle(((0,0),(im.size[0],im.size[1])),fill=256)
137
138 # Draw first part of number
139 draw.text((0, height-9), code[0], font=font, fill=0)
140
141 # Draw first part of number
142 draw.text((position+7, height-9), code[1:7], font=font, fill=0)
143
144 # Draw second part of number
145 draw.text((len(bits)/2+6+position, height-9), code[7:], font=font, fill=0)
146
147 # Draw the bar codes
148 for bit in range(len(bits)):
149 # Draw normal bar
150 if bits[bit] == '1':
151 draw.rectangle(((bit+position,0),(bit+position,height-10)),fill=0)
152 # Draw long bar
153 elif bits[bit] == 'L':
154 draw.rectangle(((bit+position,0),(bit+position,height-3)),fill=0)
155
156 # Save the result image
157 return im
158
159# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0160
=== added file 'report_aeroo/barcode/FreeMonoBold.ttf'
1Binary files report_aeroo/barcode/FreeMonoBold.ttf 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/FreeMonoBold.ttf 2014-04-05 13:18:49 +0000 differ161Binary files report_aeroo/barcode/FreeMonoBold.ttf 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/FreeMonoBold.ttf 2014-04-05 13:18:49 +0000 differ
=== added file 'report_aeroo/barcode/__init__.py'
--- report_aeroo/barcode/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/barcode/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,34 @@
1##############################################################################
2#
3# Copyright (c) 2008-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
4# General contacts <info@alistek.com>
5#
6# WARNING: This program as such is intended to be used by professional
7# programmers who take the whole responsability of assessing all potential
8# consequences resulting from its eventual inadequacies and bugs
9# End users who are looking for a ready-to-use solution with commercial
10# garantees and support are strongly adviced to contract a Free Software
11# Service Company
12#
13# This program is Free Software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation; either version 3
16# of the License, or (at your option) any later version.
17#
18# This module is GPLv3 or newer and incompatible
19# with OpenERP SA "AGPL + Private Use License"!
20#
21# This program is distributed in the hope that it will be useful,
22# but WITHOUT ANY WARRANTY; without even the implied warranty of
23# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24# GNU General Public License for more details.
25#
26# You should have received a copy of the GNU General Public License
27# along with this program; if not, write to the Free Software
28# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29#
30##############################################################################
31
32import barcode
33
34# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
035
=== added file 'report_aeroo/barcode/barcode.py'
--- report_aeroo/barcode/barcode.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/barcode/barcode.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,63 @@
1##############################################################################
2#
3# Copyright (c) 2008-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
4# General contacts <info@alistek.com>
5#
6# WARNING: This program as such is intended to be used by professional
7# programmers who take the whole responsability of assessing all potential
8# consequences resulting from its eventual inadequacies and bugs
9# End users who are looking for a ready-to-use solution with commercial
10# garantees and support are strongly adviced to contract a Free Software
11# Service Company
12#
13# This program is Free Software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation; either version 3
16# of the License, or (at your option) any later version.
17#
18# This module is GPLv3 or newer and incompatible
19# with OpenERP SA "AGPL + Private Use License"!
20#
21# This program is distributed in the hope that it will be useful,
22# but WITHOUT ANY WARRANTY; without even the implied warranty of
23# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24# GNU General Public License for more details.
25#
26# You should have received a copy of the GNU General Public License
27# along with this program; if not, write to the Free Software
28# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29#
30##############################################################################
31
32from .code128 import get_code
33from .code39 import create_c39
34from .EANBarCode import EanBarCode
35try:
36 from cStringIO import StringIO
37except ImportError:
38 from StringIO import StringIO
39
40def make_barcode(code, code_type='ean13', rotate=None, height=50, xw=1):
41 if code:
42 if code_type.lower()=='ean13':
43 bar=EanBarCode()
44 im = bar.getImage(code,height)
45 elif code_type.lower()=='code128':
46 im = get_code(code, xw, height)
47 elif code_type.lower()=='code39':
48 im = create_c39(height, xw, code)
49 else:
50 return StringIO(), 'image/png'
51
52 tf = StringIO()
53 try:
54 if rotate!=None:
55 im=im.rotate(int(rotate))
56 except Exception, e:
57 pass
58 im.save(tf, 'png')
59 size_x = str(im.size[0]/96.0)+'in'
60 size_y = str(im.size[1]/96.0)+'in'
61 return tf, 'image/png', size_x, size_y
62
63# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
064
=== added file 'report_aeroo/barcode/code128.py'
--- report_aeroo/barcode/code128.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/barcode/code128.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,189 @@
1# Copyright (c) 2009-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
2# General contacts <info@alistek.com>
3# This list was cut'n'pasted verbatim from the "Code 128 Specification Page"
4# at http://www.adams1.com/pub/russadam/128code.html
5
6codelist="""0 SP SP 00 2 1 2 2 2 2
71 ! ! 01 2 2 2 1 2 2
82 " " 02 2 2 2 2 2 1
93 # # 03 1 2 1 2 2 3
104 $ $ 04 1 2 1 3 2 2
115 % % 05 1 3 1 2 2 2
126 & & 06 1 2 2 2 1 3
137 ' ' 07 1 2 2 3 1 2
148 ( ( 08 1 3 2 2 1 2
159 ) ) 09 2 2 1 2 1 3
1610 * * 10 2 2 1 3 1 2
1711 + + 11 2 3 1 2 1 2
1812 , , 12 1 1 2 2 3 2
1913 - - 13 1 2 2 1 3 2
2014 . . 14 1 2 2 2 3 1
2115 / / 15 1 1 3 2 2 2
2216 0 0 16 1 2 3 1 2 2
2317 1 1 17 1 2 3 2 2 1
2418 2 2 18 2 2 3 2 1 1
2519 3 3 19 2 2 1 1 3 2
2620 4 4 20 2 2 1 2 3 1
2721 5 5 21 2 1 3 2 1 2
2822 6 6 22 2 2 3 1 1 2
2923 7 7 23 3 1 2 1 3 1
3024 8 8 24 3 1 1 2 2 2
3125 9 9 25 3 2 1 1 2 2
3226 : : 26 3 2 1 2 2 1
3327 ; ; 27 3 1 2 2 1 2
3428 < < 28 3 2 2 1 1 2
3529 = = 29 3 2 2 2 1 1
3630 > > 30 2 1 2 1 2 3
3731 ? ? 31 2 1 2 3 2 1
3832 @ @ 32 2 3 2 1 2 1
3933 A A 33 1 1 1 3 2 3
4034 B B 34 1 3 1 1 2 3
4135 C C 35 1 3 1 3 2 1
4236 D D 36 1 1 2 3 1 3
4337 E E 37 1 3 2 1 1 3
4438 F F 38 1 3 2 3 1 1
4539 G G 39 2 1 1 3 1 3
4640 H H 40 2 3 1 1 1 3
4741 I I 41 2 3 1 3 1 1
4842 J J 42 1 1 2 1 3 3
4943 K K 43 1 1 2 3 3 1
5044 L L 44 1 3 2 1 3 1
5145 M M 45 1 1 3 1 2 3
5246 N N 46 1 1 3 3 2 1
5347 O O 47 1 3 3 1 2 1
5448 P P 48 3 1 3 1 2 1
5549 Q Q 49 2 1 1 3 3 1
5650 R R 50 2 3 1 1 3 1
5751 S S 51 2 1 3 1 1 3
5852 T T 52 2 1 3 3 1 1
5953 U U 53 2 1 3 1 3 1
6054 V V 54 3 1 1 1 2 3
6155 W W 55 3 1 1 3 2 1
6256 X X 56 3 3 1 1 2 1
6357 Y Y 57 3 1 2 1 1 3
6458 Z Z 58 3 1 2 3 1 1
6559 [ [ 59 3 3 2 1 1 1
6660 \\ \\ 60 3 1 4 1 1 1
6761 ] ] 61 2 2 1 4 1 1
6862 ^ ^ 62 4 3 1 1 1 1
6963 _ _ 63 1 1 1 2 2 4
7064 NUL ' 64 1 1 1 4 2 2
7165 SOH a 65 1 2 1 1 2 4
7266 STX b 66 1 2 1 4 2 1
7367 ETX c 67 1 4 1 1 2 2
7468 EOT d 68 1 4 1 2 2 1
7569 ENQ e 69 1 1 2 2 1 4
7670 ACK f 70 1 1 2 4 1 2
7771 BEL g 61 1 2 2 1 1 4
7872 BS h 72 1 2 2 4 1 1
7973 HT i 73 1 4 2 1 1 2
8074 LF j 74 1 4 2 2 1 1
8175 VT k 75 2 4 1 2 1 1
8276 FF l 76 2 2 1 1 1 4
8377 CR m 77 4 1 3 1 1 1
8478 SO n 78 2 4 1 1 1 2
8579 SI o 79 1 3 4 1 1 1
8680 DLE p 80 1 1 1 2 4 2
8781 DC1 q 81 1 2 1 1 4 2
8882 DC2 r 82 1 2 1 2 4 1
8983 DC3 s 83 1 1 4 2 1 2
9084 DC4 t 84 1 2 4 1 1 2
9185 NAK u 85 1 2 4 2 1 1
9286 SYN v 86 4 1 1 2 1 2
9387 ETB w 87 4 2 1 1 1 2
9488 CAN x 88 4 2 1 2 1 1
9589 EM y 89 2 1 2 1 4 1
9690 SUB z 90 2 1 4 1 2 1
9791 ESC { 91 4 1 2 1 2 1
9892 FS | 92 1 1 1 1 4 3
9993 GS } 93 1 1 1 3 4 1
10094 RS ~ 94 1 3 1 1 4 1
10195 (Hex 7F) US DEL 95 1 1 4 1 1 3
10296 (Hex 80) FNC 3 FNC 3 96 1 1 4 3 1 1
10397 (Hex 81) FNC 2 FNC 2 97 4 1 1 1 1 3
10498 (Hex 82) SHIFT SHIFT 98 4 1 1 3 1 1
10599 (Hex 83) CODE C CODE C 99 1 1 3 1 4 1
106100 (Hex 84) CODE B FNC 4 CODE B 1 1 4 1 3 1
107101 (Hex 85) FNC 4 CODE A CODE A 3 1 1 1 4 1
108102 (Hex 86) FNC 1 FNC 1 FNC 1 4 1 1 1 3 1"""
109
110
111
112
113other="""103 (Hex 87) START (Code A) 2 1 1 4 1 2
114104 (Hex 88) START (Code B) 2 1 1 2 1 4
115105 (Hex 89) START (Code C) 2 1 1 2 3 2
116106 STOP 2 3 3 1 1 1 2"""
117
118
119codes={}
120values={}
121for l in codelist.split('\n'):
122 l.strip()
123 num,a1,b1,c1,code=l.split('\t')
124 num=int(num.split(' ')[0])
125 values[num]=[int(x) for x in code.split()]
126 codes[b1.strip()]=num
127
128codes[' ']=codes['SP']
129
130for l in other.split('\n'):
131 l.strip()
132 num,name,code=l.split('\t')
133 num=int(num.split(' ')[0])
134 values[num]=[int(x) for x in code.split()]
135 codes[name.strip()]=num
136
137def encode_message(msg):
138 startnum=codes['START (Code B)']
139 message=values[startnum][:]
140 chksum=startnum
141 mult=1
142 for c in msg:
143 if not codes.has_key(c):
144 raise "No code for "+c
145 chksum=chksum+mult*codes[c]
146 mult=mult+1
147 message=message+values[codes[c]]
148
149 chksum=chksum%103
150
151 message=message+values[chksum]
152 message=message+values[codes['STOP']]
153
154 return message
155
156
157import os
158try:
159 from PIL import Image
160except:
161 _logger.warning("ERROR IMPORTING PIL, if not installed, please install it:"
162 " get it here: https://pypi.python.org/pypi/PIL")
163def get_code(message,xw=1,h=100,rotate=None):
164 """ message is message to code.
165 xw is horizontal multiplier (in pixels width of narrowest bar)
166 h is height in pixels.
167
168 Returns a Python Imaging Library object."""
169
170 widths=[xw*20]+encode_message(message)+[xw*20]
171
172 bits=[]
173 i=1
174 for w in widths:
175 bits=bits+[i]*w*xw
176 i=1-i
177
178 #print len(bits)
179 #print bits
180
181 i=Image.new('1',(len(bits),h),1)
182
183 for b in range(len(bits)):
184 for y in range(h):
185 i.putpixel((b,y),255*bits[b])
186
187 return i
188
189# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0190
=== added file 'report_aeroo/barcode/code39.py'
--- report_aeroo/barcode/code39.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/barcode/code39.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,166 @@
1# Copyright (c) 2008 marscel.wordpress.com
2#
3# Copyright (c) 2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
4# General contacts <info@alistek.com>
5
6# Code39.py v1
7# Requires Python and Python Imaging Library (PIL),
8# has been tested with Python v2.6 and PIL v1.1.6
9
10# Usage example:
11# code39.py 100 2 "Hello World" barcode.png
12#
13# This creates a PNG image "barcode.png" containing a barcode of the height of 100px
14# a min line width of 2px with "Hello World" encoded as "*HELLO WORLD*" in Code 39
15try:
16 from PIL import Image, ImageDraw, ImageFont
17except:
18 _logger.warning("ERROR IMPORTING PIL, if not installed, please install it:"
19 " get it here: https://pypi.python.org/pypi/PIL")
20from openerp.tools import config, ustr
21import os, sys
22
23marginx = 10
24marginy = 10
25fontsize = 15
26
27charmap = {
28'*':[0,3,0,1,2,1,2,1,0],
29'-':[0,3,0,1,0,1,2,1,2],
30'$':[0,3,0,3,0,3,0,1,0],
31'%':[0,1,0,3,0,3,0,3,0],
32' ':[0,3,2,1,0,1,2,1,0],
33'.':[2,3,0,1,0,1,2,1,0],
34'/':[0,3,0,3,0,1,0,3,0],
35'+':[0,3,0,1,0,3,0,3,0],
36'0':[0,1,0,3,2,1,2,1,0],
37'1':[2,1,0,3,0,1,0,1,2],
38'2':[0,1,2,3,0,1,0,1,2],
39'3':[2,1,2,3,0,1,0,1,0],
40'4':[0,1,0,3,2,1,0,1,2],
41'5':[2,1,0,3,2,1,0,1,0],
42'6':[0,1,2,3,2,1,0,1,0],
43'7':[0,1,0,3,0,1,2,1,2],
44'8':[2,1,0,3,0,1,2,1,0],
45'9':[0,1,2,3,0,1,2,1,0],
46'A':[2,1,0,1,0,3,0,1,2],
47'B':[0,1,2,1,0,3,0,1,2],
48'C':[2,1,2,1,0,3,0,1,0],
49'D':[0,1,0,1,2,3,0,1,2],
50'E':[2,1,0,1,2,3,0,1,0],
51'F':[0,1,2,1,2,3,0,1,0],
52'G':[0,1,0,1,0,3,2,1,2],
53'H':[2,1,0,1,0,3,2,1,0],
54'I':[0,1,2,1,0,3,2,1,0],
55'J':[0,1,0,1,2,3,2,1,0],
56'K':[2,1,0,1,0,1,0,3,2],
57'L':[0,1,2,1,0,1,0,3,2],
58'M':[2,1,2,1,0,1,0,3,0],
59'N':[0,1,0,1,2,1,0,3,2],
60'O':[2,1,0,1,2,1,0,3,0],
61'P':[0,1,2,1,2,1,0,3,0],
62'Q':[0,1,0,1,0,1,2,3,2],
63'R':[2,1,0,1,0,1,2,3,0],
64'S':[0,1,2,1,0,1,2,3,0],
65'T':[0,1,0,1,2,1,2,3,0],
66'U':[2,3,0,1,0,1,0,1,2],
67'V':[0,3,2,1,0,1,0,1,2],
68'W':[2,3,2,1,0,1,0,1,0],
69'X':[0,3,0,1,2,1,0,1,2],
70'Y':[2,3,0,1,2,1,0,1,0],
71'Z':[0,3,2,1,2,1,0,1,0]
72}
73
74def create_c39(height, smallest, text):
75 pixel_length = 0
76 i = 0
77 newtext = ""
78 machinetext = "*" + text + "*"
79 seglist = []
80 while i < len(machinetext):
81 char = machinetext[i].capitalize()
82 i = i + 1
83 try:
84 cmap = charmap[char]
85 if len(cmap) != 9:
86 continue
87
88 j = 0
89 while j < 9:
90 seg = int(cmap[j])
91
92 if seg == 0 or seg == 1:
93 pixel_length = pixel_length + smallest
94 seglist.append(seg)
95 elif seg == 2 or seg == 3:
96 pixel_length = pixel_length + smallest * 3
97 seglist.append(seg)
98
99 j = j + 1
100
101 newtext += char
102 except:
103 continue
104
105 pixel_length = pixel_length + 2*marginx + len(newtext) * smallest
106 pixel_height = height + 2*marginy + fontsize
107
108 barcode_img = Image.new('RGB', [pixel_length, pixel_height], "white")
109
110 if len(seglist) == 0:
111 return barcode_img
112
113 i = 0
114 draw = ImageDraw.Draw(barcode_img)
115 current_x = marginx
116
117 while i < len(seglist):
118 seg = seglist[i]
119 color = (255, 255, 255)
120 wdth = smallest
121
122 if seg == 0 or seg == 2:
123 color = 0
124 if seg == 0:
125 wdth = smallest
126 else:
127 wdth = smallest * 3
128 elif seg == 1 or seg == 3:
129 color = (255, 255, 255)
130 if seg == 1:
131 wdth = smallest
132 else:
133 wdth = smallest * 3
134
135 j = 1
136
137 while j <= wdth:
138 draw.line((current_x, marginy, current_x, marginy+height), fill=color)
139 current_x = current_x + 1
140 j = j + 1
141
142 if ((i+1) % 9) == 0:
143 j = 1
144 while j <= smallest:
145 draw.line((current_x, marginy, current_x, marginy+height), fill=(255,255,255))
146 current_x = current_x + 1
147 j = j + 1
148 i = i + 1
149
150 ad = os.path.abspath(os.path.join(ustr(config['root_path']), u'addons'))
151 mod_path_list = map(lambda m: os.path.abspath(ustr(m.strip())), config['addons_path'].split(','))
152 mod_path_list.append(ad)
153
154 for mod_path in mod_path_list:
155 font_file = mod_path+os.path.sep+ \
156 "report_aeroo"+os.path.sep+"barcode"+os.path.sep+"FreeMonoBold.ttf"
157 if os.path.lexists(font_file):
158 font = ImageFont.truetype(font_file, fontsize)
159
160 draw.text((pixel_length/2 - len(newtext)*(fontsize/2)/2-len(newtext), height+fontsize), newtext, font=font, fill=0)
161
162 del draw
163
164 return barcode_img
165
166# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0167
=== added file 'report_aeroo/barcode/courB08.pbm'
1Binary files report_aeroo/barcode/courB08.pbm 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/courB08.pbm 2014-04-05 13:18:49 +0000 differ168Binary files report_aeroo/barcode/courB08.pbm 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/courB08.pbm 2014-04-05 13:18:49 +0000 differ
=== added file 'report_aeroo/barcode/courB08.pil'
2Binary files report_aeroo/barcode/courB08.pil 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/courB08.pil 2014-04-05 13:18:49 +0000 differ169Binary files report_aeroo/barcode/courB08.pil 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/courB08.pil 2014-04-05 13:18:49 +0000 differ
=== added file 'report_aeroo/check_deps.py'
--- report_aeroo/check_deps.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/check_deps.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,52 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Copyright (c) 2009-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
5# General contacts <info@alistek.com>
6#
7# WARNING: This program as such is intended to be used by professional
8# programmers who take the whole responsability of assessing all potential
9# consequences resulting from its eventual inadequacies and bugs
10# End users who are looking for a ready-to-use solution with commercial
11# garantees and support are strongly adviced to contract a Free Software
12# Service Company
13#
14# This program is Free Software; you can redistribute it and/or
15# modify it under the terms of the GNU General Public License
16# as published by the Free Software Foundation; either version 3
17# of the License, or (at your option) any later version.
18#
19# This module is GPLv3 or newer and incompatible
20# with OpenERP SA "AGPL + Private Use License"!
21#
22# This program is distributed in the hope that it will be useful,
23# but WITHOUT ANY WARRANTY; without even the implied warranty of
24# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25# GNU General Public License for more details.
26#
27# You should have received a copy of the GNU General Public License
28# along with this program; if not, write to the Free Software
29# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30#
31##############################################################################
32
33from openerp.osv import orm
34from openerp.tools.translate import _
35
36__all__ = [
37 'check_deps',
38]
39
40def check_deps(check_list):
41 error = False
42 import_errors = []
43 for imp in check_list:
44 try:
45 exec imp in {}
46 except ImportError,e:
47 error = True
48 import_errors.append(str(e))
49 if error:
50 raise orm.except_orm(_('Warning!')+' '+_('Unmet python dependencies!'), '\n'.join(import_errors))
51
52# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
053
=== added directory 'report_aeroo/config_pixmaps'
=== added file 'report_aeroo/config_pixmaps/module_banner.png'
1Binary files report_aeroo/config_pixmaps/module_banner.png 1970-01-01 00:00:00 +0000 and report_aeroo/config_pixmaps/module_banner.png 2014-04-05 13:18:49 +0000 differ54Binary files report_aeroo/config_pixmaps/module_banner.png 1970-01-01 00:00:00 +0000 and report_aeroo/config_pixmaps/module_banner.png 2014-04-05 13:18:49 +0000 differ
=== added directory 'report_aeroo/ctt_languages'
=== added file 'report_aeroo/ctt_languages/__init__.py'
--- report_aeroo/ctt_languages/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,3 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# Please do not edit this file!
04
=== added directory 'report_aeroo/ctt_languages/en_US'
=== added file 'report_aeroo/ctt_languages/en_US/__init__.py'
--- report_aeroo/ctt_languages/en_US/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/en_US/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,91 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# en_US
4
5from report_aeroo.ctt_objects import ctt_language
6
7class en_US(ctt_language):
8 def _init_lang(self):
9 # language name
10 self.name = 'en_US'
11 # digits - masculine, singular
12 self.digits_sng_msc = [u'zero', u'one', u'two', u'three', u'four',
13 u'five', u'six', u'seven', u'eight', u'nine']
14 # tens - masculine, singular
15 self.tens_sng_msc = [u'', u'one', u'twen', u'thir', u'four', u'fif',
16 u'six', u'seven', u'eigh', u'nine']
17 # teens - masculine
18 self.teens = [u'ten', u'eleven', u'twelve', u'thirteen', u'fourteen',
19 u'fifteen', u'sixteen', u'seventeen', u'eighteen',
20 u'nineteen']
21 # multiplier - masculine, singular
22 self.multi_sng_msc = [u' hundred', u' thousand', u' million',
23 u' billion']
24 # multiplier - masculine, plural
25 self.multi_plr_msc = [u' hundreds', u' thousands', u' millions',
26 u' billions']
27
28 # next line is needed for correct loading of currencies
29 import currencies
30 return currencies
31
32
33 def wordify(self, chunk, chunknr, gender):
34 if gender == 'm':
35 number = self.digits_sng_msc
36 elif gender == 'f':
37 number = self.digits_sng_fem
38 elif gender == 'n':
39 number = self.digits_sng_neu
40 words = u''
41 digit1 = u''
42 digit2 = u''
43 digit3 = u''
44 chunklength = len(chunk)
45 # placing digits in right places
46 if chunklength == 1:
47 digit3 = chunk[0 : 1]
48 if chunklength == 2:
49 digit2 = chunk[0 : 1]
50 digit3 = chunk[1 : 2]
51 if chunklength == 3:
52 digit1 = chunk[0 : 1]
53 digit2 = chunk[1 : 2]
54 digit3 = chunk[-1]
55 # processing zero
56 if chunklength == 1 and digit3 == '0' :
57 return number[0]
58 # processing hundreds
59 if chunklength == 3 :
60 if digit1 == '1' :
61 words += self.digits_sng_msc[int(digit1)] + self.multi_sng_msc[0]
62 else :
63 if int(digit1) >= 1 : words += self.digits_sng_msc[int(digit1)] + self.multi_plr_msc[0]
64 # processing tens
65 if chunklength > 1:
66 spacer = ''
67 if len(words) > 0 : spacer = u' '
68 if digit2 == '1':
69 words += spacer + self.teens[int(digit3)]
70 else:
71 if int(digit2) > 1 and int(digit2) > 0:
72 words += spacer + self.tens_sng_msc[int(digit2)] + u'ty'
73
74 # processing ones
75 if chunklength > 0 and digit2 != '1' :
76 spacer = ''
77 if len(words) > 0: spacer = u' '
78 if int(digit3) > 0:
79 words += spacer + number[int(digit3)]
80 # end processing
81 if len(words) > 0 :
82 if digit3 == '1' and chunknr > 0:
83 return words + self.multi_sng_msc[chunknr]
84 elif digit3 != '1' and chunknr > 0:
85 return words + self.multi_sng_msc[chunknr]
86 else:
87 return words
88 else:
89 return ''
90
91en_US()
092
=== added directory 'report_aeroo/ctt_languages/en_US/currencies'
=== added file 'report_aeroo/ctt_languages/en_US/currencies/__init__.py'
--- report_aeroo/ctt_languages/en_US/currencies/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/en_US/currencies/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,3 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# Please do not edit this file!
04
=== added file 'report_aeroo/ctt_languages/en_US/currencies/eur.py'
--- report_aeroo/ctt_languages/en_US/currencies/eur.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/en_US/currencies/eur.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,19 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class eur(ctt_currency):
7 def _init_currency(self):
8 self.language = u'en_US'
9 self.code = u'EUR'
10 self.fractions = 100
11 self.cur_singular = u' euro'
12 self.cur_plural = u' euro'
13 self.frc_singular = u' cent'
14 self.frc_plural = u' cents'
15 # grammatical genders: f - feminine, m - masculine, n -neuter
16 self.cur_gram_gender = 'm'
17 self.frc_gram_gender = 'm'
18
19eur()
020
=== added file 'report_aeroo/ctt_languages/en_US/currencies/ltl.py'
--- report_aeroo/ctt_languages/en_US/currencies/ltl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/en_US/currencies/ltl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,19 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class ltl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'en_US'
9 self.code = u'LTL'
10 self.fractions = 100
11 self.cur_singular = u' Lithuanian litas'
12 self.cur_plural = u' Lithuanian litas'
13 self.frc_singular = u' cent'
14 self.frc_plural = u' cents'
15 # grammatical genders: f - feminine, m - masculine, n -neuter
16 self.cur_gram_gender = 'm'
17 self.frc_gram_gender = 'm'
18
19ltl()
020
=== added file 'report_aeroo/ctt_languages/en_US/currencies/lvl.py'
--- report_aeroo/ctt_languages/en_US/currencies/lvl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/en_US/currencies/lvl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,19 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class lvl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'en_US'
9 self.code = u'LVL'
10 self.fractions = 100
11 self.cur_singular = u' lat'
12 self.cur_plural = u' lats'
13 self.frc_singular = u' santim'
14 self.frc_plural = u' santims'
15 # grammatical genders: f - feminine, m - masculine, n -neuter
16 self.cur_gram_gender = 'm'
17 self.frc_gram_gender = 'm'
18
19lvl()
020
=== added file 'report_aeroo/ctt_languages/en_US/currencies/mxn.py'
--- report_aeroo/ctt_languages/en_US/currencies/mxn.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/en_US/currencies/mxn.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,19 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class mxn(ctt_currency):
7 def _init_currency(self):
8 self.language = u'en_US'
9 self.code = u'MXN'
10 self.fractions = 100
11 self.cur_singular = u' Mexican peso'
12 self.cur_plural = u' Mexican pesos'
13 self.frc_singular = u' cent'
14 self.frc_plural = u' cents'
15 # grammatical genders: f - feminine, m - masculine, n -neuter
16 self.cur_gram_gender = 'm'
17 self.frc_gram_gender = 'm'
18
19mxn()
020
=== added file 'report_aeroo/ctt_languages/en_US/currencies/trl.py'
--- report_aeroo/ctt_languages/en_US/currencies/trl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/en_US/currencies/trl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,19 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class trl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'en_US'
9 self.code = u'TRL'
10 self.fractions = 100
11 self.cur_singular = u' Turkish lira'
12 self.cur_plural = u' Turkish Liras'
13 self.frc_singular = u' kurus'
14 self.frc_plural = u' kuruss'
15 # grammatical genders: f - feminine, m - masculine, n -neuter
16 self.cur_gram_gender = 'm'
17 self.frc_gram_gender = 'm'
18
19trl()
020
=== added file 'report_aeroo/ctt_languages/en_US/currencies/usd.py'
--- report_aeroo/ctt_languages/en_US/currencies/usd.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/en_US/currencies/usd.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,19 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class usd(ctt_currency):
7 def _init_currency(self):
8 self.language = u'en_US'
9 self.code = u'USD'
10 self.fractions = 100
11 self.cur_singular = u' US dollar'
12 self.cur_plural = u' US dollars'
13 self.frc_singular = u' cent'
14 self.frc_plural = u' cents'
15 # grammatical genders: f - feminine, m - masculine, n -neuter
16 self.cur_gram_gender = 'm'
17 self.frc_gram_gender = 'm'
18
19usd()
020
=== added directory 'report_aeroo/ctt_languages/es_ES'
=== added file 'report_aeroo/ctt_languages/es_ES/__init__.py'
--- report_aeroo/ctt_languages/es_ES/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/es_ES/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,102 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# es_ES
4################################################################################
5# Spanish language support assembled from contributions provided by:
6# * mechiscogo
7# * Christopher Ormaza - Ecuadorenlinea.net <chris.ormaza@gmail.com>, 2011
8################################################################################
9
10from report_aeroo.ctt_objects import ctt_language
11
12class es_ES(ctt_language):
13 def _init_lang(self):
14 # language name
15 self.name = 'es_ES'
16 # digits - masculine, singular
17 self.digits_sng_msc = [u'cero', u'uno', u'dos', u'tres', u'cuatro',
18 u'cinco', u'seis', u'siete', u'ocho', u'nueve']
19
20 # tens - masculine, singular
21 self.tens_sng_msc = [u'', u'', u'veint', u'treinta', u'cuarenta',
22 u'cincuenta', u'sesenta', u'setenta', u'ochenta',
23 u'noventa ']
24
25 # teens - masculine
26 self.teens = [u'diez', u'once', u'doce', u'trece', u'catorce',
27 u'quince', u'dieciséis', u'diecisiete', u'dieciocho',
28 u'diecinueve']
29
30 # multiplier - masculine, singular
31 self.multi_sng_msc = [u'cien', u' mil', u' millón', u' billón']
32
33 # multiplier - masculine, plural
34 self.multi_plr_msc = [u'cientos', u' mil', u' millones', u' billones']
35
36 # next line is needed for correct loading of currencies
37 import currencies
38 return currencies
39
40
41 def wordify(self, chunk, chunknr, gender):
42 if gender == 'm':
43 number = self.digits_sng_msc
44 elif gender == 'f':
45 number = self.digits_sng_fem
46 elif gender == 'n':
47 number = self.digits_sng_neu
48 words = u''
49 digit1 = u''
50 digit2 = u''
51 digit3 = u''
52 chunklength = len(chunk)
53 # placing digits in right places
54 if chunklength == 1:
55 digit3 = chunk[0 : 1]
56 if chunklength == 2:
57 digit2 = chunk[0 : 1]
58 digit3 = chunk[1 : 2]
59 if chunklength == 3:
60 digit1 = chunk[0 : 1]
61 digit2 = chunk[1 : 2]
62 digit3 = chunk[-1]
63 # processing zero
64 if chunklength == 1 and digit3 == '0' :
65 return number[0]
66 # processing hundreds
67 if chunklength == 3 :
68 if digit1 == '1' :
69 words += self.multi_sng_msc[0]
70 else :
71 if int(digit1) >= 1 : words += self.digits_sng_msc[int(digit1)]\
72 + self.multi_plr_msc[0]
73 # processing tens
74 if chunklength > 1:
75 spacer = ''
76 if len(words) > 0 : spacer = u' '
77 if digit2 == '1':
78 words += spacer + self.teens[int(digit3)]
79 else:
80 if int(digit2) > 1 and int(digit2) > 0:
81 words += spacer + self.tens_sng_msc[int(digit2)]
82 if int(digit3) > 0:
83 words += u' y'
84
85 # processing ones
86 if chunklength > 0 and digit2 != '1' :
87 spacer = ''
88 if len(words) > 0: spacer = u' '
89 if int(digit3) > 0:
90 words += spacer + number[int(digit3)]
91 # end processing
92 if len(words) > 0 :
93 if digit3 == '1' and chunknr > 0:
94 return words + self.multi_sng_msc[chunknr]
95 elif digit3 != '1' and chunknr > 0:
96 return words + self.multi_plr_msc[chunknr]
97 else:
98 return words
99 else:
100 return ''
101
102es_ES()
0103
=== added directory 'report_aeroo/ctt_languages/es_ES/currencies'
=== added file 'report_aeroo/ctt_languages/es_ES/currencies/__init__.py'
--- report_aeroo/ctt_languages/es_ES/currencies/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/es_ES/currencies/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,3 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# Please do not edit this file!
04
=== added file 'report_aeroo/ctt_languages/es_ES/currencies/eur.py'
--- report_aeroo/ctt_languages/es_ES/currencies/eur.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/es_ES/currencies/eur.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,19 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class eur(ctt_currency):
7 def _init_currency(self):
8 self.language = u'es_ES'
9 self.code = u'EUR'
10 self.fractions = 100
11 self.cur_singular = u' euro'
12 self.cur_plural = u' euros'
13 self.frc_singular = u' centavo'
14 self.frc_plural = u' centavos'
15 # grammatical genders: f - feminine, m - masculine, n -neuter
16 self.cur_gram_gender = 'm'
17 self.frc_gram_gender = 'm'
18
19eur()
020
=== added file 'report_aeroo/ctt_languages/es_ES/currencies/mxn.py'
--- report_aeroo/ctt_languages/es_ES/currencies/mxn.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/es_ES/currencies/mxn.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,19 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class mxn(ctt_currency):
7 def _init_currency(self):
8 self.language = u'es_ES'
9 self.code = u'MXN'
10 self.fractions = 100
11 self.cur_singular = u' peso'
12 self.cur_plural = u' pesos'
13 self.frc_singular = u' centavo'
14 self.frc_plural = u' centavos'
15 # grammatical genders: f - feminine, m - masculine, n -neuter
16 self.cur_gram_gender = 'm'
17 self.frc_gram_gender = 'm'
18
19mxn()
020
=== added file 'report_aeroo/ctt_languages/es_ES/currencies/usd.py'
--- report_aeroo/ctt_languages/es_ES/currencies/usd.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/es_ES/currencies/usd.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,19 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class usd(ctt_currency):
7 def _init_currency(self):
8 self.language = u'es_ES'
9 self.code = u'USD'
10 self.fractions = 100
11 self.cur_singular = u' dólar Américano'
12 self.cur_plural = u' dólares Américanos'
13 self.frc_singular = u' centavo'
14 self.frc_plural = u' centavos'
15 # grammatical genders: f - feminine, m - masculine, n -neuter
16 self.cur_gram_gender = 'm'
17 self.frc_gram_gender = 'm'
18
19usd()
020
=== added directory 'report_aeroo/ctt_languages/lt_LT'
=== added file 'report_aeroo/ctt_languages/lt_LT/__init__.py'
--- report_aeroo/ctt_languages/lt_LT/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lt_LT/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,107 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# lt_LT
4################################################################################
5#
6# Lithuanian language support assembled from contributions provided by:
7# Paulius Sladkevičius
8#
9################################################################################
10
11from report_aeroo.ctt_objects import ctt_language
12
13class lt_LT(ctt_language):
14 def _init_lang(self):
15 self.name = 'lt_LT'
16 # digits - masculine, singular
17 self.number_sng_msc = [u'nulis', u'vienas', u'du', u'trys', u'keturi',
18 u'penkti', u'šeši', u'septyni', u'aštuoni',
19 u'devyni']
20 # tens - masculine, singular
21 self.tens_sng_msc = [u'nulis', u'vienas', u'dvi', u'tris',
22 u'keturias', u'penkias', u'šešias', u'septynias',
23 u'aštuonias', u'devynias']
24 # teens - masculine
25 self.teens = [u'dešimt', u'vienuolika', u'dvylika', u'trylika',
26 u'keturiolika', u'penkiolika', u'šešiolika',
27 u'septyniolika', u'aštuonolika', u'devyniolika']
28 # multiplier - masculine, singular
29 self.multi_sng_msc = [u' šimtas', u' tūkstantis', u' milijonas',
30 u' milijardas']
31 # multiplier - masculine, plural
32 self.multi_plr_msc = [u' šimtai', u' tūkstančiai', u' milijonai',
33 u' milijardai']
34 # multiplier - masculine, plural (other form)
35 self.multi_plr_msc_2 = [u' šimtų', u' tūkstančių', u' milijonų',
36 u' milijardų']
37
38 # next line is needed for correct loading of currencies
39 import currencies
40 return currencies
41
42
43 def wordify(self, chunk, chunknr, gender):
44 if gender == 'm':
45 number = self.number_sng_msc
46 elif gender == 'f':
47 number = self.number_sng_fem
48 elif gender == 'n':
49 number = self.number_sng_neu
50 words = u''
51 digit1 = u''
52 digit2 = u''
53 digit3 = u''
54 chunklength = len(chunk)
55 # placing digits in right places
56 if chunklength == 1:
57 digit3 = chunk[0 : 1]
58 if chunklength == 2:
59 digit2 = chunk[0 : 1]
60 digit3 = chunk[1 : 2]
61 if chunklength == 3:
62 digit1 = chunk[0 : 1]
63 digit2 = chunk[1 : 2]
64 digit3 = chunk[-1]
65 # processing zero
66 if chunklength == 1 and digit3 == '0' :
67 return number[0]
68 # processing hundreds
69 if chunklength == 3 :
70 if digit1 == '1' :
71 words += self.multi_sng_msc[0]
72 else :
73 if int(digit1) > 1 : words += number[int(digit1)] + \
74 self.multi_plr_msc[0]
75 # processing tens
76 if chunklength > 1:
77 spacer = ''
78 if len(words) > 0 : spacer = ' '
79 if digit2 == '1':
80 words += spacer + self.number_teens[int(digit3)]
81 else:
82 if int(digit2) > 1 and int(digit2) > 0:
83 words += spacer + self.tens_sng_msc[int(digit2)] + u'dešimt'
84
85 # processing ones
86 if chunklength > 0 and digit2 != '1' :
87 spacer = ''
88 if len(words) > 0: spacer = u' '
89 if int(digit3) > 0:
90 words += spacer + number[int(digit3)]
91 # end processing
92 if len(words) > 0 :
93 if digit3 == '1' and chunknr > 0:
94 return words + self.multi_sng_msc[chunknr]
95 elif digit3 != '1' and chunknr > 0:
96 if chunklength >= 2 and ((int(chunk) % 10) == 0 or (digit2 == \
97 '1' and int(digit3) > 0)):
98 return words + multi_plr_msc_2[chunknr]
99 else:
100 return words + multi_plr_msc[chunknr]
101
102 else:
103 return words
104 else:
105 return ''
106
107lt_LT()
0108
=== added directory 'report_aeroo/ctt_languages/lt_LT/currencies'
=== added file 'report_aeroo/ctt_languages/lt_LT/currencies/__init__.py'
--- report_aeroo/ctt_languages/lt_LT/currencies/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lt_LT/currencies/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,3 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# Please do not edit this file!
04
=== added file 'report_aeroo/ctt_languages/lt_LT/currencies/eur.py'
--- report_aeroo/ctt_languages/lt_LT/currencies/eur.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lt_LT/currencies/eur.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class eur(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lt_LT'
9 self.code = u'EUR'
10 self.fractions = 100
11 self.cur_singular = u' euras'
12 # default plural form for currency
13 self.cur_plural = u' eurų'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' eurai'
16 self.frc_singular = u' centas'
17 # default plural form for fractions
18 self.frc_plural = u' centų'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' centai'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'm'
23 self.frc_gram_gender = 'm'
24
25eur()
026
=== added file 'report_aeroo/ctt_languages/lt_LT/currencies/ltl.py'
--- report_aeroo/ctt_languages/lt_LT/currencies/ltl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lt_LT/currencies/ltl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class ltl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lt_LT'
9 self.code = u'LTL'
10 self.fractions = 100
11 self.cur_singular = u' litas'
12 # default plural form for currency
13 self.cur_plural = u' litų'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' litai'
16 self.frc_singular = u' centas'
17 # default plural form for fractions
18 self.frc_plural = u' centų'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' centai'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'm'
23 self.frc_gram_gender = 'm'
24
25ltl()
026
=== added file 'report_aeroo/ctt_languages/lt_LT/currencies/lvl.py'
--- report_aeroo/ctt_languages/lt_LT/currencies/lvl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lt_LT/currencies/lvl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class lvl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lt_LT'
9 self.code = u'LVL'
10 self.fractions = 100
11 self.cur_singular = u' latas'
12 # default plural form for currency
13 self.cur_plural = u' latų'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' latai'
16 self.frc_singular = u' santimas'
17 # default plural form for fractions
18 self.frc_plural = u' santimų'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' santimai'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'm'
23 self.frc_gram_gender = 'm'
24
25lvl()
026
=== added file 'report_aeroo/ctt_languages/lt_LT/currencies/uah.py'
--- report_aeroo/ctt_languages/lt_LT/currencies/uah.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lt_LT/currencies/uah.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class uah(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lt_LT'
9 self.code = u'UAH'
10 self.fractions = 100
11 self.cur_singular = u' grivna'
12 # default plural form for currency
13 self.cur_plural = u' grivnų'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' grivnai'
16 self.frc_singular = u' kapeika'
17 # default plural form for fractions
18 self.frc_plural = u' kapeikų'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' kapeikos'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'm'
23 self.frc_gram_gender = 'm'
24
25uah()
026
=== added file 'report_aeroo/ctt_languages/lt_LT/currencies/usd.py'
--- report_aeroo/ctt_languages/lt_LT/currencies/usd.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lt_LT/currencies/usd.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class usd(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lt_LT'
9 self.code = u'USD'
10 self.fractions = 100
11 self.cur_singular = u' doleris'
12 # default plural form for currency
13 self.cur_plural = u' dolerių'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' doleriai'
16 self.frc_singular = u' centas'
17 # default plural form for fractions
18 self.frc_plural = u' centų'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' centai'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'm'
23 self.frc_gram_gender = 'm'
24
25usd()
026
=== added directory 'report_aeroo/ctt_languages/lv_LV'
=== added file 'report_aeroo/ctt_languages/lv_LV/__init__.py'
--- report_aeroo/ctt_languages/lv_LV/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,101 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# lv_LV
4
5from report_aeroo.ctt_objects import ctt_language
6
7class lv_LV(ctt_language):
8 def _init_lang(self):
9 self.name = 'lv_LV'
10 # digits - masculine, singular
11 self.number_sng_msc = [u'nulle', u'viens', u'divi',
12 u'trīs', u'četri', u'pieci',
13 u'seši', u'septiņi', u'astoņi',
14 u'deviņi']
15 # digits - feminine, singular
16 self.number_sng_fem = [u'nulle', u'viena', u'divas',
17 u'trīs', u'četras', u'piecas',
18 u'sešas', u'septiņas', u'astoņas',
19 u'deviņas']
20 # tens - masculine, singular
21 self.tens_sng_msc = [u'nulle', u'vien', u'div',
22 u'trīs', u'četr', u'piec',
23 u'seš', u'septiņ', u'astoņ',
24 u'deviņ']
25 # teens - masculine
26 self.teens = [u'desmit', u'vienpadsmit', u'divpadsmit',
27 u'trīspadsmit', u'četrpadsmit', u'piecpadsmit',
28 u'sešpadsmit', u'septiņpadsmit', u'astoņpadsmit',
29 u'deviņpadsmit']
30 # multiplier - masculine, singular
31 self.multi_sng_msc = [u'simts', u' tūkstotis', u' miljons',
32 u' miljards']
33 # multiplier - masculine, plural
34 self.multi_plr_msc = [u' simti', u' tūkstoši', u' miljoni',
35 u' miljardi']
36
37 # next line is needed for correct loading of currencies
38 import currencies
39 return currencies
40
41
42 def wordify(self, chunk, chunknr, gender):
43 if gender == 'm':
44 number = self.number_sng_msc
45 elif gender == 'f':
46 number = self.number_sng_fem
47 elif gender == 'n':
48 number = self.number_sng_neu
49 words = u''
50 digit1 = u''
51 digit2 = u''
52 digit3 = u''
53 chunklength = len(chunk)
54 # placing digits in right places
55 if chunklength == 1:
56 digit3 = chunk[0 : 1]
57 if chunklength == 2:
58 digit2 = chunk[0 : 1]
59 digit3 = chunk[1 : 2]
60 if chunklength == 3:
61 digit1 = chunk[0 : 1]
62 digit2 = chunk[1 : 2]
63 digit3 = chunk[-1]
64 # processing zero
65 if chunklength == 1 and digit3 == '0' :
66 return number[0]
67 # processing hundreds
68 if chunklength == 3 :
69 if digit1 == '1' :
70 words += self.multi_sng_msc[0]
71 else :
72 if int(digit1) > 1 : words += number[int(digit1)] + \
73 self.multi_plr_msc[0]
74 # processing tens
75 if chunklength > 1:
76 spacer = ''
77 if len(words) > 0 : spacer = ' '
78 if digit2 == '1':
79 words += spacer + self.teens[int(digit3)]
80 else:
81 if int(digit2) > 1 and int(digit2) > 0:
82 words += spacer + self.tens_sng_msc[int(digit2)] + u'desmit'
83
84 # processing ones
85 if chunklength > 0 and digit2 != '1' :
86 spacer = ''
87 if len(words) > 0: spacer = u' '
88 if int(digit3) > 0:
89 words += spacer + number[int(digit3)]
90 # end processing
91 if len(words) > 0 :
92 if digit3 == '1' and chunknr > 0:
93 return words + self.multi_sng_msc[chunknr]
94 elif digit3 != '1' and chunknr > 0:
95 return words + self.multi_plr_msc[chunknr]
96 else:
97 return words
98 else:
99 return ''
100
101lv_LV()
0102
=== added directory 'report_aeroo/ctt_languages/lv_LV/currencies'
=== added file 'report_aeroo/ctt_languages/lv_LV/currencies/__init__.py'
--- report_aeroo/ctt_languages/lv_LV/currencies/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/currencies/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,3 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# Please do not edit this file!
04
=== added file 'report_aeroo/ctt_languages/lv_LV/currencies/eur.py'
--- report_aeroo/ctt_languages/lv_LV/currencies/eur.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/currencies/eur.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,22 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class eur(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lv_LV'
9 self.code = u'EUR'
10 self.fractions = 100
11 self.cur_singular = u' eiro'
12 self.cur_plural = u' eiro'
13 self.frc_singular = u' cents'
14 # default plural form for fractions
15 self.frc_plural = u' centu'
16 # betwean 1 and 10 yields different plural form, if defined
17 self.frc_plural_2to10 = u' centi'
18 # grammatical genders: f - feminine, m - masculine, n -neuter
19 self.cur_gram_gender = 'm'
20 self.frc_gram_gender = 'm'
21
22eur()
023
=== added file 'report_aeroo/ctt_languages/lv_LV/currencies/ltl.py'
--- report_aeroo/ctt_languages/lv_LV/currencies/ltl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/currencies/ltl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class ltl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lv_LV'
9 self.code = u'LTL'
10 self.fractions = 100
11 self.cur_singular = u' lits'
12 # default plural form for currency
13 self.cur_plural = u' litu'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' liti'
16 self.frc_singular = u' cents'
17 # default plural form for fractions
18 self.frc_plural = u' centu'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' centi'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'm'
23 self.frc_gram_gender = 'm'
24
25ltl()
026
=== added file 'report_aeroo/ctt_languages/lv_LV/currencies/lvl.py'
--- report_aeroo/ctt_languages/lv_LV/currencies/lvl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/currencies/lvl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class lvl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lv_LV'
9 self.code = u'LVL'
10 self.fractions = 100
11 self.cur_singular = u' lats'
12 # default plural form for currency
13 self.cur_plural = u' latu'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' lati'
16 self.frc_singular = u' santīms'
17 # default plural form for fractions
18 self.frc_plural = u' santīmi'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' santīmu'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'm'
23 self.frc_gram_gender = 'm'
24
25lvl()
026
=== added file 'report_aeroo/ctt_languages/lv_LV/currencies/mxn.py'
--- report_aeroo/ctt_languages/lv_LV/currencies/mxn.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/currencies/mxn.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,22 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class mxn(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lv_LV'
9 self.code = u'MXN'
10 self.fractions = 100
11 self.cur_singular = u' Meksikas peso'
12 self.cur_plural = self.cur_singular
13 self.frc_singular = u' cents'
14 # default plural form for fractions
15 self.frc_plural = u' centu'
16 # betwean 1 and 10 yields different plural form, if defined
17 self.frc_plural_2to10 = u' centi'
18 # grammatical genders: f - feminine, m - masculine, n -neuter
19 self.cur_gram_gender = 'm'
20 self.frc_gram_gender = 'm'
21
22mxn()
023
=== added file 'report_aeroo/ctt_languages/lv_LV/currencies/rub.py'
--- report_aeroo/ctt_languages/lv_LV/currencies/rub.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/currencies/rub.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class rub(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lv_LV'
9 self.code = u'RUB'
10 self.fractions = 100
11 self.cur_singular = u' rublis'
12 # default plural form for currency
13 self.cur_plural = u' rubļu'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' rubļi'
16 self.frc_singular = u' kapeika'
17 # default plural form for fractions
18 self.frc_plural = u' kapeiku'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' kapeikas'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'm'
23 self.frc_gram_gender = 'f'
24
25rub()
026
=== added file 'report_aeroo/ctt_languages/lv_LV/currencies/trl.py'
--- report_aeroo/ctt_languages/lv_LV/currencies/trl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/currencies/trl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class trl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lv_LV'
9 self.code = u'TRL'
10 self.fractions = 100
11 self.cur_singular = u' Turku lira'
12 # default plural form for currency
13 self.cur_plural = u' Turku liru'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' Turku liras'
16 self.frc_singular = u' kurušs'
17 # default plural form for fractions
18 self.frc_plural = u' kurušu'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' kuruši'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'f'
23 self.frc_gram_gender = 'm'
24
25trl()
026
=== added file 'report_aeroo/ctt_languages/lv_LV/currencies/uah.py'
--- report_aeroo/ctt_languages/lv_LV/currencies/uah.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/currencies/uah.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,24 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class uah(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lv_LV'
9 self.code = u'UAH'
10 self.fractions = 100
11 self.cur_singular = u' grivna'
12 # default plural form for currency
13 self.cur_plural = u' grivnu'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' grivnas'
16 self.frc_singular = u' kapeika'
17 # default plural form for fractions
18 self.frc_plural = u' kapeiku'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' kapeikas'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'f'
23 self.frc_gram_gender = 'f'
24uah()
025
=== added file 'report_aeroo/ctt_languages/lv_LV/currencies/usd.py'
--- report_aeroo/ctt_languages/lv_LV/currencies/usd.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/lv_LV/currencies/usd.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class usd(ctt_currency):
7 def _init_currency(self):
8 self.language = u'lv_LV'
9 self.code = u'USD'
10 self.fractions = 100
11 self.cur_singular = u' ASV dolārs'
12 # default plural form for currency
13 self.cur_plural = u' ASV dolāru'
14 # betwean 1 and 10 yields different plural form, if defined
15 self.cur_plural_2to10 = u' ASV dolāri'
16 self.frc_singular = u' cents'
17 # default plural form for fractions
18 self.frc_plural = u' centu'
19 # betwean 1 and 10 yields different plural form, if defined
20 self.frc_plural_2to10 = u' centi'
21 # grammatical genders: f - feminine, m - masculine, n -neuter
22 self.cur_gram_gender = 'm'
23 self.frc_gram_gender = 'm'
24
25usd()
026
=== added directory 'report_aeroo/ctt_languages/ru_RU'
=== added file 'report_aeroo/ctt_languages/ru_RU/__init__.py'
--- report_aeroo/ctt_languages/ru_RU/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/ru_RU/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,110 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# ru_RU
4
5from report_aeroo.ctt_objects import ctt_language
6
7class ru_RU(ctt_language):
8 def _init_lang(self):
9 # language name
10 self.name = 'ru_RU'
11 # digits - masculine, singular
12 self.number_sng_msc = [u'ноль', u'один', u'два', u'три', u'четыре',
13 u'пять', u'шесть', u'семь', u'восемь', u'девять']
14 # tens - masculine, singular
15 self.number_sng_fem = [u'ноль', u'одна', u'две', u'три', u'четыре',
16 u'пять', u'шесть', u'семь', u'восемь', u'девять']
17 # tens - masculine, plural
18 self.number_plr_msc = [u'', u'один', u'двa', u'три', u'четыре', u'пять',
19 u'шесть', u'семь', u'восемь', u'девять']
20 # teens - masculine
21 self.number_teens = [u'десять', u'одиннадцать', u'двенадцать',
22 u'тринадцать', u'четырнадцать', u'пятнадцать',
23 u'шестнадцать', u'семнадцать', u'восемнадцать',
24 u'девятнадцать']
25 # multiplier - masculine, singular
26 self.multi_sng_msc = [u'стo', u' тысяча', u' миллион', u' миллиард']
27 # multiplier - masculine, plural
28 self.multi_plr_msc = [u'сoт', u' тысяч', u' миллионов', u' миллиардов']
29
30 # next line is needed for correct loading of currencies
31 import currencies
32 return currencies
33
34
35 def wordify(self, chunk, chunknr, gender):
36 if gender == 'm':
37 number = self.number_sng_msc
38 elif gender == 'f':
39 number = self.number_sng_fem
40 elif gender == 'n':
41 number = self.number_sng_neu
42 words = u''
43 digit1 = u''
44 digit2 = u''
45 digit3 = u''
46 chunklength = len(chunk)
47 # placing digits in right places
48 if chunklength == 1:
49 digit3 = chunk[0 : 1]
50 if chunklength == 2:
51 digit2 = chunk[0 : 1]
52 digit3 = chunk[1 : 2]
53 if chunklength == 3:
54 digit1 = chunk[0 : 1]
55 digit2 = chunk[1 : 2]
56 digit3 = chunk[-1]
57 # processing zero
58 if chunklength == 1 and digit3 == '0' :
59 return number[0]
60 # processing hundreds
61 if chunklength == 3 :
62 if int(digit1) == 1 :
63 words += self.multi_sng_msc[0]
64 elif int(digit1) == 2 :
65 words += u'двести'
66 elif int(digit1) == 3 :
67 words += u'триста'
68 elif int(digit1) == 4 :
69 words += u'четыреста'
70 elif int(digit1) >= 5 :
71 words += self.number_sng_msc[int(digit1)] + self.multi_plr_msc[0]
72 # processing tens
73 if chunklength > 1:
74 spacer = ''
75 if len(words) > 0 : spacer = ' '
76 if digit2 == '1':
77 words += spacer + self.number_teens[int(digit3)]
78 else:
79 if int(digit2) > 1 and int(digit2) < 4:
80 words += spacer + self.number_plr_msc[int(digit2)] + u'дцать'
81 elif digit2 == '4':
82 words += spacer + u'сорок'
83 elif int(digit2) >= 5 and int(digit2) != 9:
84 words += spacer + self.number_plr_msc[int(digit2)] + u'десят'
85 elif digit2 == '9':
86 words += spacer + u'девяносто'
87
88 # processing ones
89 if chunklength > 0 and digit2 != '1' :
90 spacer = ''
91 if len(words) > 0: spacer = u' '
92 if chunknr == 1:
93 if int(digit3) == 1 or int(digit3) == 2:
94 words += spacer + self.number_sng_fem[int(digit3)]
95 elif int(digit3) >= 3 and int(digit3) != 0:
96 words += spacer + self.number_sng_msc[int(digit3)]
97 else:
98 if int(digit3) > 0: words += spacer + self.number_sng_msc[int(digit3)]
99 # end processing
100 if len(words) > 0 :
101 if digit3 == '1' and chunknr > 0:
102 return words + self.multi_sng_msc[chunknr]
103 elif digit3 != '1' and chunknr > 0:
104 return words + self.multi_plr_msc[chunknr]
105 else:
106 return words
107 else:
108 return ''
109
110ru_RU()
0111
=== added directory 'report_aeroo/ctt_languages/ru_RU/currencies'
=== added file 'report_aeroo/ctt_languages/ru_RU/currencies/__init__.py'
--- report_aeroo/ctt_languages/ru_RU/currencies/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/ru_RU/currencies/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,3 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# Please do not edit this file!
04
=== added file 'report_aeroo/ctt_languages/ru_RU/currencies/eur.py'
--- report_aeroo/ctt_languages/ru_RU/currencies/eur.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/ru_RU/currencies/eur.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,22 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class eur(ctt_currency):
7 def _init_currency(self):
8 self.language = u'ru_RU'
9 self.code = u'EUR'
10 self.fractions = 100
11 self.cur_singular = u' евро'
12 self.cur_plural = u' евро'
13 self.frc_singular = u' цент'
14 # default plural form for fractions
15 self.frc_plural = u' центов'
16 self.frc_plural_2_to4 = u' цента'
17
18 # grammatical genders: f - feminine, m - masculine, n -neuter
19 self.cur_gram_gender = 'm'
20 self.frc_gram_gender = 'm'
21
22eur()
023
=== added file 'report_aeroo/ctt_languages/ru_RU/currencies/ltl.py'
--- report_aeroo/ctt_languages/ru_RU/currencies/ltl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/ru_RU/currencies/ltl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class ltl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'ru_RU'
9 self.code = u'LTL'
10 self.fractions = 100
11 self.cur_singular = u' лит'
12 # default plural form for currency
13 self.cur_plural = u' литов'
14 self.cur_plural_2to4 = u' лита'
15 self.frc_singular = u' цент'
16 # default plural form for fractions
17 self.frc_plural = u' центов'
18 self.frc_plural_2to4 = u' цента'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'm'
21 self.frc_gram_gender = 'm'
22
23ltl()
024
=== added file 'report_aeroo/ctt_languages/ru_RU/currencies/lvl.py'
--- report_aeroo/ctt_languages/ru_RU/currencies/lvl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/ru_RU/currencies/lvl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class lvl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'ru_RU'
9 self.code = u'LVL'
10 self.fractions = 100
11 self.cur_singular = u' лат'
12 # default plural form for currency
13 self.cur_plural = u' латов'
14 self.cur_plural_2to4 = u' лата'
15 self.frc_singular = u' сантим'
16 # default plural form for fractions
17 self.frc_plural = u' сантимов'
18 self.frc_plural_2to4 = u' сантима'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'm'
21 self.frc_gram_gender = 'm'
22
23lvl()
024
=== added file 'report_aeroo/ctt_languages/ru_RU/currencies/rub.py'
--- report_aeroo/ctt_languages/ru_RU/currencies/rub.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/ru_RU/currencies/rub.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class rub(ctt_currency):
7 def _init_currency(self):
8 self.language = u'ru_RU'
9 self.code = u'RUB'
10 self.fractions = 100
11 self.cur_singular = u' рубль'
12 # default plural form for currency
13 self.cur_plural = u' рублей'
14 self.cur_plural_2to4 = u' рубля'
15 self.frc_singular = u' копейка'
16 # default plural form for fractions
17 self.frc_plural = u' копеек'
18 self.frc_plural_2to4 = u' копейки'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'm'
21 self.frc_gram_gender = 'f'
22
23rub()
024
=== added file 'report_aeroo/ctt_languages/ru_RU/currencies/uah.py'
--- report_aeroo/ctt_languages/ru_RU/currencies/uah.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/ru_RU/currencies/uah.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class uah(ctt_currency):
7 def _init_currency(self):
8 self.language = u'ru_RU'
9 self.code = u'UAH'
10 self.fractions = 100
11 self.cur_singular = u' гривна'
12 # default plural form for currency
13 self.cur_plural = u' гривен'
14 self.cur_plural_2to4 = u' гривны'
15 self.frc_singular = u' копeйка'
16 # default plural form for fractions
17 self.frc_plural = u' копeек'
18 self.frc_plural_2to4 = u' копeйки'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'f'
21 self.frc_gram_gender = 'f'
22
23uah()
024
=== added file 'report_aeroo/ctt_languages/ru_RU/currencies/usd.py'
--- report_aeroo/ctt_languages/ru_RU/currencies/usd.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/ru_RU/currencies/usd.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class usd(ctt_currency):
7 def _init_currency(self):
8 self.language = u'ru_RU'
9 self.code = u'USD'
10 self.fractions = 100
11 self.cur_singular = u' доллара США'
12 # default plural form for currency
13 self.cur_plural = u' долларов США'
14 self.cur_frc_plural_2to4 = u' доллара США'
15 self.frc_singular = u' цент'
16 # default plural form for fractions
17 self.frc_plural = u' центов'
18 self.frc_plural_2to4 = u' цента'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'm'
21 self.frc_gram_gender = 'm'
22
23usd()
024
=== added directory 'report_aeroo/ctt_languages/tr_TR'
=== added file 'report_aeroo/ctt_languages/tr_TR/__init__.py'
--- report_aeroo/ctt_languages/tr_TR/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/tr_TR/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,93 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# tr_TR
4################################################################################
5#
6# Turkish language support assembled from contributions provided by:
7# Ahmet Altınışık
8#
9################################################################################
10from report_aeroo.ctt_objects import ctt_language
11
12class tr_TR(ctt_language):
13 def _init_lang(self):
14 self.name = 'tr_TR'
15 # digits - masculine, singular
16 self.number_sng_msc = [u'', u'bir', u'iki', u'üç', u'dört', u'beş',
17 u'alti', u'yedi', u'sekiz', u'dokuz']
18 # tens - masculine, singular
19 self.tens_sng_msc = [u'on', u'on bir', u'on iki', u'on üç', u'on dört',
20 u'on beş', u'on alti', u'on yedi', u'on sekiz',
21 u'on dokuz']
22 # teens - masculine
23 self.teens = [u'on', u'on bir', u'on iki', u'on üç', u'on dört',
24 u'on beş', u'on alti', u'on yedi', u'on sekiz',
25 u'on dokuz']
26 # multiplier - masculine, singular
27 self.multi_sng_msc = [u'yüz', u' bin', u' milyon', u' milyar']
28
29 # next line is needed for correct loading of currencies
30 import currencies
31 return currencies
32
33
34 def wordify(self, chunk, chunknr, gender):
35 if gender == 'm':
36 number = self.number_sng_msc
37 elif gender == 'f':
38 number = self.number_sng_fem
39 elif gender == 'n':
40 number = self.number_sng_neu
41 words = u''
42 digit1 = u''
43 digit2 = u''
44 digit3 = u''
45 chunklength = len(chunk)
46 # placing digits in right places
47 if chunklength == 1:
48 digit3 = chunk[0 : 1]
49 if chunklength == 2:
50 digit2 = chunk[0 : 1]
51 digit3 = chunk[1 : 2]
52 if chunklength == 3:
53 digit1 = chunk[0 : 1]
54 digit2 = chunk[1 : 2]
55 digit3 = chunk[-1]
56 # processing zero
57 if chunklength == 1 and digit3 == '0' :
58 return number[0]
59 # processing hundreds
60 if chunklength == 3 :
61 if digit1 == '1' :
62 words += self.multi_sng_msc[0]
63 else :
64 if int(digit1) > 1 : words += number[int(digit1)] + \
65 self.multi_plr_msc[0]
66 # processing tens
67 if chunklength > 1:
68 spacer = ''
69 if len(words) > 0 : spacer = ' '
70 if digit2 == '1':
71 words += spacer + self.teens[int(digit3)]
72 else:
73 if int(digit2) > 1 and int(digit2) > 0:
74 words += spacer + self.tens_sng_msc[int(digit2)]
75
76 # processing ones
77 if chunklength > 0 and digit2 != '1' :
78 spacer = ''
79 if len(words) > 0: spacer = u' '
80 if int(digit3) > 0:
81 words += spacer + number[int(digit3)]
82 # end processing
83 if len(words) > 0 :
84 if digit3 == '1' and chunknr > 0:
85 return words + self.multi_sng_msc[chunknr]
86 elif digit3 != '1' and chunknr > 0:
87 return words + self.multi_plr_msc[chunknr]
88 else:
89 return words
90 else:
91 return ''
92
93tr_TR()
094
=== added directory 'report_aeroo/ctt_languages/tr_TR/currencies'
=== added file 'report_aeroo/ctt_languages/tr_TR/currencies/__init__.py'
--- report_aeroo/ctt_languages/tr_TR/currencies/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/tr_TR/currencies/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,3 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# Please do not edit this file!
04
=== added file 'report_aeroo/ctt_languages/tr_TR/currencies/eur.py'
--- report_aeroo/ctt_languages/tr_TR/currencies/eur.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/tr_TR/currencies/eur.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,21 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class eur(ctt_currency):
7 def _init_currency(self):
8 self.language = u'tr_TR'
9 self.code = u'EUR'
10 self.fractions = 100
11 self.cur_singular = u' Euro'
12 # default plural form for currency
13 self.cur_plural = u' Euro'
14 self.frc_singular = u' sent'
15 # default plural form for fractions
16 self.frc_plural = u' sent'
17 # grammatical genders: f - feminine, m - masculine, n -neuter
18 self.cur_gram_gender = 'm'
19 self.frc_gram_gender = 'm'
20
21eur()
022
=== added file 'report_aeroo/ctt_languages/tr_TR/currencies/lvl.py'
--- report_aeroo/ctt_languages/tr_TR/currencies/lvl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/tr_TR/currencies/lvl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,21 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class lvl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'tr_TR'
9 self.code = u'LVL'
10 self.fractions = 100
11 self.cur_singular = u' Litvanya Liatası'
12 # default plural form for currency
13 self.cur_plural = u' Litvanya Liatası'
14 self.frc_singular = u' santim'
15 # default plural form for fractions
16 self.frc_plural = u' santims'
17 # grammatical genders: f - feminine, m - masculine, n -neuter
18 self.cur_gram_gender = 'm'
19 self.frc_gram_gender = 'm'
20
21lvl()
022
=== added file 'report_aeroo/ctt_languages/tr_TR/currencies/trl.py'
--- report_aeroo/ctt_languages/tr_TR/currencies/trl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/tr_TR/currencies/trl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,21 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class trl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'tr_TR'
9 self.code = u'TRL'
10 self.fractions = 100
11 self.cur_singular = u' Lira'
12 # default plural form for currency
13 self.cur_plural = u' Lira'
14 self.frc_singular = u' kuruş'
15 # default plural form for fractions
16 self.frc_plural = u' kuruş'
17 # grammatical genders: f - feminine, m - masculine, n -neuter
18 self.cur_gram_gender = 'm'
19 self.frc_gram_gender = 'm'
20
21trl()
022
=== added file 'report_aeroo/ctt_languages/tr_TR/currencies/usd.py'
--- report_aeroo/ctt_languages/tr_TR/currencies/usd.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/tr_TR/currencies/usd.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,21 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class usd(ctt_currency):
7 def _init_currency(self):
8 self.language = u'tr_TR'
9 self.code = u'USD'
10 self.fractions = 100
11 self.cur_singular = u' USD'
12 # default plural form for currency
13 self.cur_plural = u' USD'
14 self.frc_singular = u' sent'
15 # default plural form for fractions
16 self.frc_plural = u' sent'
17 # grammatical genders: f - feminine, m - masculine, n -neuter
18 self.cur_gram_gender = 'm'
19 self.frc_gram_gender = 'm'
20
21usd()
022
=== added directory 'report_aeroo/ctt_languages/uk_UA'
=== added file 'report_aeroo/ctt_languages/uk_UA/__init__.py'
--- report_aeroo/ctt_languages/uk_UA/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/uk_UA/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,112 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# uk_UA
4
5from report_aeroo.ctt_objects import ctt_language
6
7class uk_UA(ctt_language):
8 def _init_lang(self):
9 # language name
10 self.name = 'uk_UA'
11 # digits - masculine, singular
12 self.number_sng_msc = [u'ноль', u'один', u'два', u'три', u'чотири',
13 u'п\'ять', u'шість', u'сім', u'вісім',
14 u'дев\'ять']
15 # tens - masculine, singular
16 self.number_sng_fem = [u'ноль', u'одна', u'дві', u'три', u'чотири',
17 u'п\'ять', u'шість', u'сім', u'вісім',
18 u'дев\'ять']
19 # tens - masculine, plural
20 self.number_plr_msc = [u'', u'один', u'двa', u'три', u'четыре', u'пять',
21 u'шесть', u'семь', u'восемь', u'девять']
22 # teens - masculine
23 self.number_teens = [u'десять', u'одинадцять', u'дванадцять',
24 u'тринадцять', u'чотирнадцять', u'п\'ятнадцять',
25 u'шістнадцять', u'сімнадцять', u'вісімнадцять',
26 u'дев\'ятнадцять']
27 # multiplier - masculine, singular
28 self.multi_sng_msc = [u'стo', u' тисяча', u' мiллiон', u' мiллiард']
29 # multiplier - masculine, plural
30 self.multi_plr_msc = [u'сoт', u' тисяч', u' мiллiонiв', u' мiллiардов']
31
32 # next line is needed for correct loading of currencies
33 import currencies
34 return currencies
35
36
37 def wordify(self, chunk, chunknr, gender):
38 if gender == 'm':
39 number = self.number_sng_msc
40 elif gender == 'f':
41 number = self.number_sng_fem
42 elif gender == 'n':
43 number = self.number_sng_neu
44 words = u''
45 digit1 = u''
46 digit2 = u''
47 digit3 = u''
48 chunklength = len(chunk)
49 # placing digits in right places
50 if chunklength == 1:
51 digit3 = chunk[0 : 1]
52 if chunklength == 2:
53 digit2 = chunk[0 : 1]
54 digit3 = chunk[1 : 2]
55 if chunklength == 3:
56 digit1 = chunk[0 : 1]
57 digit2 = chunk[1 : 2]
58 digit3 = chunk[-1]
59 # processing zero
60 if chunklength == 1 and digit3 == '0' :
61 return number[0]
62 # processing hundreds
63 if chunklength == 3 :
64 if int(digit1) == 1 :
65 words += self.multi_sng_msc[0]
66 elif int(digit1) == 2 :
67 words += u'двісті'
68 elif int(digit1) == 3 :
69 words += u'триста'
70 elif int(digit1) == 4 :
71 words += u'чотириста'
72 elif int(digit1) >= 5 :
73 words += self.number_sng_msc[int(digit1)] + self.multi_plr_msc[0]
74 # processing tens
75 if chunklength > 1:
76 spacer = ''
77 if len(words) > 0 : spacer = ' '
78 if digit2 == '1':
79 words += spacer + self.number_teens[int(digit3)]
80 else:
81 if int(digit2) > 1 and int(digit2) < 4:
82 words += spacer + skaitlix[int(digit2)] + u'дцять'
83 elif digit2 == '4':
84 words += spacer + u'сорок'
85 elif int(digit2) >= 5 and int(digit2) != 9:
86 words += spacer + skaitlix[int(digit2)] + u'десят'
87 elif digit2 == '9':
88 words += spacer + u'дев\'яносто'
89
90 # processing ones
91 if chunklength > 0 and digit2 != '1' :
92 spacer = ''
93 if len(words) > 0: spacer = u' '
94 if chunknr == 1:
95 if int(digit3) == 1 or int(digit3) == 2:
96 words += spacer + self.number_sng_fem[int(digit3)]
97 elif int(digit3) >= 3 and int(digit3) != 0:
98 words += spacer + self.number_sng_msc[int(digit3)]
99 else:
100 if int(digit3) > 0: words += spacer + self.number_sng_msc[int(digit3)]
101 # end processing
102 if len(words) > 0 :
103 if digit3 == '1' and chunknr > 0:
104 return words + self.multi_sng_msc[chunknr]
105 elif digit3 != '1' and chunknr > 0:
106 return words + self.multi_plr_msc[chunknr]
107 else:
108 return words
109 else:
110 return ''
111
112uk_UA()
0113
=== added directory 'report_aeroo/ctt_languages/uk_UA/currencies'
=== added file 'report_aeroo/ctt_languages/uk_UA/currencies/__init__.py'
--- report_aeroo/ctt_languages/uk_UA/currencies/__init__.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/uk_UA/currencies/__init__.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,3 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3# Please do not edit this file!
04
=== added file 'report_aeroo/ctt_languages/uk_UA/currencies/eur.py'
--- report_aeroo/ctt_languages/uk_UA/currencies/eur.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/uk_UA/currencies/eur.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,21 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class eur(ctt_currency):
7 def _init_currency(self):
8 self.language = u'uk_UA'
9 self.code = u'EUR'
10 self.fractions = 100
11 self.cur_singular = u' евро'
12 self.cur_plural = u' евро'
13 self.frc_singular = u' цент'
14 # default plural form for fractions
15 self.frc_plural = u' центов'
16 self.frc_plural_2to4 = u' цента'
17 # grammatical genders: f - feminine, m - masculine, n -neuter
18 self.cur_gram_gender = 'm'
19 self.frc_gram_gender = 'm'
20
21eur()
022
=== added file 'report_aeroo/ctt_languages/uk_UA/currencies/ltl.py'
--- report_aeroo/ctt_languages/uk_UA/currencies/ltl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/uk_UA/currencies/ltl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class ltl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'uk_UA'
9 self.code = u'LTL'
10 self.fractions = 100
11 self.cur_singular = u' лит'
12 # default plural form for currency
13 self.cur_plural = u' литов'
14 self.cur_plural_2to4 = u' лита'
15 self.frc_singular = u' цент'
16 # default plural form for fractions
17 self.frc_plural = u' центов'
18 self.frc_plural_2to4 = u' цента'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'm'
21 self.frc_gram_gender = 'm'
22
23ltl()
024
=== added file 'report_aeroo/ctt_languages/uk_UA/currencies/lvl.py'
--- report_aeroo/ctt_languages/uk_UA/currencies/lvl.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/uk_UA/currencies/lvl.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class lvl(ctt_currency):
7 def _init_currency(self):
8 self.language = u'uk_UA'
9 self.code = u'LVL'
10 self.fractions = 100
11 self.cur_singular = u' лат'
12 # default plural form for currency
13 self.cur_plural = u' латов'
14 self.cur_plural_2to3 = u' лата'
15 self.frc_singular = u' сантим'
16 # default plural form for fractions
17 self.frc_plural = u' сантимов'
18 self.frc_plural_2to3 = u' сантима'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'm'
21 self.frc_gram_gender = 'm'
22
23lvl()
024
=== added file 'report_aeroo/ctt_languages/uk_UA/currencies/rub.py'
--- report_aeroo/ctt_languages/uk_UA/currencies/rub.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/uk_UA/currencies/rub.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class rub(ctt_currency):
7 def _init_currency(self):
8 self.language = u'uk_UA'
9 self.code = u'RUB'
10 self.fractions = 100
11 self.cur_singular = u' рубль'
12 # default plural form for currency
13 self.cur_plural = u' рублiв'
14 self.cur_plural_2to4 = u' рубля'
15 self.frc_singular = u' копійка'
16 # default plural form for fractions
17 self.frc_plural = u' копійок'
18 self.frc_plural_2to4 = u' копійки'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'm'
21 self.frc_gram_gender = 'f'
22
23rub()
024
=== added file 'report_aeroo/ctt_languages/uk_UA/currencies/uah.py'
--- report_aeroo/ctt_languages/uk_UA/currencies/uah.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/uk_UA/currencies/uah.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class uah(ctt_currency):
7 def _init_currency(self):
8 self.language = u'uk_UA'
9 self.code = u'UAH'
10 self.fractions = 100
11 self.cur_singular = u' гривня'
12 # default plural form for currency
13 self.cur_plural = u' гривень'
14 self.cur_plural_2to4 = u' гривні'
15 self.frc_singular = u' копійка'
16 # default plural form for fractions
17 self.frc_plural = u' копійок'
18 self.frc_plural_2to4 = u' копійки'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'f'
21 self.frc_gram_gender = 'f'
22
23uah()
024
=== added file 'report_aeroo/ctt_languages/uk_UA/currencies/usd.py'
--- report_aeroo/ctt_languages/uk_UA/currencies/usd.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_languages/uk_UA/currencies/usd.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4from report_aeroo.ctt_objects import ctt_currency
5
6class usd(ctt_currency):
7 def _init_currency(self):
8 self.language = u'uk_UA'
9 self.code = u'USD'
10 self.fractions = 100
11 self.cur_singular = u' доллара США'
12 # default plural form for currency
13 self.cur_plural = u' долларов США'
14 self.cur_plural_2to4 = u' доллара США'
15 self.frc_singular = u' цент'
16 # default plural form for fractions
17 self.frc_plural = u' центов'
18 self.frc_plural_2to4 = u' цента'
19 # grammatical genders: f - feminine, m - masculine, n -neuter
20 self.cur_gram_gender = 'm'
21 self.frc_gram_gender = 'm'
22
23usd()
024
=== added file 'report_aeroo/ctt_objects.py'
--- report_aeroo/ctt_objects.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/ctt_objects.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,161 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3################################################################################
4# Developed by Kaspars Vilkens - Alistek Ltd (c) 2011
5#
6# Supported sum: 0 ... 999999999999.99
7# Supported languages: for more reference see languages forlder
8# Supported currencies: see particular language for reference
9################################################################################
10
11import os
12supported_language = {}
13
14if __name__ == '__main__':
15 from sys import exit
16 error = '''This code is part of Report Aeroo package!
17 Not to be used separately...'''
18 exit(error)
19
20def currency_to_text(sum, currency_code, language_code):
21 if language_code not in supported_language:
22 raise Exception('Not supported or no language: %s' % language_code)
23 else:
24 suppl = supported_language[language_code]
25 return suppl.currency_to_text(sum, currency_code)
26
27class ctt_language(object):
28 def _init_lang(self):
29 pass
30
31 def __repr__(self):
32 return self.name
33
34 def __init__(self):
35 self.supported_currency = {}
36 self.minbound = 0
37 self.maxbound = 999999999999.99
38 currencies = self._init_lang()
39 supported_language.update({self.name : self})
40 import_submodules('currency', currencies, 0)
41
42 def check_sum(self):
43 if sum < self.minbound or sum > self.maxbound :
44 raise Exception(\
45 """Sum out of bounds: must be from %s to %s""" % \
46 (str(self.minbound), str(self.maxbound)))
47
48 def check_currency(self):
49 if currency not in supported_currency:
50 raise Exception(\
51 """Unsupported or no currency: must be one of (%s)""" % \
52 ', '.join(self.supported_currency))
53
54 def dtowords(self, sum_integers, gender):
55 diginwords = u''
56 if sum_integers == 0:
57 return self.wordify('0', 0, gender)
58 elif sum_integers > 0:
59 lengthx = len(str(sum_integers))
60 nrchunks = (lengthx / 3)
61 if nrchunks < (float(lengthx) / 3) :
62 nrchunks+=1
63 inc = 1
64 while inc <= nrchunks:
65 startpos = (lengthx - inc * 3)
66 chunklength = 3
67 if startpos < 0:
68 chunklength += startpos
69 startpos = 0
70 chunk = str(sum_integers)[startpos : startpos + chunklength]
71 #print str(startpos)+' '+str(chunklength)+' '+ chunk
72 if inc == 1:
73 wordified = self.wordify(chunk, inc-1, gender)
74 else:
75 wordified = self.wordify(chunk, inc-1, 'm')
76 inc += 1
77 spacer = ''
78 if len(diginwords) > 0 and wordified:
79 spacer = ' '
80 diginwords = wordified + spacer + diginwords
81 return diginwords
82
83
84 def currency_to_text(self, sum, currency):
85 #--------------for currencies with 100 fractions
86 sum = float(sum)
87 sum = round(sum, 2)
88 # find out digits before floating point - currency
89 sum_cur = int(sum)
90 # find out digits after floating point - fractions
91 sum_frc = int(round((sum - sum_cur) * 100,0))
92 curr = self.supported_currency.get(currency)
93 cur_in_words = self.dtowords(sum_cur, curr.cur_gram_gender)
94 frc_in_words = self.dtowords(sum_frc, curr.frc_gram_gender)
95 #------------------------------------
96
97 return (cur_in_words + curr.cur_to_text(sum_cur) + ' ' + frc_in_words +\
98 curr.frc_to_text(sum_frc)).strip().encode('utf-8')
99
100
101class ctt_currency(object):
102 def _init_currency(self):
103 pass
104
105 def __repr__(self):
106 return self.code
107
108 def __init__(self):
109 self._init_currency()
110 suppl = supported_language.get(self.language)
111 suppl.supported_currency.update({self.code : self})
112
113 def cur_to_text(self, sum_cur):
114 # is the currency sum one
115 if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] !='1'):
116 return self.cur_singular
117 # 2,3 and 4 yields different plural form, if defined
118 elif ((sum_cur in [2, 3, 4]) or (str(sum_cur)[-1] in ['2', '3', '4'] \
119 and str(sum_cur)[-2] != '1')) and hasattr(self, 'cur_plural_2to4'):
120 return self.cur_plural_2to4
121 # betwean 1 and 10 yields different plural form, if defined
122 elif (sum_cur > 1 and sum_cur < 10 or (int(str(sum_cur)[-1]) > 1 \
123 and str(sum_cur)[-2] != '1')) and hasattr(self, 'cur_plural_2to10'):
124 return self.cur_plural_2to10
125 # starting from 10 yields uses default plural form
126 else:
127 return self.cur_plural
128
129 def frc_to_text(self, sum_frc):
130 # is the fraction sum one
131 if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] !='1'):
132 return self.frc_singular
133 # 2,3 and 4 yields different plural form, if defined
134 elif ((sum_frc in [2, 3, 4]) or (str(sum_frc)[-1] in ['2', '3', '4'] \
135 and str(sum_frc)[-2] != '1')) and hasattr(self, 'frc_plural_2to4'):
136 return self.frc_plural_2to4
137 # betwean 1 and 10 yields different plural form, if defined
138 elif (sum_frc > 1 and sum_frc < 10 or (int(str(sum_frc)[-1]) > 1 \
139 and str(sum_frc)[-2] != '1')) and hasattr(self, 'frc_plural_2to10'):
140 return self.frc_plural_2to10
141 # starting from 10 yields uses default plural form
142 else:
143 return self.frc_plural
144
145def __filter_names(to_import, package):
146 folder = os.path.split(package.__file__)[0]
147 for name in os.listdir(folder):
148 if to_import == 'currency':
149 if name.endswith(".py") and not name.startswith("__"):
150 yield name[:-3]
151 if to_import == 'language':
152 if len(name) == 5 and not name.startswith("__"):
153 yield name
154
155def import_submodules(to_import, package, level=-1):
156 names = list(__filter_names(to_import, package))
157 m = __import__(package.__name__, globals(), locals(), names, level)
158 return dict((name, getattr(m, name)) for name in names)
159
160import ctt_languages
161import_submodules('language', ctt_languages, 0)
0162
=== added file 'report_aeroo/currency_to_text.py'
--- report_aeroo/currency_to_text.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/currency_to_text.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,491 @@
1#!/usr/bin/python
2# -*- coding: utf8 -*-
3
4###########################################################
5# Developed by Kaspars Vilkens - Alistek Ltd (c) 2011
6# pep-8, unicode and doctests by Paul Stevens, paul@nfg.nl, 2010
7#
8# Supported currencies: LVL, EUR, USD, UAH
9# Supported sum: 0 ... 999999999999.99
10# Supported languages: lv_LV, en_US, ru_RU, uk_UA
11###########################################################
12import string
13
14supported_currency = ['LVL','EUR','USD', 'UAH']
15supported_language = ['lv_LV','en_US','ru_RU', 'uk_UA']
16
17def currency_to_text(sum, currency, language):
18 """
19
20 first some simple tests
21
22 >>> currency_to_text(123, 'EUR', 'en_US')
23 'one hundred twenty three euros zero cents'
24
25 >>> currency_to_text(1.11, 'EUR', 'en_US')
26 'one euro eleven cents'
27
28 >>> currency_to_text(1.10, 'USD', 'en_US')
29 'one US dollar ten cents'
30
31 >>> currency_to_text(1.01, 'USD', 'en_US')
32 'one US dollar one cent'
33
34 >>> currency_to_text(1.01, 'LVL', 'lv_LV') == 'viens lats viens santīms'
35 True
36
37 >>> currency_to_text(123.12, 'LVL', 'ru_RU') == 'стo двaдцать три лата двенадцать сантимов'
38 True
39
40 >>> currency_to_text(123.12, 'USD', 'ru_RU') == 'стo двaдцать три доллара США двенадцать центов'
41 True
42
43
44 """
45 if sum < 0 or sum > 999999999999.99 :
46 raise Exception('Sum out of bounds: must be from 0 to 999999999999.99')
47 if currency not in supported_currency:
48 raise Exception("""Unsupported or no currency: must be one of (%s)""" % \
49 string.join(supported_currency,','))
50 if language not in supported_language:
51 raise Exception("""Unsupported or no language: must be one of (%s)""" % \
52 string.join(supported_language,','))
53#--------------for currencies with 100 fractions
54 sum = float(sum)
55 sum = round(sum, 2)
56 # find out digits before floating point - currency
57 sum_cur = int(sum)
58 # find out digits after floating point - fractions
59 sum_frc = int(round((sum - sum_cur) * 100,0))
60 cur_in_words = dtowords(sum_cur, language)
61 #print cur_in_words
62 frc_in_words = dtowords(sum_frc, language)
63 #print frc_in_words
64 #------------------------------------
65 if language == 'lv_LV' :
66 if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1'): # is the currency sum one
67 if currency == 'LVL':
68 cur_in_words += u' lats'
69 elif currency == 'EUR':
70 cur_in_words += u' eiro'
71 elif currency == 'USD':
72 cur_in_words += u' dolārs'
73 elif currency == 'UAH':
74 cur_in_words += u' grivna'
75 else:
76 if currency == 'LVL':
77 cur_in_words += u' lati'
78 elif currency == 'EUR':
79 cur_in_words += u' eiro'
80 elif currency == 'USD':
81 cur_in_words += u' dolāri'
82 elif currency == 'UAH':
83 cur_in_words += u' grivnas'
84
85 if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] != '1'): # is the fraction sum one
86 if currency == 'LVL':
87 frc_in_words += u' santīms'
88 elif currency == 'EUR' or currency == 'USD' :
89 frc_in_words += u' cents'
90 elif currency == 'UAH':
91 frc_in_words += u' kapeika'
92 else:
93 if currency == 'LVL':
94 frc_in_words += u' santīmi'
95 elif currency == 'EUR' or currency == 'USD':
96 frc_in_words += u' centi'
97 elif currency == 'UAH':
98 frc_in_words += u' kapeikas'
99 #------------------------------------
100 if language == 'en_US' :
101 if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1'): # is the currency sum one
102 if currency == 'LVL':
103 cur_in_words += u' Latvian lats'
104 elif currency == 'EUR':
105 cur_in_words += u' euro'
106 elif currency == 'USD':
107 cur_in_words += u' US dollar'
108 else:
109 if currency == 'LVL':
110 cur_in_words += u' Latvian lats'
111 elif currency == 'EUR':
112 cur_in_words += u' euros'
113 elif currency == 'USD':
114 cur_in_words += u' dollars'
115 if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] != '1'): # is the fraction sum one
116 if currency == 'LVL':
117 frc_in_words += u' santim'
118 elif currency == 'EUR' or currency == 'USD':
119 frc_in_words += u' cent'
120 else:
121 if currency == 'LVL':
122 frc_in_words += u' santims'
123 elif currency == 'EUR' or currency == 'USD' :
124 frc_in_words += u' cents'
125 #------------------------------------
126 if language == 'ru_RU' :
127 if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1'): # is the currency sum one
128 if currency == 'LVL':
129 cur_in_words += u' лат'
130 elif currency == 'EUR':
131 cur_in_words += u' евро'
132 elif currency == 'USD':
133 cur_in_words += u' доллар США'
134 elif (sum_cur in [2, 3, 4]) or (str(sum_cur)[-1] in ['2', '3', '4'] and str(sum_cur)[-2] != '1'):
135 if currency == 'LVL':
136 cur_in_words += u' лата'
137 elif currency == 'EUR' :
138 cur_in_words += u' евро'
139 elif currency == 'USD' :
140 cur_in_words += u' доллара США'
141 elif (sum_cur >= 5 and sum_cur <= 20) or str(sum_cur)[-1] not in [2, 3, 4]:
142 if currency == 'LVL' :
143 cur_in_words += u' латов'
144 elif currency == 'EUR' :
145 cur_in_words += u' евро'
146 elif currency == 'USD' :
147 cur_in_words += u' долларов США'
148
149 if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] != '1') : # is the fraction one
150 if currency == 'LVL' :
151 frc_in_words += u' сантим'
152 elif currency == 'EUR' or currency == 'USD' :
153 frc_in_words += u' цент'
154 elif (sum_frc in [2, 3, 4]) or (str(sum_frc)[-1] in ['2', '3', '4'] and str(sum_frc)[-2] != '1') :
155 if currency == 'LVL' :
156 frc_in_words += u' сантима'
157 elif currency == 'EUR' or currency == 'USD' :
158 frc_in_words += u' цента'
159 elif (sum_frc >= 5 and sum_frc <= 20) or str(sum_frc)[-1] not in [2, 3, 4] :
160 if currency == 'LVL' :
161 frc_in_words += u' сантимов'
162 elif currency == 'EUR' or currency == 'USD' :
163 frc_in_words += u' центов'
164 #------------------------------------
165 if language == 'uk_UA' :
166 if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1') : # is the currency sum one
167 if currency == 'LVL' :
168 cur_in_words += u' лат'
169 elif currency == 'EUR' :
170 cur_in_words += u' евро'
171 elif currency == 'USD' :
172 cur_in_words += u' доллар США'
173 elif currency == 'UAH' :
174 cur_in_words += u' гривня'
175 elif (sum_cur in [2, 3, 4]) or (str(sum_cur)[-1] in ['2', '3', '4'] and str(sum_cur)[-2] != '1') :
176 if currency == 'LVL' :
177 cur_in_words += u' лата'
178 elif currency == 'EUR' :
179 cur_in_words += u' евро'
180 elif currency == 'USD' :
181 cur_in_words += u' доллара США'
182 elif currency == 'UAH' :
183 cur_in_words += u' гривні'
184 elif (sum_cur >= 5 and sum_cur <= 20) or str(sum_cur)[-1] not in [2, 3, 4] :
185 if currency == 'LVL' :
186 cur_in_words += u' латов'
187 elif currency == 'EUR' :
188 cur_in_words += u' евро'
189 elif currency == 'USD' :
190 cur_in_words += u' долларов США'
191 elif currency == 'UAH' :
192 cur_in_words += u' гривень'
193
194 if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] != '1') : # is the fraction one
195 if currency == 'LVL' :
196 frc_in_words += u' сантим'
197 elif currency == 'EUR' or currency == 'USD' :
198 frc_in_words += u' цент'
199 elif currency == 'UAH' :
200 frc_in_words += u' копійка'
201 elif (sum_frc in [2, 3, 4]) or (str(sum_frc)[-1] in ['2', '3', '4'] and str(sum_frc)[-2] != '1') :
202 if currency == 'LVL' :
203 frc_in_words += u' сантима'
204 elif currency == 'EUR' or currency == 'USD' :
205 frc_in_words += u' цента'
206 elif currency == 'UAH' :
207 frc_in_words += u' копійки'
208 elif (sum_frc >= 5 and sum_frc <= 20) or str(sum_frc)[-1] not in [2, 3, 4] :
209 if currency == 'LVL' :
210 frc_in_words += u' сантимов'
211 elif currency == 'EUR' or currency == 'USD' :
212 frc_in_words += u' центов'
213 elif currency == 'UAH' :
214 frc_in_words += u' копійок'
215 frc_in_words = str(sum_frc) + u' коп.'
216
217 return (cur_in_words + ' ' + frc_in_words).strip().encode('utf-8')
218
219
220def dtowords(sum_integers, language):
221 """
222 >>> dtowords(0, 'en_US')
223 u'zero'
224
225 >>> dtowords(1, 'en_US')
226 u'one'
227
228 >>> dtowords(11, 'en_US')
229 u'eleven'
230
231 >>> dtowords(169, 'en_US')
232 u'one hundred sixty nine'
233
234 >>> dtowords(12345, 'en_US')
235 u'twelve thousand three hundred fourty five'
236
237 >>> dtowords(123456, 'en_US')
238 u'one hundred twenty three thousand four hundred fifty six'
239
240 >>> dtowords(0, 'lv_LV')
241 u'nulle'
242
243 >>> dtowords(1, 'lv_LV')
244 u'viens'
245
246 >>> dtowords(11, 'lv_LV')
247 u'vienpadsmit'
248
249 >>> dtowords(169, 'lv_LV').encode('utf-8') == 'simts sešdesmit deviņi'
250 True
251
252 >>> dtowords(12345, 'lv_LV').encode('utf-8') == 'divpadsmit tūkstoši trīs simti četrdesmit pieci'
253 True
254
255 >>> dtowords(123456, 'lv_LV').encode('utf-8') == 'simts divdesmit trīs tūkstoši četri simti piecdesmit seši'
256 True
257
258 >>> dtowords(0, 'ru_RU').encode('utf-8') == 'ноль'
259 True
260
261 >>> dtowords(1, 'ru_RU').encode('utf-8') == 'один'
262 True
263
264 >>> dtowords(11, 'ru_RU').encode('utf-8') == 'одиннадцать'
265 True
266
267 >>> dtowords(169, 'ru_RU').encode('utf-8') == 'стo шестьдесят девять'
268 True
269
270 >>> dtowords(12345, 'ru_RU').encode('utf-8') == 'двенадцать тысяч триста сорок пять'
271 True
272
273 >>> dtowords(123456, 'ru_RU').encode('utf-8') == 'стo двaдцать три тысячи четыреста пятьдесят шесть'
274 True
275
276
277 """
278 diginwords = u''
279 if sum_integers == 0:
280 return wordify('0', 0, language)
281 elif sum_integers > 0:
282 lengthx = len(str(sum_integers))
283 nrchunks = (lengthx / 3)
284 if nrchunks < (float(lengthx) / 3) :
285 nrchunks+=1
286 inc = 1
287 while inc <= nrchunks:
288 startpos = (lengthx - inc * 3)
289 chunklength = 3
290 if startpos < 0:
291 chunklength += startpos
292 startpos = 0
293 chunk = str(sum_integers)[startpos : startpos + chunklength]
294 #print str(startpos)+' '+str(chunklength)+' '+ chunk
295 wordified = wordify(chunk, inc-1, language)
296 inc += 1
297 spacer = ''
298 if len(diginwords) > 0 :
299 spacer = ' '
300 diginwords = wordified + spacer + diginwords
301 return diginwords
302
303def wordify(chunk, chunknr, language):
304 #print 'chunk '+str(chunk)
305 #print 'cunknr '+str(chunknr)
306 words = u''
307
308 if language == 'lv_LV':
309 skaitli = [u'nulle', u'viens', u'divi', u'trīs', u'četri', u'pieci',
310 u'seši', u'septiņi', u'astoņi', u'deviņi']
311 skaitlix = [u'nulle', u'vien', u'div', u'trīs', u'četr', u'piec', u'seš',
312 u'septiņ', u'astoņ', u'deviņ']
313 skaitli_teens = [u'desmit', u'vienpadsmit', u'divpadsmit', u'trīspadsmit',
314 u'četrpadsmit', u'piecpadsmit', u'sešpadsmit',
315 u'septiņpadsmit', u'astoņpadsmit', u'deviņpadsmit']
316 daudzums = [u'simts', u' tūkstotis', u' miljons', u' miljards']
317 daudzumsx = [u' simti', u' tūkstoši', u' miljoni', u' miljardi']
318
319 elif language == 'en_US':
320 skaitli = [u'zero', u'one', u'two', u'three', u'four', u'five', u'six',
321 u'seven', u'eight', u'nine']
322 skaitlix = [u'zero', u'one', u'twen', u'thir', u'four', u'fif', u'six',
323 u'seven', u'eigh', u'nine']
324 skaitli_teens = [u'ten', u'eleven', u'twelve', u'thirteen', u'fourteen',
325 u'fifteen', u'sixteen', u'seventeen', u'eighteen', u'nineteen']
326 daudzums = [u' hundred', u' thousand', u' million', u' billion']
327 daudzumsx = daudzums
328
329 elif language == 'ru_RU':
330 skaitli = [u'ноль', u'один', u'два', u'три', u'четыре', u'пять', u'шесть',
331 u'семь', u'восемь', u'девять']
332 skaitlix = [u'', u'один', u'двa', u'три', u'четыре', u'пять', u'шесть',
333 u'семь', u'восемь', u'девять']
334 skaitli_teens = [u'десять', u'одиннадцать', u'двенадцать', u'тринадцать',
335 u'четырнадцать', u'пятнадцать', u'шестнадцать', u'семнадцать',
336 u'восемнадцать', u'девятнадцать']
337 daudzums = [u'стo', u' тысяча', u' миллион', u' миллиард']
338 daudzumsx = [u'сoт', u' тысяч', u' миллионов', u' миллиардов']
339
340 elif language == 'uk_UA' :
341 skaitli = [u'ноль', u'один', u'два', u'три', u'чотири', u'п\'ять', u'шість',
342 u'сім', u'вісім', u'дев\'ять']
343 skaitlix = [u'', u'один', u'двa', u'три', u'чотири', u'п\'ять', u'шість',
344 u'сім', u'вісім', u'дев\'ять']
345 skaitli_teens = [u'десять', u'одинадцять', u'дванадцять', u'тринадцять',
346 u'чотирнадцять', u'п\'ятнадцять', u'шістнадцять', u'сімнадцять',
347 u'вісімнадцять', u'дев\'ятнадцять']
348 daudzums = [u'стo', u' тисяча', u' мiллiон', u' мiллiард']
349 daudzumsx = [u'сoт', u' тисяч', u' мiллiонiв', u' мiллiардов']
350 digit1 = u''
351 digit2 = u''
352 digit3 = u''
353 chunklength = len(chunk)
354 # placing digits in right places
355 if chunklength == 1:
356 digit3 = chunk[0 : 1]
357 if chunklength == 2:
358 digit2 = chunk[0 : 1]
359 digit3 = chunk[1 : 2]
360 if chunklength == 3:
361 digit1 = chunk[0 : 1]
362 digit2 = chunk[1 : 2]
363 digit3 = chunk[-1]
364 # processing zero
365 if chunklength == 1 and digit3 == '0' :
366 return skaitli[0]
367 # processing hundreds
368 if chunklength == 3 :
369 if digit1 == '1' :
370 if language == 'lv_LV' or language == 'ru_RU' or language == 'uk_UA':
371 words += daudzums[0]
372 elif language == 'en_US' :
373 words += skaitli[int(digit1)] + daudzumsx[0]
374 else :
375 if language == 'lv_LV' :
376 if int(digit1) > 1 : words += skaitli[int(digit1)] + daudzumsx[0]
377 elif language == 'en_US' :
378 if int(digit1) > 1 : words += skaitli[int(digit1)] + daudzumsx[0]
379 elif language == 'ru_RU' :
380 if int(digit1) == 2 :
381 words += u'двести'
382 elif int(digit1) == 3 :
383 words += u'триста'
384 elif int(digit1) == 4 :
385 words += u'четыреста'
386 elif int(digit1) >= 5 :
387 words += skaitli[int(digit1)] + daudzumsx[0]
388 elif language == 'uk_UA' :
389 if int(digit1) == 2 :
390 words += u'двісті'
391 elif int(digit1) == 3 :
392 words += u'триста'
393 elif int(digit1) == 4 :
394 words += u'чотириста'
395 elif int(digit1) >= 5 :
396 words += skaitli[int(digit1)] + daudzumsx[0]
397 # processing tens
398 if chunklength > 1:
399 spacer = ''
400 if len(words) > 0 : spacer = ' '
401 if digit2 == '1':
402 if language == 'lv_LV' or language == 'en_US' or language == 'ru_RU' or language == 'uk_UA':
403 words += spacer + skaitli_teens[int(digit3)]
404 else:
405 if language == 'lv_LV':
406 if int(digit2) > 1 and int(digit2) > 0:
407 words += spacer + skaitlix[int(digit2)] + u'desmit'
408 elif language == 'en_US':
409 if int(digit2) > 1 and int(digit2) > 0:
410 words += spacer + skaitlix[int(digit2)] + u'ty'
411 elif language == 'ru_RU':
412 if int(digit2) > 1 and int(digit2) < 4:
413 words += spacer + skaitlix[int(digit2)] + u'дцать'
414 elif digit2 == '4':
415 words += spacer + u'сорок'
416 elif int(digit2) >= 5 and int(digit2) != 9:
417 words += spacer + skaitlix[int(digit2)] + u'десят'
418 elif digit2 == '9':
419 words += spacer + u'девяносто'
420 elif language == 'uk_UA' :
421 if int(digit2) > 1 and int(digit2) < 4:
422 words += spacer + skaitlix[int(digit2)] + u'дцять'
423 elif digit2 == '4':
424 words += spacer + u'сорок'
425 elif int(digit2) >= 5 and int(digit2) != 9:
426 words += spacer + skaitlix[int(digit2)] + u'десят'
427 elif digit2 == '9':
428 words += spacer + u'дев\'яносто'
429 # processing ones
430 if chunklength > 0 and digit2 != '1' :
431 spacer = ''
432 if len(words) > 0: spacer = u' '
433 if language == 'lv_LV' or language == 'en_US':
434 if int(digit3) > 0:
435 words += spacer + skaitli[int(digit3)]
436 elif language == 'ru_RU':
437 if chunknr == 1:
438 if int(digit3) == 1:
439 words += spacer + u'одна'
440 elif int(digit3) == 2:
441 words += spacer + u'две'
442 elif int(digit3) >= 3 and int(digit3) != 0:
443 words += spacer + skaitli[int(digit3)]
444 else:
445 if int(digit3) > 0: words += spacer + skaitli[int(digit3)]
446 elif language == 'uk_UA' :
447 if chunknr == 1 :
448 if int(digit3) == 1 : words += spacer + u'одна'
449 elif int(digit3) == 2 : words += spacer + u'дві'
450 elif int(digit3) >= 3 and int(digit3) != 0: words += spacer + skaitli[int(digit3)]
451 else:
452 if int(digit3) > 0 : words += spacer + skaitli[int(digit3)]
453 # end processing
454 if len(words) > 0 :
455
456 if digit3 == '1' and chunknr > 0:
457 return words + daudzums[chunknr]
458 elif digit3 != '1' and chunknr > 0:
459 if language == 'lv_LV' or language == 'en_US' :
460 return words + daudzumsx[chunknr]
461 elif language == 'ru_RU' :
462 if (int(digit3) == 2 or int(digit3) == 3 or int(digit3) == 4) and digit2 != '1' :
463 if chunknr == 1 :
464 return words + u' тысячи'
465 elif chunknr == 2 :
466 return words + u' миллионa'
467 elif chunknr == 3 :
468 return words + u' миллиардa'
469 else:
470 return words + daudzumsx[chunknr]
471 elif language == 'uk_UA' :
472 if (int(digit3) == 2 or int(digit3) == 3 or int(digit3) == 4) and digit2 != '1' :
473 if chunknr == 1 :
474 return words + u' тисячі'
475 elif chunknr == 2 :
476 return words + u' мілліонa'
477 elif chunknr == 3 :
478 return words + u' мілліардa'
479 else:
480 return words + daudzumsx[chunknr]
481 else:
482 return words
483 else:
484 return ''
485
486
487if __name__ == '__main__':
488 import doctest
489 doctest.testmod()
490
491# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0492
=== added directory 'report_aeroo/data'
=== added file 'report_aeroo/data/report_aeroo_data.xml'
--- report_aeroo/data/report_aeroo_data.xml 1970-01-01 00:00:00 +0000
+++ report_aeroo/data/report_aeroo_data.xml 2014-04-05 13:18:49 +0000
@@ -0,0 +1,25 @@
1<?xml version="1.0"?>
2<openerp>
3 <data noupdate="1">
4
5 <record model="report.mimetypes" id="report_mimetypes_odt_odt" >
6 <field name="name">ODF Text Document (.odt)</field>
7 <field name="code">oo-odt</field>
8 <field name="compatible_types">oo-odt</field>
9 </record>
10
11 <record model="report.mimetypes" id="report_mimetypes_ods_ods" >
12 <field name="name">ODF Spreadsheet (.ods)</field>
13 <field name="code">oo-ods</field>
14 <field name="compatible_types">oo-ods</field>
15 </record>
16
17 <record model="report.mimetypes" id="report_mimetypes_raw" >
18 <field name="name">Generic</field>
19 <field name="code">genshi-raw</field>
20 <field name="compatible_types">genshi-raw</field>
21 </record>
22
23 </data>
24</openerp>
25
026
=== added file 'report_aeroo/domain_parser.py'
--- report_aeroo/domain_parser.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/domain_parser.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,49 @@
1##############################################################################
2#
3# Copyright (c) 2009-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
4# General contacts <info@alistek.com>
5#
6# WARNING: This program as such is intended to be used by professional
7# programmers who take the whole responsability of assessing all potential
8# consequences resulting from its eventual inadequacies and bugs
9# End users who are looking for a ready-to-use solution with commercial
10# garantees and support are strongly adviced to contract a Free Software
11# Service Company
12#
13# This program is Free Software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation; either version 3
16# of the License, or (at your option) any later version.
17#
18# This module is GPLv3 or newer and incompatible
19# with OpenERP SA "AGPL + Private Use License"!
20#
21# This program is distributed in the hope that it will be useful,
22# but WITHOUT ANY WARRANTY; without even the implied warranty of
23# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24# GNU General Public License for more details.
25#
26# You should have received a copy of the GNU General Public License
27# along with this program; if not, write to the Free Software
28# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29#
30##############################################################################
31
32def domain2statement(domain):
33 statement=''
34 operator=False
35 for d in domain:
36 if not operator:
37 if type(d)==str:
38 if d=='|':
39 operator=' or'
40 continue
41 else:
42 operator=False
43 statement+=' o.'+str(d[0])+' '+(d[1]=='=' and '==' or d[1])+' '+(isinstance(d[2], str) and '\''+d[2]+'\'' or str(d[2]))
44 if d!=domain[-1]:
45 statement+=operator or ' and'
46 operator=False
47 return statement
48
49# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
050
=== added file 'report_aeroo/installer.py'
--- report_aeroo/installer.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/installer.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,79 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (c) 2008-2013 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
5# General contacts <info@alistek.com>
6#
7# WARNING: This program as such is intended to be used by professional
8# programmers who take the whole responsability of assessing all potential
9# consequences resulting from its eventual inadequacies and bugs
10# End users who are looking for a ready-to-use solution with commercial
11# garantees and support are strongly adviced to contract a Free Software
12# Service Company
13#
14# This program is Free Software; you can redistribute it and/or
15# modify it under the terms of the GNU General Public License
16# as published by the Free Software Foundation; either version 3
17# of the License, or (at your option) any later version.
18#
19# This module is GPLv3 or newer and incompatible
20# with OpenERP SA "AGPL + Private Use License"!
21#
22# This program is distributed in the hope that it will be useful,
23# but WITHOUT ANY WARRANTY; without even the implied warranty of
24# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25# GNU General Public License for more details.
26#
27# You should have received a copy of the GNU General Public License
28# along with this program; if not, write to the Free Software
29# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30#
31##############################################################################
32from openerp.osv import orm, fields
33from openerp import netsvc
34from openerp import tools
35import os, base64
36import urllib2
37
38_url = 'http://www.alistek.com/aeroo_banner/v7_0_report_aeroo.png'
39
40class report_aeroo_installer(orm.TransientModel):
41 _name = 'report.aeroo.installer'
42 _inherit = 'res.config.installer'
43 _logo_image = None
44
45 def _get_image(self, cr, uid, context=None):
46 if self._logo_image:
47 return self._logo_image
48 try:
49 im = urllib2.urlopen(_url.encode("UTF-8"))
50 if im.headers.maintype!='image':
51 raise TypeError(im.headers.maintype)
52 except Exception, e:
53 path = os.path.join('report_aeroo','config_pixmaps','module_banner.png')
54 image_file = file_data = tools.file_open(path,'rb')
55 try:
56 file_data = image_file.read()
57 self._logo_image = base64.encodestring(file_data)
58 return self._logo_image
59 finally:
60 image_file.close()
61 else:
62 self._logo_image = base64.encodestring(im.read())
63 return self._logo_image
64
65 def _get_image_fn(self, cr, uid, ids, name, args, context=None):
66 image = self._get_image(cr, uid, context)
67 return dict.fromkeys(ids, image) # ok to use .fromkeys() as the image is same for all
68
69 _columns = {
70 'link':fields.char('Original developer', size=128, readonly=True),
71 'config_logo': fields.function(_get_image_fn, string='Image', type='binary', method=True),
72 }
73
74 _defaults = {
75 'config_logo': _get_image,
76 'link':'http://www.alistek.com',
77 }
78
79# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
080
=== added file 'report_aeroo/installer.xml'
--- report_aeroo/installer.xml 1970-01-01 00:00:00 +0000
+++ report_aeroo/installer.xml 2014-04-05 13:18:49 +0000
@@ -0,0 +1,56 @@
1<openerp>
2 <data>
3
4 <record id="view_report_aeroo_installer" model="ir.ui.view">
5 <field name="name">report.aeroo.installer.view</field>
6 <field name="model">report.aeroo.installer</field>
7 <field name="type">form</field>
8 <field name="inherit_id" ref="base.res_config_installer"/>
9 <field name="arch" type="xml">
10 <data>
11 <form position="attributes" version="7.0">
12 <attribute name="string">Aeroo Reports Installation</attribute>
13 </form>
14 <footer position="replace">
15 <footer>
16 <button name="action_next" type="object" string="Continue" invisible="context.get('menu',False)" class="oe_highlight"/>
17 or
18 <button special="cancel" string="Close" class="oe_link"/>
19 </footer>
20 </footer>
21 <separator string="title" position="replace">
22 <p class="oe_grey">
23 Aeroo Reports for OpenERP is a comprehensive reporting engine based on Aeroo Library.
24 </p>
25 <group>
26 <group width="25%%">
27 <field name="config_logo" widget="image" nolabel="1" colspan="2"/>
28 </group>
29 <group width="75%%">
30 <field name="link" widget="url"/>
31 </group>
32 </group>
33 </separator>
34 </data>
35 </field>
36 </record>
37
38 <record id="action_report_aeroo_installer" model="ir.actions.act_window">
39 <field name="name">Aeroo Reports Installation</field>
40 <field name="type">ir.actions.act_window</field>
41 <field name="res_model">report.aeroo.installer</field>
42 <field name="view_id" ref="view_report_aeroo_installer"/>
43 <field name="view_type">form</field>
44 <field name="view_mode">form</field>
45 <field name="target">new</field>
46 </record>
47
48 <record id="report_aeroo_installer_todo" model="ir.actions.todo">
49 <field name="action_id" ref="action_report_aeroo_installer"/>
50 <field name="restart">always</field>
51 <field name="sequence">3</field>
52 <field name="type">automatic</field>
53 </record>
54
55 </data>
56</openerp>
057
=== added file 'report_aeroo/report_aeroo.py'
--- report_aeroo/report_aeroo.py 1970-01-01 00:00:00 +0000
+++ report_aeroo/report_aeroo.py 2014-04-05 13:18:49 +0000
@@ -0,0 +1,859 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (c) 2009-2013 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
5# General contacts <info@alistek.com>
6# Copyright (C) 2009 Domsense s.r.l.
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsability of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs
11# End users who are looking for a ready-to-use solution with commercial
12# garantees and support are strongly adviced to contract a Free Software
13# Service Company
14#
15# This program is Free Software; you can redistribute it and/or
16# modify it under the terms of the GNU General Public License
17# as published by the Free Software Foundation; either version 3
18# of the License, or (at your option) any later version.
19#
20# This module is GPLv3 or newer and incompatible
21# with OpenERP SA "AGPL + Private Use License"!
22#
23# This program is distributed in the hope that it will be useful,
24# but WITHOUT ANY WARRANTY; without even the implied warranty of
25# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26# GNU General Public License for more details.
27#
28# You should have received a copy of the GNU General Public License
29# along with this program; if not, write to the Free Software
30# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31#
32##############################################################################
33
34import os, sys, traceback
35from tempfile import NamedTemporaryFile
36from openerp import report
37from report.report_sxw import report_sxw, report_rml, browse_record_list, _fields_process
38from report.pyPdf import PdfFileWriter, PdfFileReader
39#import zipfile
40try:
41 from cStringIO import StringIO
42except ImportError:
43 from StringIO import StringIO
44from xml.dom import minidom
45import base64
46from openerp.osv import orm
47from openerp import tools
48from tools.translate import _
49import time
50import re
51import copy
52import threading
53from random import randint
54try:
55 from addons import load_information_from_description_file # for OpenERP 6.0.x
56except ImportError:
57 from openerp.modules import load_information_from_description_file # for OpenERP 6.1 or 7.0
58from openerp import release
59
60import aeroolib
61from aeroolib.plugins.opendocument import Template, OOSerializer
62from genshi.template import NewTextTemplate
63from genshi import __version__ as genshi_version
64from openerp import pooler
65from openerp import netsvc
66from lxml import etree
67import logging
68
69logger = logging.getLogger(__name__)
70
71from .ExtraFunctions import ExtraFunctions
72
73try:
74 aeroo_lock = threading.Lock()
75 msg = "Aeroo lock instantiated."
76 logger.log(logging.INFO, msg)
77except Exception:
78 err_msg = "Could not instantiate Aeroo lock!!!"
79 logger.log(logging.CRITICAL, err_msg)
80
81from openerp import SUPERUSER_ID
82
83def _aeroo_ooo_test(cr):
84 '''
85 Detect report_aeroo_ooo module
86 '''
87 aeroo_ooo = False
88 cr.execute("SELECT id, state FROM ir_module_module WHERE name='report_aeroo_ooo'")
89 helper_module = cr.dictfetchone()
90 if helper_module and helper_module['state'] in ('installed', 'to upgrade'):
91 aeroo_ooo = True
92 return aeroo_ooo
93
94class Counter(object):
95 def __init__(self, name, start=0, interval=1):
96 self.name = name
97 self._number = start
98 self._interval = interval
99
100 def next(self, increment=True):
101 if increment:
102 self._number += self._interval
103 return self._number
104 else:
105 return self._number + self._interval
106
107 def get_inc(self):
108 return self._number
109
110 def prev(self, decrement=True):
111 if decrement:
112 self._number -= self._interval
113 return self._number
114 else:
115 return self._number-self._interval
116
117class AerooPrint(object):
118 print_ids = [] # static property
119 def __init__(self):
120 print_id = False
121 while(not print_id or print_id in self.print_ids):
122 print_id = randint(1, 99999)
123 self.print_ids.append(print_id)
124 self.id = print_id
125 self.subreports = []
126 self.epl_images = []
127 self.counters = {}
128 self.start_time = 0
129 self.start_total_time = 0
130
131class Aeroo_report(report_sxw):
132
133 _logger = logging.getLogger(__name__)
134
135 def __init__(self, cr, name, table, rml=False, parser=False, header=True, store=False):
136 super(Aeroo_report, self).__init__(name, table, rml, parser, header, store)
137 self._logger.info("registering %s (%s)" % (name, table))
138 self.active_prints = {}
139 self.oo_subreports = []
140 self.epl_images = []
141 self.counters = {}
142 self.start_time = 0
143
144 pool = pooler.get_pool(cr.dbname)
145 ir_obj = pool.get('ir.actions.report.xml')
146 name = name.startswith('report.') and name[7:] or name
147 try:
148 report_xml_ids = ir_obj.search(cr, SUPERUSER_ID, [('report_name', '=', name)])
149 if report_xml_ids:
150 report_xml = ir_obj.browse(cr, SUPERUSER_ID, report_xml_ids[0])
151 else:
152 report_xml = False
153
154 if report_xml and report_xml.preload_mode == 'preload':
155 file_data = report_xml.report_sxw_content
156 if not file_data:
157 self._logger.warning("template is not defined in %s (%s) !" % (name, table))
158 template_io = None
159 else:
160 template_io = StringIO()
161 template_io.write(base64.decodestring(file_data))
162 style_io=self.get_styles_file(cr, SUPERUSER_ID, report_xml)
163 if template_io:
164 self.serializer = OOSerializer(template_io, oo_styles=style_io)
165 except Exception, e:
166 print e
167
168 def getObjects_mod(self, cr, uid, ids, rep_type, context):
169 table_obj = pooler.get_pool(cr.dbname).get(self.table)
170 if rep_type=='aeroo':
171 return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context)
172 return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context)
173
174 ##### Counter functions #####
175 def _def_inc(self, aeroo_print):
176 def def_inc(name, start=0, interval=1):
177 aeroo_print.counters[name] = Counter(name, start, interval)
178 return def_inc
179
180 def _get_inc(self, aeroo_print):
181 def get_inc(name):
182 return aeroo_print.counters[name].get_inc()
183 return get_inc
184
185 def _prev(self, aeroo_print):
186 def prev(name):
187 return aeroo_print.counters[name].prev()
188 return prev
189
190 def _next(self, aeroo_print):
191 def next(name):
192 return aeroo_print.counters[name].next()
193 return next
194 #############################
195
196 def _epl_asimage(self, data, aeroo_print):
197 from PIL import Image
198 from math import ceil
199 if not data:
200 return ''
201 img = Image.open(StringIO(base64.decodestring(data)))
202 if img.format!='BMP':
203 return ''
204 data = base64.decodestring(data)[62:]
205 line_len = int(ceil(img.size[0]/32.0)*4)
206 temp_data = ''
207 for n in range(img.size[1]):
208 curr_pos = n*line_len
209 temp_data = data[curr_pos:curr_pos+line_len][:int(img.size[0]/8)] + temp_data
210
211 new_data = ''
212 for d in temp_data:
213 new_data += chr(ord(d)^255)
214 aeroo_print.epl_images.append(new_data)
215 return img.size
216
217 def _epl2_gw(self, aeroo_print):
218 def epl2_gw(start_x, start_y, data):
219 if not data:
220 return None
221 size_x, size_y = self._epl_asimage(data, aeroo_print)
222 return 'GW'+str(start_x)+','+str(start_y)+','+str(int(size_x/8))+','+str(size_y)+',<binary_data>'
223 return epl2_gw
224
225 def _include_document(self, print_id, aeroo_ooo=False):
226 def include_document(data, silent=False):
227 if not aeroo_ooo:
228 return _("Error! Include document not available!")
229 import binascii, urllib2
230 temp_file = NamedTemporaryFile(suffix='.odt', prefix='aeroo-report-', delete=False)
231 if os.path.isfile(data):
232 fd = file(data, 'rb')
233 data = fd.read()
234 else:
235 error = False
236 try:
237 url_file = urllib2.urlopen(data)
238 data = url_file.read()
239 except urllib2.HTTPError, e:
240 os.unlink(temp_file.name)
241 error = _('HTTP Error %s! File not found:') % e.getcode() + ' %s' % data
242 except urllib2.URLError, e:
243 os.unlink(temp_file.name)
244 error = _('Error!')+' %s' % e
245 except IOError, e:
246 os.unlink(temp_file.name)
247 error = _('Error!')+' %s' % e
248 except Exception, e:
249 try:
250 data = base64.decodestring(data)
251 except binascii.Error:
252 os.unlink(temp_file.name)
253 error = _('Error! File not found:')+' %s' % data
254 if error:
255 if not silent:
256 return error
257 else:
258 return None
259 try:
260 temp_file.write(data)
261 finally:
262 temp_file.close()
263 #self.oo_subreports[print_id].append(temp_file.name)
264 self.active_prints[print_id].subreports.append(temp_file.name)
265 return "<insert_doc('%s')>" % temp_file.name
266 return include_document
267
268 def _subreport(self, cr, uid, aeroo_print, output='odt', aeroo_ooo=False, context={}):
269 pool = pooler.get_pool(cr.dbname)
270 ir_obj = pool.get('ir.actions.report.xml')
271 #### for odt documents ####
272 def odt_subreport(name=None, obj=None):
273 if not aeroo_ooo:
274 return _("Error! Subreports not available!")
275 report_xml_ids = ir_obj.search(cr, uid, [('report_name', '=', name)], context=context)
276 if report_xml_ids:
277 service = netsvc.Service._services['report.%s' % name]
278 report_xml = ir_obj.browse(cr, uid, report_xml_ids[0], context=context)
279 data = {'model': obj._table_name, 'id': obj.id, 'report_type': 'aeroo', 'in_format': 'oo-odt'}
280 ### Get new printing object ###
281 sub_aeroo_print = AerooPrint()
282 service.active_prints[sub_aeroo_print.id] = sub_aeroo_print
283 context['print_id'] = sub_aeroo_print.id
284 ###############################
285 sub_aeroo_print.start_time = time.time()
286 report, output = service.create_aeroo_report(cr, uid, \
287 [obj.id], data, report_xml, context=context, output='odt') # change for OpenERP 6.0 - Service class usage
288
289 ### Delete printing object ###
290 AerooPrint.print_ids.remove(sub_aeroo_print.id)
291 del service.active_prints[sub_aeroo_print.id]
292 ##############################
293 with NamedTemporaryFile(suffix='.odt', prefix='aeroo-report-', delete=False) as temp_file:
294 temp_file.write(report)
295
296 #self.oo_subreports[print_id].append(temp_file.name)
297 aeroo_print.subreports.append(temp_file.name)
298
299 return "<insert_doc('%s')>" % temp_file.name
300 return None
301 #### for text documents ####
302 def raw_subreport(name=None, obj=None):
303 report_xml_ids = ir_obj.search(cr, uid, [('report_name', '=', name)], context=context)
304 if report_xml_ids:
305 report_xml = ir_obj.browse(cr, uid, report_xml_ids[0], context=context)
306 data = {'model': obj._table_name, 'id': obj.id, 'report_type': 'aeroo', 'in_format': 'genshi-raw'}
307 report, output = netsvc.Service._services['report.%s' % name].create_genshi_raw_report(cr, uid, \
308 [obj.id], data, report_xml, context=context, output=output) # change for OpenERP 6.0 - Service class usage
309 return report
310 return None
311
312 if output=='odt':
313 return odt_subreport
314 elif output=='raw':
315 return raw_subreport
316
317 def set_xml_data_fields(self, objects, parser):
318 xml_data_fields = parser.localcontext.get('xml_data_fields', False)
319 if xml_data_fields:
320 for field in xml_data_fields:
321 for o in objects:
322 if getattr(o, field):
323 xml_data = base64.decodestring(getattr(o, field))
324 xmldoc = minidom.parseString(xml_data)
325 setattr(o, field, xmldoc.firstChild)
326 return objects
327
328 def get_other_template(self, cr, uid, data, parser):
329 if hasattr(parser, 'get_template'):
330 pool = pooler.get_pool(cr.dbname)
331 record = pool.get(data['model']).browse(cr, uid, data['id'], {})
332 template = parser.get_template(cr, uid, record)
333 return template
334 else:
335 return False
336
337 def get_styles_file(self, cr, uid, report_xml, company=None, context=None):
338 pool = pooler.get_pool(cr.dbname)
339 style_io=None
340 if report_xml.styles_mode!='default':
341 if report_xml.styles_mode=='global':
342 company_id = company or pool.get('res.users')._get_company(cr, uid, context=context)
343 style_content = pool.get('res.company').browse(cr, uid, company_id, context=context).stylesheet_id
344 style_content = style_content and style_content.report_styles or False
345 elif report_xml.styles_mode=='specified':
346 style_content = report_xml.stylesheet_id
347 style_content = style_content and style_content.report_styles or False
348 if style_content:
349 style_io = StringIO()
350 style_io.write(base64.decodestring(style_content))
351 return style_io
352
353 def create_genshi_raw_report(self, cr, uid, ids, data, report_xml, context=None, output='raw', tmpl=False):
354 def preprocess(data, aeroo_print):
355 aeroo_print.epl_images.reverse()
356 while aeroo_print.epl_images:
357 img = aeroo_print.epl_images.pop()
358 data = data.replace('<binary_data>', img, 1)
359 return data.replace('\n', '\r\n')
360
361 print_id = context.get('print_id', False)
362 aeroo_print = self.active_prints[print_id] # Aeroo print object
363 if not aeroo_print.start_time:
364 aeroo_print.start_time = time.time()
365 if not context:
366 context={}
367 context = context.copy()
368 objects = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context)
369 oo_parser = self.parser(cr, uid, self.name2, context=context)
370 oo_parser.localcontext.update(context)
371 oo_parser.set_context(objects, data, ids, report_xml.report_type)
372 self.set_xml_data_fields(oo_parser.objects, oo_parser) # Get/Set XML
373 oo_parser.localcontext['data'] = data
374 oo_parser.localcontext['user_lang'] = context.get('lang', False)
375 if len(objects)>0:
376 oo_parser.localcontext['o'] = objects[0]
377 xfunc = ExtraFunctions(cr, uid, report_xml.id, oo_parser.localcontext)
378 oo_parser.localcontext.update(xfunc.functions)
379 file_data = tmpl or self.get_other_template(cr, uid, data, oo_parser) or report_xml.report_sxw_content # Get other Tamplate
380 if not file_data or file_data=='False':
381 raise orm.except_orm(_('Error!'), _('No template found!'))
382 ################################################
383 if not file_data:
384 self._logger.info("End process %s (%s), elapsed time: %s" % (self.name, self.table, time.time() - aeroo_print.start_time)) # debug mode
385 return False, output
386
387 print_id = context.get('print_id', False)
388 aeroo_print = self.active_prints[print_id]
389
390 oo_parser.localcontext['include_subreport'] = self._subreport(cr, uid, aeroo_print, output='raw', aeroo_ooo=False, context=context)
391 oo_parser.localcontext['epl2_gw'] = self._epl2_gw(aeroo_print)
392 deferred = context.get('deferred_process')
393 oo_parser.localcontext['progress_update'] = deferred and deferred.progress_update or (lambda:True)
394
395 aeroo_print.epl_images = []
396 basic = NewTextTemplate(source=base64.decodestring(file_data))
397 if genshi_version<='0.6':
398 data = preprocess(basic.generate(**oo_parser.localcontext).render().decode('utf8').encode(report_xml.charset), aeroo_print)
399 else:
400 data = preprocess(basic.generate(**oo_parser.localcontext).render().encode(report_xml.charset), aeroo_print)
401
402 if report_xml.content_fname:
403 output = report_xml.content_fname
404 self._logger.info("End process %s (%s), elapsed time: %s" % (self.name, self.table, time.time() - aeroo_print.start_time)) # debug mode
405 return data, output
406
407 def _generate_doc(self, DC, data, report_xml, print_id):
408 with aeroo_lock:
409 DC.putDocument(data)
410 #subreports = self.oo_subreports.get(print_id)
411 aeroo_print = self.active_prints.get(print_id, False)
412 if aeroo_print:
413 DC.insertSubreports(aeroo_print.subreports)
414 #self.oo_subreports = []
415 #del self.oo_subreports[print_id]
416 if report_xml.out_format.code=='oo-dbf':
417 data = DC.saveByStream(report_xml.out_format.filter_name, "78")
418 else:
419 data = DC.saveByStream(report_xml.out_format.filter_name)
420 DC.closeDocument()
421 return data
422
423 def _raise_exception(self, e, print_id):
424 tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
425 self._logger.error(_("Report generation error!")+'\n'+tb_s)
426 #subreports = self.oo_subreports.get(print_id, [])
427 aeroo_print = self.active_prints.get(print_id, [])
428 if aeroo_print:
429 for sub_report in aeroo_print.subreports:
430 if os.path.isfile(sub_report):
431 os.unlink(sub_report)
432 raise Exception(_("Aeroo Reports: Error while generating the report."), e, str(e), _("For more reference inspect error logs."))
433
434 def create_aeroo_report(self, cr, uid, ids, data, report_xml, context=None, output='odt'):
435 """ Returns an aeroo report generated with aeroolib
436 """
437 pool = pooler.get_pool(cr.dbname)
438 if not context:
439 context={}
440 context = context.copy()
441 if self.name=='report.printscreen.list':
442 context['model'] = data['model']
443 context['ids'] = ids
444
445 print_id = context.get('print_id', False)
446 aeroo_print = self.active_prints[print_id] # Aeroo print object
447 aeroo_print.subreports = []
448 #self.oo_subreports[print_id] = []
449 objects = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context) or []
450 oo_parser = self.parser(cr, uid, self.name2, context=context)
451 oo_parser.localcontext.update(context)
452 oo_parser.set_context(objects, data, ids, report_xml.report_type)
453 self.set_xml_data_fields(objects, oo_parser) # Get/Set XML
454
455 oo_parser.localcontext['data'] = data
456 oo_parser.localcontext['user_lang'] = context.get('lang', False)
457 if len(objects)>0:
458 oo_parser.localcontext['o'] = objects[0]
459 xfunc = ExtraFunctions(cr, uid, report_xml.id, oo_parser.localcontext)
460 oo_parser.localcontext.update(xfunc.functions)
461
462 #company_id = objects and 'company_id' in objects[0]._table._columns.keys() and \
463 # objects[0].company_id and objects[0].company_id.id or False # for object company usage
464 company_id = False
465 style_io=self.get_styles_file(cr, uid, report_xml, company=company_id, context=context)
466
467 if report_xml.tml_source in ('file', 'database'):
468 if not report_xml.report_sxw_content or report_xml.report_sxw_content=='False':
469 raise orm.except_orm(_('Error!'), _('No template found!'))
470 file_data = base64.decodestring(report_xml.report_sxw_content)
471 else:
472 file_data = self.get_other_template(cr, uid, data, oo_parser)
473 if not file_data and not report_xml.report_sxw_content:
474 self._logger.info("End process %s (%s), elapsed time: %s" % (self.name, self.table, time.time() - aeroo_print.start_time)) # debug mode
475 return False, output
476 #elif file_data:
477 # template_io = StringIO()
478 # template_io.write(file_data or report_xml.report_sxw_content)
479 # basic = Template(source=template_io, styles=style_io)
480 else:
481 if report_xml.preload_mode == 'preload' and hasattr(self, 'serializer'):
482 serializer = copy.copy(self.serializer)
483 serializer.apply_style(style_io)
484 template_io = serializer.template
485 else:
486 template_io = StringIO()
487 template_io.write(file_data or base64.decodestring(report_xml.report_sxw_content) )
488 serializer = OOSerializer(template_io, oo_styles=style_io)
489 try:
490 basic = Template(source=template_io, serializer=serializer)
491 except Exception, e:
492 self._raise_exception(e, print_id)
493
494 #if not file_data:
495 # return False, output
496
497 #basic = Template(source=template_io, serializer=serializer)
498
499 aeroo_ooo = context.get('aeroo_ooo', False)
500 oo_parser.localcontext['include_subreport'] = self._subreport(cr, uid, aeroo_print, output='odt', aeroo_ooo=aeroo_ooo, context=context)
501 oo_parser.localcontext['include_document'] = self._include_document(aeroo_ooo, print_id)
502 deferred = context.get('deferred_process')
503 oo_parser.localcontext['progress_update'] = deferred and deferred.progress_update or (lambda:True)
504 ####### Add counter functons to localcontext #######
505 oo_parser.localcontext.update({'def_inc':self._def_inc(aeroo_print),
506 'get_inc':self._get_inc(aeroo_print),
507 'prev':self._prev(aeroo_print),
508 'next':self._next(aeroo_print)})
509
510 user_name = pool.get('res.users').browse(cr, uid, uid, {}).name
511 model_id = pool.get('ir.model').search(cr, uid, [('model','=',context.get('active_model', data['model']) or data['model'])])[0]
512 model_name = pool.get('ir.model').browse(cr, uid, model_id).name
513
514 #basic = Template(source=None, filepath=odt_path)
515
516 basic.Serializer.add_title(model_name)
517 basic.Serializer.add_creation_user(user_name)
518 module_info = load_information_from_description_file('report_aeroo')
519 version = module_info['version']
520 basic.Serializer.add_generator_info('Aeroo Lib/%s Aeroo Reports/%s' % (aeroolib.__version__, version))
521 basic.Serializer.add_custom_property('Aeroo Reports %s' % version, 'Generator')
522 basic.Serializer.add_custom_property('OpenERP %s' % release.version, 'Software')
523 basic.Serializer.add_custom_property(module_info['website'], 'URL')
524 basic.Serializer.add_creation_date(time.strftime('%Y-%m-%dT%H:%M:%S'))
525
526 try:
527 data = basic.generate(**oo_parser.localcontext).render().getvalue()
528 except orm.except_orm, e:
529 raise
530 except Exception, e:
531 self._raise_exception(e, print_id)
532
533 ######### OpenOffice extras #########
534 DC = netsvc.Service._services.get('openoffice')
535 if output!=report_xml.in_format[3:] or aeroo_print.subreports:
536 if aeroo_ooo and DC:
537 try:
538 data = self._generate_doc(DC, data, report_xml, print_id)
539 except Exception, e:
540 self._logger.error(_("OpenOffice.org related error!")+'\n'+str(e))
541 if DC._restart_ooo():
542 # We try again
543 try:
544 data = self._generate_doc(DC, data, report_xml, print_id)
545 except Exception, e:
546 self._logger.error(_("OpenOffice.org related error!")+'\n'+str(e))
547 if not report_xml.fallback_false:
548 output=report_xml.in_format[3:]
549 elif not report_xml.fallback_false:
550 output=report_xml.in_format[3:]
551 aeroo_print.subreports = []
552 else:
553 if report_xml.fallback_false:
554 if not aeroo_ooo:
555 raise orm.except_orm(_('OpenOffice.org related error!'), _('Module "report_aeroo_ooo" not installed.'))
556 elif not DC:
557 raise orm.except_orm(_('OpenOffice.org related error!'), _('Can not connect to OpenOffice.org.'))
558 else:
559 self._logger.warning("PDF generator temporarily offline, please wait a minute")
560 output=report_xml.in_format[3:]
561 elif output in ('pdf', 'doc', 'xls'):
562 output=report_xml.in_format[3:]
563 #####################################
564
565 if report_xml.content_fname:
566 output = report_xml.content_fname
567 self._logger.info("End process %s (%s), elapsed time: %s" % (self.name, self.table, time.time() - aeroo_print.start_time))
568 return data, output
569
570 # override needed to keep the attachments' storing procedure
571 def create_single_pdf(self, cr, uid, ids, data, report_xml, context=None):
572 if not context:
573 context={}
574 if report_xml.report_type == 'aeroo':
575 if report_xml.out_format.code.startswith('oo-'):
576 output = report_xml.out_format.code[3:]
577 return self.create_aeroo_report(cr, uid, ids, data, report_xml, context=context, output=output)
578 elif report_xml.out_format.code =='genshi-raw':
579 return self.create_genshi_raw_report(cr, uid, ids, data, report_xml, context=context, output='raw')
580 logo = None
581 context = context.copy()
582 title = report_xml.name
583 rml = report_xml.report_rml_content
584 oo_parser = self.parser(cr, uid, self.name2, context=context)
585 objs = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context)
586 oo_parser.set_context(objs, data, ids, report_xml.report_type)
587 processed_rml = self.preprocess_rml(etree.XML(rml),report_xml.report_type)
588 if report_xml.header:
589 oo_parser._add_header(processed_rml)
590 if oo_parser.logo:
591 logo = base64.decodestring(oo_parser.logo)
592 create_doc = self.generators[report_xml.report_type]
593 pdf = create_doc(etree.tostring(processed_rml),oo_parser.localcontext,logo,title.encode('utf8'))
594 return (pdf, report_xml.report_type)
595
596 def _get_attachment_create_vals(self, cr, uid, report_xml, vals, context=None):
597 if context is None:
598 context = {}
599 pool = pooler.get_pool(cr.dbname)
600 report_obj = pool.get('ir.actions.report.xml')
601 vals = report_obj._get_attachment_create_vals(cr, uid, report_xml, vals, context=context)
602 return vals
603
604 def create_source_pdf(self, cr, uid, ids, data, report_xml, context=None):
605 if not context:
606 context={}
607 pool = pooler.get_pool(cr.dbname)
608 attach = report_xml.attachment
609 aeroo_ooo = _aeroo_ooo_test(cr) # Detect report_aeroo_ooo module
610 context['aeroo_ooo'] = aeroo_ooo
611 print_id = context.get('print_id', False)
612 aeroo_print = self.active_prints[print_id] # Aeroo print object
613 if attach or aeroo_ooo and report_xml.process_sep:
614 objs = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context)
615 deferred = context.get('deferred_process')
616 results = []
617 for obj in objs:
618 aeroo_print.start_time = time.time()
619 if deferred:
620 deferred.progress_update()
621 aname = attach and eval(attach, {'object':obj, 'time':time}) or False
622 result = False
623 if report_xml.attachment_use and aname and context.get('attachment_use', True):
624 #aids = pool.get('ir.attachment').search(cr, uid, [('datas_fname','=',aname+'.pdf'),('res_model','=',self.table),('res_id','=',obj.id)])
625 #if aids:
626 # brow_rec = pool.get('ir.attachment').browse(cr, uid, aids[0])
627 # if not brow_rec.datas:
628 # continue
629 # d = base64.decodestring(brow_rec.datas)
630 # results.append((d,'pdf'))
631 # continue
632 cr.execute("SELECT id, datas_fname FROM ir_attachment WHERE datas_fname ilike %s and res_model=%s and res_id=%s LIMIT 1", (aname+'.%',self.table,obj.id))
633 search_res = cr.dictfetchone()
634 if search_res:
635 brow_rec = pool.get('ir.attachment').browse(cr, uid, search_res['id'])
636 if not brow_rec.datas:
637 continue
638 d = base64.decodestring(brow_rec.datas)
639 extension = search_res['datas_fname'].split('.')[1]
640 results.append((d,extension))
641 continue
642 result = self.create_single_pdf(cr, uid, [obj.id], data, report_xml, context)
643 if not result:
644 return False
645 try:
646 if attach and aname:
647 name = aname+'.'+result[1]
648 datas = base64.encodestring(result[0])
649 ctx = dict(context)
650 ctx.pop('default_type', None)
651 vals = {
652 'name': aname,
653 'datas': datas,
654 'file_size': len(datas),
655 'datas_fname': name,
656 'res_model': self.table,
657 'res_id': obj.id,
658 'type': 'binary',
659 }
660 attachment_vals = self._get_attachment_create_vals(
661 cr, uid, report_xml, vals, context=ctx)
662 pool.get('ir.attachment').create(cr, uid, attachment_vals, context=ctx)
663 cr.commit()
664 except Exception,e:
665 tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
666 self._logger.error(str(e))
667 results.append(result)
668 if results and len(results)==1:
669 return results[0]
670 if results:
671 not_pdf = filter(lambda r: r[1]!='pdf', results)
672 if not_pdf:
673 raise orm.except_orm(_('Error!'), _('Unsupported combination of formats!'))
674 #if results[0][1]=='pdf':
675 output = PdfFileWriter()
676 for r in results:
677 reader = PdfFileReader(StringIO(r[0]))
678 for page in range(reader.getNumPages()):
679 output.addPage(reader.getPage(page))
680 s = StringIO()
681 output.write(s)
682 return s.getvalue(), results[0][1]
683 return self.create_single_pdf(cr, uid, ids, data, report_xml, context)
684
685 def create_source_odt(self, cr, uid, ids, data, report_xml, context=None):
686 if not context:
687 context={}
688 pool = pooler.get_pool(cr.dbname)
689 results = []
690 attach = report_xml.attachment
691 aeroo_ooo = _aeroo_ooo_test(cr) # Detect report_aeroo_ooo module
692 context['aeroo_ooo'] = aeroo_ooo
693 print_id = context.get('print_id', False)
694 aeroo_print = self.active_prints[print_id] # Aeroo print object
695 if attach or aeroo_ooo and report_xml.process_sep:
696 objs = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context)
697 deferred = context.get('deferred_process')
698 for obj in objs:
699 aeroo_print.start_time = time.time()
700 if deferred:
701 deferred.progress_update()
702 aname = attach and eval(attach, {'object':obj, 'time':time}) or False
703 result = False
704 if report_xml.attachment_use and aname and context.get('attachment_use', True):
705 #aids = pool.get('ir.attachment').search(cr, uid, [('datas_fname','=',aname+'.odt'),('res_model','=',self.table),('res_id','=',obj.id)])
706 #if aids:
707 # brow_rec = pool.get('ir.attachment').browse(cr, uid, aids[0])
708 # if not brow_rec.datas:
709 # continue
710 # d = base64.decodestring(brow_rec.datas)
711 # results.append((d,'odt'))
712 # continue
713 cr.execute("SELECT id, datas_fname FROM ir_attachment WHERE datas_fname ilike %s and res_model=%s and res_id=%s LIMIT 1", (aname+'.%',self.table,obj.id))
714 search_res = cr.dictfetchone()
715 if search_res:
716 brow_rec = pool.get('ir.attachment').browse(cr, uid, search_res['id'])
717 if not brow_rec.datas:
718 continue
719 d = base64.decodestring(brow_rec.datas)
720 extension = search_res['datas_fname'].split('.')[1]
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches