Changeset 13:d57a45e8a7b2
- Timestamp:
- 07/14/08 22:09:55 (5 years ago)
- Branch:
- default
- Location:
- relatorio
- Files:
-
- 3 modified
-
reporting.py (modified) (2 diffs)
-
templates/__init__.py (modified) (1 diff)
-
templates/odt.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
relatorio/reporting.py
r12 r13 19 19 ############################################################################### 20 20 21 __revision__ = "$Id: reporting.py 1 3 2008-07-10 16:41:20Z ged$"21 __revision__ = "$Id: reporting.py 14 2008-07-14 22:09:55Z nicoe $" 22 22 __metaclass__ = type 23 23 … … 28 28 from genshi.template import TemplateLoader 29 29 30 from templates import NullTemplate 30 31 from templates.odt import Template as OOTemplate 31 from templates.pdf import Template as PDFTemplate 32 33 try: 34 from templates.pdf import Template as PDFTemplate 35 except ImportError: 36 PDFTemplate = NullTemplate 37 warnings.warn("trml2pdf is not installed on your system. You will not " 38 "be able to create PDF files.") 32 39 33 40 def _absolute(path): -
relatorio/templates/__init__.py
r1 r13 1 ############################################################################### 2 # 3 # Copyright (c) 2007, 2008 OpenHex SPRL. (http://openhex.com) All Rights 4 # Reserved. 5 # 6 # This program is free software; you can redistribute it and/or modify it under 7 # the terms of the GNU General Public License as published by the Free Software 8 # Foundation; either version 2 of the License, or (at your option) any later 9 # version. 10 # 11 # This program is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 # details. 15 # 16 # You should have received a copy of the GNU General Public License along with 17 # this program. If not, see <http://www.gnu.org/licenses/>. 18 # 19 ############################################################################### 20 21 __revision__ = "$Id: __init__.py 14 2008-07-14 22:09:55Z nicoe $" 22 __metaclass__ = type 23 24 from genshi.template import Template as GenshiTemplate, MarkupTemplate 25 26 27 class NullTemplate(GenshiTemplate): 28 29 def __init__(self, source, filepath=None, filename=None, loader=None, 30 encoding=None, lookup='strict', allow_exec=True): 31 raise NotImplementedError 32 33 def _parse(self, source, encoding): 34 pass 35 36 def _prepare(self, stream): 37 pass 38 39 def generate(self, *args, **kwargs): 40 pass -
relatorio/templates/odt.py
r8 r13 19 19 ############################################################################### 20 20 21 __revision__ = "$Id: odt.py 9 2008-07-08 19:23:12Z nicoe $"21 __revision__ = "$Id: odt.py 14 2008-07-14 22:09:55Z nicoe $" 22 22 __metaclass__ = type 23 23 … … 46 46 } 47 47 48 def _make_href(zip): 49 def attr_maker(expr, name): 48 class ImageHref: 49 50 def __init__(self, zipfile): 51 self.zip = zipfile 52 self.count = 0 53 54 def __call__(self, expr, name): 50 55 bitstream, mimetype = expr 51 name = md5.new(name).hexdigest() 56 name = md5.new('%s-%s' % (name, self.count)).hexdigest() 57 self.count += 1 52 58 path = 'Pictures/%s.%s' % (name, EXTENSIONS[mimetype]) 53 59 bitstream.seek(0) 54 zip.writestr(path, bitstream.read())60 self.zip.writestr(path, bitstream.read()) 55 61 return {'{%s}href' % NS['xlink']: path} 56 return attr_maker57 62 58 63 … … 178 183 outzip = zipfile.ZipFile(new_oo, 'w') 179 184 180 kwargs['make_href'] = _make_href(outzip)185 kwargs['make_href'] = ImageHref(outzip) 181 186 content = str(self.content_template.generate(*args, **kwargs)) 182 187
