| 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-2016 Eyeo GmbH | 2 # Copyright (C) 2006-2016 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 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 return False | 232 return False |
| 233 return True | 233 return True |
| 234 | 234 |
| 235 def read_file(self, filename, binary=False): | 235 def read_file(self, filename, binary=False): |
| 236 data = self._archive.read('root/' + filename) | 236 data = self._archive.read('root/' + filename) |
| 237 if not binary: | 237 if not binary: |
| 238 data = data.decode('utf-8') | 238 data = data.decode('utf-8') |
| 239 return (data, '%s!%s' % (self._name, filename)) | 239 return (data, '%s!%s' % (self._name, filename)) |
| 240 | 240 |
| 241 def list_files(self, subdir): | 241 def list_files(self, subdir): |
| 242 prefix = 'root/%s/' % subdir | 242 prefix = 'root/{}/'.format(subdir) |
| 243 for filename in self._archive.namelist(): | 243 for filename in self._archive.namelist(): |
| 244 if filename.startswith(prefix): | 244 if filename.startswith(prefix): |
| 245 yield filename[len(prefix):] | 245 yield filename[len(prefix):] |
| 246 | 246 |
| 247 if os.name == 'posix': | 247 if os.name == 'posix': |
| 248 def get_cache_dir(self): | 248 def get_cache_dir(self): |
| 249 return '/var/cache/' + self._name | 249 return '/var/cache/' + self._name |
| 250 | 250 |
| 251 | 251 |
| 252 class FileSource(Source): | 252 class FileSource(Source): |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 path = os.path.join(dir, filename) | 292 path = os.path.join(dir, filename) |
| 293 if os.path.isfile(path): | 293 if os.path.isfile(path): |
| 294 result.append(relpath + filename) | 294 result.append(relpath + filename) |
| 295 elif os.path.isdir(path): | 295 elif os.path.isdir(path): |
| 296 do_list(path, relpath + filename + '/') | 296 do_list(path, relpath + filename + '/') |
| 297 do_list(self.get_path(subdir), '') | 297 do_list(self.get_path(subdir), '') |
| 298 return result | 298 return result |
| 299 | 299 |
| 300 def get_cache_dir(self): | 300 def get_cache_dir(self): |
| 301 return os.path.join(self._dir, 'cache') | 301 return os.path.join(self._dir, 'cache') |
| LEFT | RIGHT |