Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: filters/get_subscriptions.py

Issue 29337941: Issue 3750 - Avoid re-generating subscription list for each locale (Closed)
Patch Set: Turned get_subscriptions into a global function Created March 9, 2016, 3:53 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | globals/get_subscriptions.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filters/get_subscriptions.py
diff --git a/filters/get_subscriptions.py b/filters/get_subscriptions.py
deleted file mode 100644
index d5d20768584f4788fab1b1cc46ae68afb35a90b7..0000000000000000000000000000000000000000
--- a/filters/get_subscriptions.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# This file is part of the Adblock Plus website,
-# Copyright (C) 2006-2016 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 os
-import tarfile
-import urllib
-import logging
-from ConfigParser import SafeConfigParser
-
-def get_subscriptions(_):
- try:
- from sitescripts.subscriptions import subscriptionParser
- except ImportError:
- logging.warning("Unable to import sitescripts, proceeding with empty "
- "subscriptions list.")
- return []
-
- result = {}
- utf8_reader = codecs.getreader('utf8')
- source = urllib.urlopen("https://hg.adblockplus.org/subscriptionlist/archive/default.tar.gz")
- orig_get_settings = subscriptionParser.get_settings
- try:
- # Hack: monkey-patch subscriptionParser.get_settings()
- settings = SafeConfigParser()
- settings_handle = urllib.urlopen("https://hg.adblockplus.org/subscriptionlist/rawfile/default/settings")
- try:
- settings.readfp(utf8_reader(settings_handle))
- finally:
- settings_handle.close()
- subscriptionParser.get_settings = lambda: settings
-
- with tarfile.open(fileobj=source, mode="r|gz") as archive:
- for fileinfo in archive:
- if os.path.splitext(fileinfo.name)[1] != ".subscription":
- continue
-
- filedata = subscriptionParser.parse_file(fileinfo.name, utf8_reader(archive.extractfile(fileinfo)))
- if filedata.unavailable:
- continue
-
- result[filedata.name] = filedata
- finally:
- source.close()
- subscriptionParser.get_settings = orig_get_settings
-
- subscriptionParser.calculate_supplemented(result)
- return result.values()
« no previous file with comments | « no previous file | globals/get_subscriptions.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld