mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-26 19:43:40 +00:00
Replaced remaning __import__(module) calls.
This commit replaces the statements __import__(module) as the previous replaced the statements __import__(module, {}, {}, ['']). At first I thought leaving the single-argument calls, but perhaps it's better to be strict rather than having exceptions to the rule in this case.
This commit is contained in:
parent
343f997ed6
commit
10e22aa5fb
@ -6,6 +6,7 @@ See documentation in docs/topics/extensions.rst
|
||||
|
||||
import socket
|
||||
from pprint import pformat
|
||||
from importlib import import_module
|
||||
|
||||
from twisted.internet import task
|
||||
|
||||
@ -20,7 +21,8 @@ class MemoryUsage(object):
|
||||
if not crawler.settings.getbool('MEMUSAGE_ENABLED'):
|
||||
raise NotConfigured
|
||||
try:
|
||||
self.resource = __import__('resource')
|
||||
# stdlib's resource module is only availabe on unix platforms.
|
||||
self.resource = import_module('resource')
|
||||
except ImportError:
|
||||
raise NotConfigured
|
||||
|
||||
|
@ -15,6 +15,7 @@ Scrapy developers, if you add a setting here remember to:
|
||||
|
||||
import os
|
||||
import sys
|
||||
from importlib import import_module
|
||||
from os.path import join, abspath, dirname
|
||||
|
||||
BOT_NAME = 'scrapybot'
|
||||
@ -229,7 +230,7 @@ TEMPLATES_DIR = abspath(join(dirname(__file__), '..', 'templates'))
|
||||
|
||||
URLLENGTH_LIMIT = 2083
|
||||
|
||||
USER_AGENT = 'Scrapy/%s (+http://scrapy.org)' % __import__('scrapy').__version__
|
||||
USER_AGENT = 'Scrapy/%s (+http://scrapy.org)' % import_module('scrapy').__version__
|
||||
|
||||
TELNETCONSOLE_ENABLED = 1
|
||||
TELNETCONSOLE_PORT = [6023, 6073]
|
||||
|
@ -1,9 +1,10 @@
|
||||
from importlib import import_module
|
||||
from twisted.trial import unittest
|
||||
|
||||
class ScrapyUtilsTest(unittest.TestCase):
|
||||
def test_required_openssl_version(self):
|
||||
try:
|
||||
module = __import__('OpenSSL')
|
||||
module = import_module('OpenSSL')
|
||||
except ImportError as ex:
|
||||
raise unittest.SkipTest("OpenSSL is not available")
|
||||
|
||||
|
@ -4,6 +4,7 @@ This module contains some assorted functions used in tests
|
||||
|
||||
import os
|
||||
|
||||
from importlib import import_module
|
||||
from twisted.trial.unittest import SkipTest
|
||||
|
||||
|
||||
@ -39,7 +40,7 @@ def get_crawler(settings_dict=None):
|
||||
def get_pythonpath():
|
||||
"""Return a PYTHONPATH suitable to use in processes so that they find this
|
||||
installation of Scrapy"""
|
||||
scrapy_path = __import__('scrapy').__path__[0]
|
||||
scrapy_path = import_module('scrapy').__path__[0]
|
||||
return os.path.dirname(scrapy_path) + os.pathsep + os.environ.get('PYTHONPATH', '')
|
||||
|
||||
def get_testenv():
|
||||
|
Loading…
x
Reference in New Issue
Block a user