| Index: filters/get_subscriptions.py |
| diff --git a/filters/get_subscriptions.py b/filters/get_subscriptions.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8aa8949c61f470bd18506105c6eaded4b7bebaa9 |
| --- /dev/null |
| +++ b/filters/get_subscriptions.py |
| @@ -0,0 +1,37 @@ |
| +# This file is part of the Adblock Plus website, |
| +# Copyright (C) 2006-2015 Eyeo GmbH |
| +# |
| +# Adblock Plus is free software: you can redistribute it and/or modify |
| +# it under the terms of the GNU General Public License version 3 as |
| +# published by the Free Software Foundation. |
| +# |
| +# Adblock Plus is distributed in the hope that it will be useful, |
| +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| +# GNU General Public License for more details. |
| +# |
| +# You should have received a copy of the GNU General Public License |
| +# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| + |
| +import codecs |
| +import tarfile |
| +import urllib |
| + |
| +from sitescripts.subscriptions.subscriptionParser import parse_file, calculate_supplemented |
| + |
| +def get_subscriptions(_): |
| + result = {} |
| + source = urllib.urlopen("https://hg.adblockplus.org/subscriptionlist/archive/default.tar.gz") |
| + with tarfile.open(fileobj=source, mode="r|gz") as archive: |
| + for fileinfo in archive: |
| + if not fileinfo.name.endswith(".subscription"): |
| + continue |
| + |
| + filedata = parse_file(fileinfo.name, codecs.getreader('utf8')(archive.extractfile(fileinfo))) |
| + if filedata.unavailable: |
| + continue |
| + |
| + result[filedata.name] = filedata |
| + |
| + calculate_supplemented(result) |
| + return list(result.itervalues()) |
|
Wladimir Palant
2015/02/26 22:01:46
return result.values()?
kzar
2015/02/26 22:12:17
Done.
|