LEFT | RIGHT |
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-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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 # Page helpers | 64 # Page helpers |
65 # | 65 # |
66 | 66 |
67 @staticmethod | 67 @staticmethod |
68 def page_filename(page, format): | 68 def page_filename(page, format): |
69 return "pages/%s.%s" % (page, format) | 69 return "pages/%s.%s" % (page, format) |
70 | 70 |
71 def list_pages(self): | 71 def list_pages(self): |
72 for filename in self.list_files("pages"): | 72 for filename in self.list_files("pages"): |
73 root, ext = os.path.splitext(filename) | 73 root, ext = os.path.splitext(filename) |
74 format = ext[1:] | 74 format = ext[1:].lower() |
75 yield root, format | 75 yield root, format |
76 | 76 |
77 def has_page(self, page, format): | 77 def has_page(self, page, format): |
78 return self.has_file(self.page_filename(page, format)) | 78 return self.has_file(self.page_filename(page, format)) |
79 | 79 |
80 def read_page(self, page, format): | 80 def read_page(self, page, format): |
81 return self.read_file(self.page_filename(page, format)) | 81 return self.read_file(self.page_filename(page, format)) |
82 | 82 |
83 # | 83 # |
84 # Localizable files helpers | 84 # Localizable files helpers |
85 # | 85 # |
86 | 86 |
87 @staticmethod | 87 @staticmethod |
88 def localizable_file_filename(locale, filename): | 88 def localizable_file_filename(locale, filename): |
89 return "locales/%s/%s" % (locale, filename) | 89 return "locales/%s/%s" % (locale, filename) |
90 | 90 |
91 def list_localizable_files(self): | 91 def list_localizable_files(self): |
92 default_locale = self.read_config().get("general", "defaultlocale") | 92 default_locale = self.read_config().get("general", "defaultlocale") |
93 return filter( | 93 return filter( |
94 lambda f: os.path.splitext(f)[1] != ".json", | 94 lambda f: os.path.splitext(f)[1].lower() != ".json", |
95 self.list_files("locales/%s" % default_locale) | 95 self.list_files("locales/%s" % default_locale) |
96 ) | 96 ) |
97 | 97 |
98 def has_localizable_file(self, locale, filename): | 98 def has_localizable_file(self, locale, filename): |
99 return self.has_file(self.localizable_file_filename(locale, filename)) | 99 return self.has_file(self.localizable_file_filename(locale, filename)) |
100 | 100 |
101 def read_localizable_file(self, locale, filename): | 101 def read_localizable_file(self, locale, filename): |
102 return self.read_file(self.localizable_file_filename(locale, filename), bina
ry=True) | 102 return self.read_file(self.localizable_file_filename(locale, filename), bina
ry=True) |
103 | 103 |
104 # | 104 # |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 return | 252 return |
253 | 253 |
254 for filename in files: | 254 for filename in files: |
255 path = os.path.join(dir, filename) | 255 path = os.path.join(dir, filename) |
256 if os.path.isfile(path): | 256 if os.path.isfile(path): |
257 result.append(relpath + filename) | 257 result.append(relpath + filename) |
258 elif os.path.isdir(path): | 258 elif os.path.isdir(path): |
259 do_list(path, relpath + filename + "/") | 259 do_list(path, relpath + filename + "/") |
260 do_list(self.get_path(subdir), "") | 260 do_list(self.get_path(subdir), "") |
261 return result | 261 return result |
LEFT | RIGHT |