OLD | NEW |
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
4 # Copyright (C) 2006-2015 Eyeo GmbH | 4 # Copyright (C) 2006-2015 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return "pages/%s.%s" % (page, format) | 83 return "pages/%s.%s" % (page, format) |
84 | 84 |
85 def list_pages(self): | 85 def list_pages(self): |
86 for filename in self.list_files("pages"): | 86 for filename in self.list_files("pages"): |
87 root, ext = os.path.splitext(filename) | 87 root, ext = os.path.splitext(filename) |
88 format = ext[1:].lower() | 88 format = ext[1:].lower() |
89 yield root, format | 89 yield root, format |
90 | 90 |
91 def has_page(self, page, format=None): | 91 def has_page(self, page, format=None): |
92 if format is None: | 92 if format is None: |
93 from .converters import converters | 93 from cms.converters import converters |
94 return any( | 94 return any( |
95 self.has_page(page, format) | 95 self.has_page(page, format) |
96 for format in converters.iterkeys() | 96 for format in converters.iterkeys() |
97 ) | 97 ) |
98 else: | 98 else: |
99 return self.has_file(self.page_filename(page, format)) | 99 return self.has_file(self.page_filename(page, format)) |
100 | 100 |
101 def read_page(self, page, format): | 101 def read_page(self, page, format): |
102 return self.read_file(self.page_filename(page, format)) | 102 return self.read_file(self.page_filename(page, format)) |
103 | 103 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 path = os.path.join(dir, filename) | 282 path = os.path.join(dir, filename) |
283 if os.path.isfile(path): | 283 if os.path.isfile(path): |
284 result.append(relpath + filename) | 284 result.append(relpath + filename) |
285 elif os.path.isdir(path): | 285 elif os.path.isdir(path): |
286 do_list(path, relpath + filename + "/") | 286 do_list(path, relpath + filename + "/") |
287 do_list(self.get_path(subdir), "") | 287 do_list(self.get_path(subdir), "") |
288 return result | 288 return result |
289 | 289 |
290 def get_cache_dir(self): | 290 def get_cache_dir(self): |
291 return os.path.join(self._dir, "cache") | 291 return os.path.join(self._dir, "cache") |
OLD | NEW |