Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
looyolo
scrapy
提交
de896fa6
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,发现更多精彩内容 >>
提交
de896fa6
编写于
3月 31, 2010
作者:
P
Pablo Hoffman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactored implementation of Request.replace() and Response.replace()
上级
2ed8a5bf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
26 deletion
+11
-26
scrapy/http/request/__init__.py
scrapy/http/request/__init__.py
+6
-14
scrapy/http/response/__init__.py
scrapy/http/response/__init__.py
+5
-12
未找到文件。
scrapy/http/request/__init__.py
浏览文件 @
de896fa6
...
...
@@ -96,20 +96,12 @@ class Request(object_ref):
"""Return a copy of this Request"""
return
self
.
replace
()
def
replace
(
self
,
url
=
None
,
callback
=
None
,
method
=
None
,
headers
=
None
,
body
=
None
,
\
cookies
=
None
,
meta
=
None
,
encoding
=
None
,
priority
=
None
,
\
dont_filter
=
None
,
errback
=
None
):
def
replace
(
self
,
*
args
,
**
kwargs
):
"""Create a new Request with the same attributes except for those
given new values.
"""
return
self
.
__class__
(
url
=
self
.
url
if
url
is
None
else
url
,
callback
=
callback
,
method
=
self
.
method
if
method
is
None
else
method
,
headers
=
copy
.
deepcopy
(
self
.
headers
)
if
headers
is
None
else
headers
,
body
=
self
.
body
if
body
is
None
else
body
,
cookies
=
self
.
cookies
if
cookies
is
None
else
cookies
,
meta
=
self
.
meta
if
meta
is
None
else
meta
,
encoding
=
self
.
encoding
if
encoding
is
None
else
encoding
,
priority
=
self
.
priority
if
priority
is
None
else
priority
,
dont_filter
=
self
.
dont_filter
if
dont_filter
is
None
else
dont_filter
,
errback
=
errback
)
for
x
in
[
'url'
,
'method'
,
'headers'
,
'body'
,
'cookies'
,
'meta'
,
\
'encoding'
,
'priority'
,
'dont_filter'
]:
kwargs
.
setdefault
(
x
,
getattr
(
self
,
x
))
cls
=
kwargs
.
pop
(
'cls'
,
self
.
__class__
)
return
cls
(
*
args
,
**
kwargs
)
scrapy/http/response/__init__.py
浏览文件 @
de896fa6
...
...
@@ -71,18 +71,11 @@ class Response(object_ref):
"""Return a copy of this Response"""
return
self
.
replace
()
def
replace
(
self
,
url
=
None
,
status
=
None
,
headers
=
None
,
body
=
None
,
meta
=
None
,
\
flags
=
None
,
cls
=
None
,
**
kwargs
):
def
replace
(
self
,
*
args
,
**
kwargs
):
"""Create a new Response with the same attributes except for those
given new values.
"""
if
cls
is
None
:
cls
=
self
.
__class__
new
=
cls
(
url
=
self
.
url
if
url
is
None
else
url
,
status
=
self
.
status
if
status
is
None
else
status
,
headers
=
copy
.
deepcopy
(
self
.
headers
)
if
headers
is
None
else
headers
,
body
=
self
.
body
if
body
is
None
else
body
,
meta
=
self
.
meta
if
meta
is
None
else
meta
,
flags
=
self
.
flags
if
flags
is
None
else
flags
,
**
kwargs
)
return
new
for
x
in
[
'url'
,
'status'
,
'headers'
,
'body'
,
'meta'
,
'flags'
]:
kwargs
.
setdefault
(
x
,
getattr
(
self
,
x
))
cls
=
kwargs
.
pop
(
'cls'
,
self
.
__class__
)
return
cls
(
*
args
,
**
kwargs
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录