| LEFT | RIGHT | 
|---|
| (no file at all) |  | 
| 1 # coding: utf-8 | 1 # coding: utf-8 | 
| 2 | 2 | 
| 3 # This file is part of the Adblock Plus build tools, | 3 # This file is part of the Adblock Plus build tools, | 
| 4 # Copyright (C) 2006-2013 Eyeo GmbH | 4 # Copyright (C) 2006-2013 Eyeo GmbH | 
| 5 # | 5 # | 
| 6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify | 
| 7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as | 
| 8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. | 
| 9 # | 9 # | 
| 10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 106       # Make sure the file is inside an included directory | 106       # Make sure the file is inside an included directory | 
| 107       if '/' in target and not self.isIncluded(target): | 107       if '/' in target and not self.isIncluded(target): | 
| 108         continue | 108         continue | 
| 109       parts = source.split('/') | 109       parts = source.split('/') | 
| 110       path = os.path.join(os.path.dirname(item.source), *parts) | 110       path = os.path.join(os.path.dirname(item.source), *parts) | 
| 111       if os.path.exists(path): | 111       if os.path.exists(path): | 
| 112         self.read(path, target) | 112         self.read(path, target) | 
| 113       else: | 113       else: | 
| 114         print >>sys.stderr, 'Warning: Mapped file %s doesn\'t exist' % source | 114         print >>sys.stderr, 'Warning: Mapped file %s doesn\'t exist' % source | 
| 115 | 115 | 
|  | 116   def preprocess(self, filenames, params={}): | 
|  | 117     import jinja2 | 
|  | 118     env = jinja2.Environment() | 
|  | 119 | 
|  | 120     for filename in filenames: | 
|  | 121       env.autoescape = os.path.splitext(filename)[1].lower() in ('.html', '.xml'
     ) | 
|  | 122       template = env.from_string(self[filename].decode('utf-8')) | 
|  | 123       self[filename] = template.render(params).encode('utf-8') | 
|  | 124 | 
| 116   def zip(self, outFile, sortKey=None): | 125   def zip(self, outFile, sortKey=None): | 
| 117     zip = zipfile.ZipFile(outFile, 'w', zipfile.ZIP_DEFLATED) | 126     zip = zipfile.ZipFile(outFile, 'w', zipfile.ZIP_DEFLATED) | 
| 118     names = self.keys() | 127     names = self.keys() | 
| 119     names.sort(key=sortKey) | 128     names.sort(key=sortKey) | 
| 120     for name in names: | 129     for name in names: | 
| 121       zip.writestr(name, self[name]) | 130       zip.writestr(name, self[name]) | 
| 122     zip.close() | 131     zip.close() | 
| 123 | 132 | 
| 124   def zipToString(self, sortKey=None): | 133   def zipToString(self, sortKey=None): | 
| 125     buffer = StringIO() | 134     buffer = StringIO() | 
| 126     self.zip(buffer, sortKey=sortKey) | 135     self.zip(buffer, sortKey=sortKey) | 
| 127     return buffer.getvalue() | 136     return buffer.getvalue() | 
| LEFT | RIGHT | 
|---|