| 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 | 
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  228         return self |  228         return self | 
|  229  |  229  | 
|  230     def __exit__(self, type, value, traceback): |  230     def __exit__(self, type, value, traceback): | 
|  231         return False |  231         return False | 
|  232  |  232  | 
|  233     def close(self): |  233     def close(self): | 
|  234         pass |  234         pass | 
|  235  |  235  | 
|  236     @property |  236     @property | 
|  237     def version(self): |  237     def version(self): | 
|  238         return randint(1, 10) |  238         return randint(1, 2 ** 32) | 
|  239  |  239  | 
|  240     def get_path(self, filename): |  240     def get_path(self, filename): | 
|  241         return os.path.join(self._dir, *filename.split('/')) |  241         return os.path.join(self._dir, *filename.split('/')) | 
|  242  |  242  | 
|  243     def has_file(self, filename): |  243     def has_file(self, filename): | 
|  244         return os.path.isfile(self.get_path(filename)) |  244         return os.path.isfile(self.get_path(filename)) | 
|  245  |  245  | 
|  246     def read_file(self, filename, binary=False): |  246     def read_file(self, filename, binary=False): | 
|  247         path = self.get_path(filename) |  247         path = self.get_path(filename) | 
|  248  |  248  | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  361  |  361  | 
|  362  |  362  | 
|  363 def create_source(path, cached=False, revision=None): |  363 def create_source(path, cached=False, revision=None): | 
|  364     """Create a source from path and optional revision. |  364     """Create a source from path and optional revision. | 
|  365  |  365  | 
|  366     `cached` flag activates caching. This can be used to optimize performance |  366     `cached` flag activates caching. This can be used to optimize performance | 
|  367     if no changes are expected on the filesystem after the source was created. |  367     if no changes are expected on the filesystem after the source was created. | 
|  368     This is usually the case with static generation (as opposed to dynamic |  368     This is usually the case with static generation (as opposed to dynamic | 
|  369     preview). |  369     preview). | 
|  370  |  370  | 
|  371     If `revision` option is provided, the `path` is assumed to be pointing to a |  | 
|  372     Mercurial repository. In this case the source will return the content of |  | 
|  373     selected revision (using `MercurialSource`) instead of the content of the |  | 
|  374     directory. Note that any local changes will be ignored in this case. |  | 
|  375  |  | 
|  376     If `settings.ini` in the source contains `[paths]` section with an |  371     If `settings.ini` in the source contains `[paths]` section with an | 
|  377     `additional-paths` key that contains the list of additional root folders, |  372     `additional-paths` key that contains the list of additional root folders, | 
|  378     `MultiSource` will be instantiated and its bases will be the original |  373     `MultiSource` will be instantiated and its bases will be the original | 
|  379     source plus an additional source for each additional root folder. |  374     source plus an additional source for each additional root folder. | 
|  380     `MultiSource` looks up files in its base sources in the order they are |  375     `MultiSource` looks up files in its base sources in the order they are | 
|  381     provided, so the files in the additional folders will only be used if the |  376     provided, so the files in the additional folders will only be used if the | 
|  382     original source doesn't contain that file. |  377     original source doesn't contain that file. | 
|  383     """ |  378     """ | 
|  384     source = FileSource(path) |  379     source = FileSource(path) | 
|  385  |  380  | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
|  402             'resolve_link', |  397             'resolve_link', | 
|  403             'read_config', |  398             'read_config', | 
|  404             'read_template', |  399             'read_template', | 
|  405             'read_locale', |  400             'read_locale', | 
|  406             'read_include', |  401             'read_include', | 
|  407             'exec_file', |  402             'exec_file', | 
|  408         ]: |  403         ]: | 
|  409             setattr(source, fname, _memoize(getattr(source, fname))) |  404             setattr(source, fname, _memoize(getattr(source, fname))) | 
|  410  |  405  | 
|  411     return source |  406     return source | 
| LEFT | RIGHT |