4
# Copyright (C) 2009 John Garland <johnnybg@gmail.com>
6
# Deluge is free software.
8
# You may redistribute it and/or modify it under the terms of the
9
# GNU General Public License, as published by the Free Software
10
# Foundation; either version 3 of the License, or (at your option)
13
# deluge is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
# See the GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with deluge. If not, write to:
20
# The Free Software Foundation, Inc.,
21
# 51 Franklin Street, Fifth Floor
22
# Boston, MA 02110-1301, USA.
24
# In addition, as a special exception, the copyright holders give
25
# permission to link the code of portions of this program with the OpenSSL
27
# You must obey the GNU General Public License in all respects for all of
28
# the code used other than OpenSSL. If you modify file(s) with this
29
# exception, you may extend this exception to your version of the file(s),
30
# but you are not obligated to do so. If you do not wish to do so, delete
31
# this exception statement from your version. If you delete this exception
32
# statement from all source files in the program, then also delete it here.
36
import gzip, zipfile, bz2
39
"""Blocklist reader for zipped blocklists"""
41
z = zipfile.ZipFile(self.file)
42
return z.open(z.namelist()[0])
47
"""Blocklist reader for gzipped blocklists"""
49
return gzip.open(self.file)
54
"""Blocklist reader for bzipped2 blocklists"""
56
return bz2.BZ2File(self.file)