From fc17f3568c985e6a3441fd814d9142952b0cb761 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 22 Jul 2013 23:25:18 +0200 Subject: little cleanup, added some tests --- pyload/network/RequestFactory.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'pyload/network/RequestFactory.py') diff --git a/pyload/network/RequestFactory.py b/pyload/network/RequestFactory.py index e6015219f..472705409 100644 --- a/pyload/network/RequestFactory.py +++ b/pyload/network/RequestFactory.py @@ -1,28 +1,26 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program 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 this program; if not, see . - - @author: mkaay, RaNaN -""" +############################################################################### +# Copyright(c) 2008-2013 pyLoad Team +# http://www.pyload.org +# +# This file is part of pyLoad. +# pyLoad is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Subjected to the terms and conditions in LICENSE +# +# @author: RaNaN +############################################################################### from Bucket import Bucket -from CookieJar import CookieJar from pyload.plugins.network.DefaultRequest import DefaultRequest, DefaultDownload -class RequestFactory(): + +class RequestFactory: def __init__(self, core): self.core = core self.bucket = Bucket() @@ -42,8 +40,8 @@ class RequestFactory(): def getRequest(self, context=None, klass=DefaultRequest): """ Creates a request with new or given context """ - # also accepts cookiejars, not so nice, since it depends on implementation - if isinstance(context, CookieJar): + # also accepts the context class directly + if isinstance(context, klass.CONTEXT_CLASS): return klass(self.getConfig(), context) elif context: return klass(*context) -- cgit v1.2.3