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 27 matching lines...) Expand all Loading... |
38 type = define_property("type") | 38 type = define_property("type") |
39 maintainer = define_property("maintainer") | 39 maintainer = define_property("maintainer") |
40 email = define_property("email") | 40 email = define_property("email") |
41 specialization = define_property("specialization") | 41 specialization = define_property("specialization") |
42 languages = define_property("languages") | 42 languages = define_property("languages") |
43 recommendation = define_property("recommendation", readonly=True) | 43 recommendation = define_property("recommendation", readonly=True) |
44 deprecated = define_property("deprecated", readonly=True) | 44 deprecated = define_property("deprecated", readonly=True) |
45 unavailable = define_property("unavailable", readonly=True) | 45 unavailable = define_property("unavailable", readonly=True) |
46 catchall = define_property("catchall", readonly=True) | 46 catchall = define_property("catchall", readonly=True) |
47 supplements = define_property("supplements", readonly=True) | 47 supplements = define_property("supplements", readonly=True) |
| 48 supplementsType = define_property("supplementsType", readonly=True) |
48 supplemented = define_property("supplemented", readonly=True) | 49 supplemented = define_property("supplemented", readonly=True) |
49 variants = define_property("variants", readonly=True) | 50 variants = define_property("variants", readonly=True) |
50 homepage = define_property("homepage") | 51 homepage = define_property("homepage") |
51 contact = define_property("contact") | 52 contact = define_property("contact") |
52 forum = define_property("forum") | 53 forum = define_property("forum") |
53 faq = define_property("faq") | 54 faq = define_property("faq") |
54 blog = define_property("blog") | 55 blog = define_property("blog") |
55 changelog = define_property("changelog") | 56 changelog = define_property("changelog") |
56 policy = define_property("policy") | 57 policy = define_property("policy") |
57 digest = define_property("digest") | 58 digest = define_property("digest") |
58 digestDay = define_property("digestDay") | 59 digestDay = define_property("digestDay") |
59 | 60 |
60 def __init__(self, path, data): | 61 def __init__(self, path, data): |
61 self._data = { | 62 self._data = { |
62 'name': None, | 63 'name': None, |
63 'type': 'ads', | 64 'type': 'ads', |
64 'maintainer': None, | 65 'maintainer': None, |
65 'email': None, | 66 'email': None, |
66 'specialization': None, | 67 'specialization': None, |
67 'languages': None, | 68 'languages': None, |
68 'deprecated': False, | 69 'deprecated': False, |
69 'unavailable': False, | 70 'unavailable': False, |
70 'catchall': False, | 71 'catchall': False, |
71 'supplements': [], | 72 'supplements': [], |
| 73 'supplementsType': set(), |
72 'supplemented': [], | 74 'supplemented': [], |
73 'variants': [], | 75 'variants': [], |
74 'recommendation': None, | 76 'recommendation': None, |
75 'homepage': None, | 77 'homepage': None, |
76 'contact': None, | 78 'contact': None, |
77 'forum': None, | 79 'forum': None, |
78 'faq': None, | 80 'faq': None, |
79 'blog': None, | 81 'blog': None, |
80 'changelog': None, | 82 'changelog': None, |
81 'policy': None, | 83 'policy': None, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 215 |
214 def parse_file(path, data): | 216 def parse_file(path, data): |
215 return Subscription(path, data) | 217 return Subscription(path, data) |
216 | 218 |
217 def calculate_supplemented(lists): | 219 def calculate_supplemented(lists): |
218 for filedata in lists.itervalues(): | 220 for filedata in lists.itervalues(): |
219 for supplements in filedata.supplements: | 221 for supplements in filedata.supplements: |
220 if supplements in lists: | 222 if supplements in lists: |
221 if lists[supplements].type == filedata.type: | 223 if lists[supplements].type == filedata.type: |
222 lists[supplements].supplemented.append(filedata) | 224 lists[supplements].supplemented.append(filedata) |
| 225 filedata.supplementsType.add(lists[supplements].type) |
223 else: | 226 else: |
224 warn('Subscription %s supplements an unknown subscription %s' % (filedat
a.name, supplements)) | 227 warn('Subscription %s supplements an unknown subscription %s' % (filedat
a.name, supplements)) |
225 | 228 |
226 @cached(60) | 229 @cached(60) |
227 def get_settings(): | 230 def get_settings(): |
228 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) | 231 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) |
229 settingsdata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defaul
t', os.path.join(repo, 'settings')]) | 232 settingsdata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defaul
t', os.path.join(repo, 'settings')]) |
230 settings = SafeConfigParser() | 233 settings = SafeConfigParser() |
231 settings.readfp(codecs.getreader('utf8')(StringIO(settingsdata))) | 234 settings.readfp(codecs.getreader('utf8')(StringIO(settingsdata))) |
232 return settings | 235 return settings |
(...skipping 18 matching lines...) Expand all Loading... |
251 | 254 |
252 def getFallbackData(): | 255 def getFallbackData(): |
253 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) | 256 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) |
254 redirectdata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defaul
t', os.path.join(repo, 'redirects')]) | 257 redirectdata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defaul
t', os.path.join(repo, 'redirects')]) |
255 gonedata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default',
os.path.join(repo, 'gone')]) | 258 gonedata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default',
os.path.join(repo, 'gone')]) |
256 return (redirectdata, gonedata) | 259 return (redirectdata, gonedata) |
257 | 260 |
258 def _validate_URL(url): | 261 def _validate_URL(url): |
259 parse_result = urlparse(url) | 262 parse_result = urlparse(url) |
260 return parse_result.scheme in ('http', 'https') and parse_result.netloc != '' | 263 return parse_result.scheme in ('http', 'https') and parse_result.netloc != '' |
OLD | NEW |