LEFT | RIGHT |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 def list_localizable_files(self): | 118 def list_localizable_files(self): |
119 default_locale = self.read_config().get('general', 'defaultlocale') | 119 default_locale = self.read_config().get('general', 'defaultlocale') |
120 return filter(lambda f: os.path.splitext(f)[1].lower() != '.json', | 120 return filter(lambda f: os.path.splitext(f)[1].lower() != '.json', |
121 self.list_files('locales/%s' % default_locale)) | 121 self.list_files('locales/%s' % default_locale)) |
122 | 122 |
123 def has_localizable_file(self, locale, filename): | 123 def has_localizable_file(self, locale, filename): |
124 return self.has_file(self.localizable_file_filename(locale, filename)) | 124 return self.has_file(self.localizable_file_filename(locale, filename)) |
125 | 125 |
126 def read_localizable_file(self, locale, filename): | 126 def read_localizable_file(self, locale, filename): |
127 return self.read_file(self.localizable_file_filename(locale, filename),
binary=True)[0] | 127 return self.read_file(self.localizable_file_filename(locale, filename),
True)[0] |
128 | 128 |
129 # | 129 # |
130 # Static file helpers | 130 # Static file helpers |
131 # | 131 # |
132 | 132 |
133 @staticmethod | 133 @staticmethod |
134 def static_filename(filename): | 134 def static_filename(filename): |
135 return 'static/%s' % filename | 135 return 'static/%s' % filename |
136 | 136 |
137 def list_static(self): | 137 def list_static(self): |
138 return self.list_files('static') | 138 return self.list_files('static') |
139 | 139 |
140 def has_static(self, filename): | 140 def has_static(self, filename): |
141 return self.has_file(self.static_filename(filename)) | 141 return self.has_file(self.static_filename(filename)) |
142 | 142 |
143 def read_static(self, filename): | 143 def read_static(self, filename): |
144 return self.read_file(self.static_filename(filename), binary=True)[0] | 144 return self.read_file(self.static_filename(filename), True)[0] |
145 | 145 |
146 # | 146 # |
147 # Locale helpers | 147 # Locale helpers |
148 # | 148 # |
149 | 149 |
150 def locale_filename(self, locale, page): | 150 def locale_filename(self, locale, page): |
151 config = self.read_config() | 151 config = self.read_config() |
152 try: | 152 try: |
153 page = config.get('locale_overrides', page) | 153 page = config.get('locale_overrides', page) |
154 except ConfigParser.Error: | 154 except ConfigParser.Error: |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 397 |
398 if additional_paths: | 398 if additional_paths: |
399 additional_sources = [ | 399 additional_sources = [ |
400 create_source(os.path.join(path, p)) | 400 create_source(os.path.join(path, p)) |
401 for p in additional_paths | 401 for p in additional_paths |
402 ] | 402 ] |
403 source = MultiSource([source] + additional_sources) | 403 source = MultiSource([source] + additional_sources) |
404 | 404 |
405 if cached: | 405 if cached: |
406 for fname in [ | 406 for fname in [ |
| 407 'list_files', |
| 408 'list_locales', |
407 'resolve_link', | 409 'resolve_link', |
408 'read_config', | 410 'read_config', |
409 'read_template', | 411 'read_template', |
410 'read_locale', | 412 'read_locale', |
| 413 'read_file', |
411 'read_include', | 414 'read_include', |
412 'exec_file', | 415 'exec_file', |
413 ]: | 416 ]: |
414 setattr(source, fname, _memoize(getattr(source, fname))) | 417 setattr(source, fname, _memoize(getattr(source, fname))) |
415 | 418 |
416 return source | 419 return source |
LEFT | RIGHT |