Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
looyolo
scrapy
提交
a915af2e
S
scrapy
项目概览
looyolo
/
scrapy
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
scrapy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
a915af2e
编写于
5月 11, 2020
作者:
E
Eugenio Lacuesta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove monkeypatches module, E402 flake8 code
上级
314adf6c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
40 deletion
+30
-40
pytest.ini
pytest.ini
+1
-3
scrapy/__init__.py
scrapy/__init__.py
+25
-22
scrapy/_monkeypatches.py
scrapy/_monkeypatches.py
+0
-11
scrapy/linkextractors/__init__.py
scrapy/linkextractors/__init__.py
+1
-1
scrapy/spiders/__init__.py
scrapy/spiders/__init__.py
+3
-3
未找到文件。
pytest.ini
浏览文件 @
a915af2e
...
...
@@ -27,18 +27,16 @@ flake8-ignore =
# Exclude files that are meant to provide top-level imports
# E402: Module level import not at top of file
# F401: Module imported but unused
scrapy/__init__.py
E402
scrapy/core/downloader/handlers/http.py
F401
scrapy/http/__init__.py
F401
scrapy/linkextractors/__init__.py
E402
F401
scrapy/spiders/__init__.py
E402
F401
# Issues pending a review:
scrapy/__init__.py
E402
scrapy/selector/__init__.py
F403
scrapy/spiders/__init__.py
E402
scrapy/utils/http.py
F403
scrapy/utils/markup.py
F403
scrapy/utils/multipart.py
F403
scrapy/utils/url.py
F403
F405
tests/test_loader.py
E741
tests/test_webclient.py
E402
scrapy/__init__.py
浏览文件 @
a915af2e
...
...
@@ -2,33 +2,11 @@
Scrapy - a web crawling and web scraping framework written for Python
"""
__all__
=
[
'__version__'
,
'version_info'
,
'twisted_version'
,
'Spider'
,
'Request'
,
'FormRequest'
,
'Selector'
,
'Item'
,
'Field'
]
# Scrapy version
import
pkgutil
__version__
=
pkgutil
.
get_data
(
__package__
,
'VERSION'
).
decode
(
'ascii'
).
strip
()
version_info
=
tuple
(
int
(
v
)
if
v
.
isdigit
()
else
v
for
v
in
__version__
.
split
(
'.'
))
del
pkgutil
# Check minimum required Python version
import
sys
if
sys
.
version_info
<
(
3
,
5
):
print
(
"Scrapy %s requires Python 3.5"
%
__version__
)
sys
.
exit
(
1
)
# Ignore noisy twisted deprecation warnings
import
warnings
warnings
.
filterwarnings
(
'ignore'
,
category
=
DeprecationWarning
,
module
=
'twisted'
)
del
warnings
# Apply monkey patches to fix issues in external libraries
from
scrapy
import
_monkeypatches
del
_monkeypatches
from
twisted
import
version
as
_txv
twisted_version
=
(
_txv
.
major
,
_txv
.
minor
,
_txv
.
micro
)
# Declare top-level shortcuts
from
scrapy.spiders
import
Spider
...
...
@@ -36,4 +14,29 @@ from scrapy.http import Request, FormRequest
from
scrapy.selector
import
Selector
from
scrapy.item
import
Item
,
Field
__all__
=
[
'__version__'
,
'version_info'
,
'twisted_version'
,
'Spider'
,
'Request'
,
'FormRequest'
,
'Selector'
,
'Item'
,
'Field'
,
]
# Scrapy and Twisted versions
__version__
=
pkgutil
.
get_data
(
__package__
,
'VERSION'
).
decode
(
'ascii'
).
strip
()
version_info
=
tuple
(
int
(
v
)
if
v
.
isdigit
()
else
v
for
v
in
__version__
.
split
(
'.'
))
twisted_version
=
(
_txv
.
major
,
_txv
.
minor
,
_txv
.
micro
)
# Check minimum required Python version
if
sys
.
version_info
<
(
3
,
5
):
print
(
"Scrapy %s requires Python 3.5"
%
__version__
)
sys
.
exit
(
1
)
# Ignore noisy twisted deprecation warnings
warnings
.
filterwarnings
(
'ignore'
,
category
=
DeprecationWarning
,
module
=
'twisted'
)
del
pkgutil
del
sys
del
warnings
scrapy/_monkeypatches.py
已删除
100644 → 0
浏览文件 @
314adf6c
import
copyreg
# Undo what Twisted's perspective broker adds to pickle register
# to prevent bugs like Twisted#7989 while serializing requests
import
twisted.persisted.styles
# NOQA
# Remove only entries with twisted serializers for non-twisted types.
for
k
,
v
in
frozenset
(
copyreg
.
dispatch_table
.
items
()):
if
not
str
(
getattr
(
k
,
'__module__'
,
''
)).
startswith
(
'twisted'
)
\
and
str
(
getattr
(
v
,
'__module__'
,
''
)).
startswith
(
'twisted'
):
copyreg
.
dispatch_table
.
pop
(
k
)
scrapy/linkextractors/__init__.py
浏览文件 @
a915af2e
...
...
@@ -133,4 +133,4 @@ class FilteringLinkExtractor:
# Top-level imports
from
scrapy.linkextractors.lxmlhtml
import
LxmlLinkExtractor
as
LinkExtractor
# noqa: F401
from
scrapy.linkextractors.lxmlhtml
import
LxmlLinkExtractor
as
LinkExtractor
scrapy/spiders/__init__.py
浏览文件 @
a915af2e
...
...
@@ -110,6 +110,6 @@ class Spider(object_ref):
# Top-level imports
from
scrapy.spiders.crawl
import
CrawlSpider
,
Rule
# noqa: F401
from
scrapy.spiders.feed
import
XMLFeedSpider
,
CSVFeedSpider
# noqa: F401
from
scrapy.spiders.sitemap
import
SitemapSpider
# noqa: F401
from
scrapy.spiders.crawl
import
CrawlSpider
,
Rule
from
scrapy.spiders.feed
import
XMLFeedSpider
,
CSVFeedSpider
from
scrapy.spiders.sitemap
import
SitemapSpider
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录