itemloaders
itemloaders copied to clipboard
add the default parameter to get_output_value
Hey guys! Good job decoupling this from Scrapy!
I’ve been thinking about the possibility of adding a default value for the get_output_value()
.
So as an example, you could do:
item_loader.get_output_value('name', 'Foobar')
and you would receive the value for name
if it's available or 'Foobar'
if it's not available.
The implementation seems quite simple, but there are a lot of scenarios that I tried to reproduce in the tests.
Could you?
1. Let me know if you like the idea. I decided to implement it because I frequently find something similar to:
item_loader.get_output_value('name') or ''
2. Check the tests I added and see if it's what you expect or not. If you see any missed case you can also let me know it.
Thanks in advance!
Codecov Report
Merging #26 into master will increase coverage by
1.58%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #26 +/- ##
==========================================
+ Coverage 98.02% 99.60% +1.58%
==========================================
Files 4 4
Lines 253 256 +3
==========================================
+ Hits 248 255 +7
+ Misses 5 1 -4
Impacted Files | Coverage Δ | |
---|---|---|
itemloaders/__init__.py | 99.36% <100.00%> (+1.94%) |
:arrow_up: |
itemloaders/utils.py | 100.00% <0.00%> (+3.12%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update e6c9d3e...1fa0607. Read the comment docs.
Updated @Gallaecio
You are right, we definitely need to update the documentation.