Left: | ||
Right: |
OLD | NEW |
---|---|
1 # This file is part of the Adblock Plus website, | 1 # This file is part of the Adblock Plus website, |
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 |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 import codecs | 16 import codecs |
17 import os | 17 import os |
18 import tarfile | 18 import tarfile |
19 import urllib | 19 import urllib |
20 import logging | |
20 from ConfigParser import SafeConfigParser | 21 from ConfigParser import SafeConfigParser |
21 | 22 |
22 def get_subscriptions(_): | 23 def get_subscriptions(_): |
23 from sitescripts.subscriptions import subscriptionParser | 24 try: |
25 from sitescripts.subscriptions import subscriptionParser | |
26 except ImportError: | |
27 logging.warning("Unable to import sitescripts, proceeding with empty subscri ptions list") | |
kzar
2016/02/19 17:57:14
Nit: This line is too long (but I think the messag
juliandoucette
2016/02/23 14:50:27
Done.
| |
28 return [] | |
24 | 29 |
25 result = {} | 30 result = {} |
26 utf8_reader = codecs.getreader('utf8') | 31 utf8_reader = codecs.getreader('utf8') |
27 source = urllib.urlopen("https://hg.adblockplus.org/subscriptionlist/archive/d efault.tar.gz") | 32 source = urllib.urlopen("https://hg.adblockplus.org/subscriptionlist/archive/d efault.tar.gz") |
28 orig_get_settings = subscriptionParser.get_settings | 33 orig_get_settings = subscriptionParser.get_settings |
29 try: | 34 try: |
30 # Hack: monkey-patch subscriptionParser.get_settings() | 35 # Hack: monkey-patch subscriptionParser.get_settings() |
31 settings = SafeConfigParser() | 36 settings = SafeConfigParser() |
32 settings_handle = urllib.urlopen("https://hg.adblockplus.org/subscriptionlis t/rawfile/default/settings") | 37 settings_handle = urllib.urlopen("https://hg.adblockplus.org/subscriptionlis t/rawfile/default/settings") |
33 try: | 38 try: |
(...skipping 11 matching lines...) Expand all Loading... | |
45 if filedata.unavailable: | 50 if filedata.unavailable: |
46 continue | 51 continue |
47 | 52 |
48 result[filedata.name] = filedata | 53 result[filedata.name] = filedata |
49 finally: | 54 finally: |
50 source.close() | 55 source.close() |
51 subscriptionParser.get_settings = orig_get_settings | 56 subscriptionParser.get_settings = orig_get_settings |
52 | 57 |
53 subscriptionParser.calculate_supplemented(result) | 58 subscriptionParser.calculate_supplemented(result) |
54 return result.values() | 59 return result.values() |
OLD | NEW |