File tree Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 6
6
7
7
import socket
8
8
from pprint import pformat
9
+ from importlib import import_module
9
10
10
11
from twisted .internet import task
11
12
@@ -20,7 +21,8 @@ def __init__(self, crawler):
20
21
if not crawler .settings .getbool ('MEMUSAGE_ENABLED' ):
21
22
raise NotConfigured
22
23
try :
23
- self .resource = __import__ ('resource' )
24
+ # stdlib's resource module is only availabe on unix platforms.
25
+ self .resource = import_module ('resource' )
24
26
except ImportError :
25
27
raise NotConfigured
26
28
Original file line number Diff line number Diff line change 15
15
16
16
import os
17
17
import sys
18
+ from importlib import import_module
18
19
from os .path import join , abspath , dirname
19
20
20
21
BOT_NAME = 'scrapybot'
229
230
230
231
URLLENGTH_LIMIT = 2083
231
232
232
- USER_AGENT = 'Scrapy/%s (+http://scrapy.org)' % __import__ ('scrapy' ).__version__
233
+ USER_AGENT = 'Scrapy/%s (+http://scrapy.org)' % import_module ('scrapy' ).__version__
233
234
234
235
TELNETCONSOLE_ENABLED = 1
235
236
TELNETCONSOLE_PORT = [6023 , 6073 ]
Original file line number Diff line number Diff line change
1
+ from importlib import import_module
1
2
from twisted .trial import unittest
2
3
3
4
class ScrapyUtilsTest (unittest .TestCase ):
4
5
def test_required_openssl_version (self ):
5
6
try :
6
- module = __import__ ('OpenSSL' )
7
+ module = import_module ('OpenSSL' )
7
8
except ImportError as ex :
8
9
raise unittest .SkipTest ("OpenSSL is not available" )
9
10
Original file line number Diff line number Diff line change 4
4
5
5
import os
6
6
7
+ from importlib import import_module
7
8
from twisted .trial .unittest import SkipTest
8
9
9
10
@@ -39,7 +40,7 @@ class SettingsModuleMock(object):
39
40
def get_pythonpath ():
40
41
"""Return a PYTHONPATH suitable to use in processes so that they find this
41
42
installation of Scrapy"""
42
- scrapy_path = __import__ ('scrapy' ).__path__ [0 ]
43
+ scrapy_path = import_module ('scrapy' ).__path__ [0 ]
43
44
return os .path .dirname (scrapy_path ) + os .pathsep + os .environ .get ('PYTHONPATH' , '' )
44
45
45
46
def get_testenv ():
You can’t perform that action at this time.
0 commit comments