01-10-2010, 03:02 PM | #1 |
Member
Posts: 23
Karma: 22
Join Date: Dec 2009
Device: Kindle DX
|
BasicNewsRecipe interactive?
Hi. It would be helpful for me to test some new recipe ideas if I could call the methods of BasicNewsRecipe interactively.
I oversimplified things by assuming that I could just call the methods from CALIBRE-DEBUG. I'm missing an important step somewhere. Can someone help me run something like the example below from an interactive command line? soup = self.index_to_soup('http://www.xxxxx.com') thanks, Brian |
01-10-2010, 05:44 PM | #2 |
Comparer of the Ephemeris
Posts: 1,496
Karma: 424697
Join Date: Mar 2009
Device: iPad
|
Just add a print statement in your recipe:
print soup.prettify() 'soup' is an instance of BeautifulSoup, which has a pretty print method prettify(). Debugging python with print statements is quick and intuitive. G |
Advert | |
|
01-11-2010, 02:20 PM | #3 |
Member
Posts: 23
Karma: 22
Join Date: Dec 2009
Device: Kindle DX
|
This makes sense, thanks.
However, I'm new to Python, so I'd like the opportunity to play with various functions and methods interactively. It's a lot easier if I can do this interactively as opposed to with PRINT statements in a program. Can the CALIBRE-DEBUG program be used to interactively run the methods of BasicNewsRecipe? |
01-11-2010, 02:24 PM | #4 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You stick
from calibre import ipython ipython(user_ns=locals()) into any point in your code to have an interactive prompt at that point. |
01-11-2010, 04:32 PM | #5 |
Comparer of the Ephemeris
Posts: 1,496
Karma: 424697
Join Date: Mar 2009
Device: iPad
|
Nice, I didn't know about that.
G |
Advert | |
|
01-11-2010, 05:40 PM | #6 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yeah it's a good way to explore when you're new to calibre/python.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PRS-600 Interactive Interpreter | luma | Sony Reader Dev Corner | 1 | 07-24-2010 12:19 PM |
BasicNewsRecipe tag handling | nickredding | Calibre | 3 | 12-22-2009 02:19 PM |
Interactive Fiction... how likely is this? | el.astrologo | Sony Reader | 22 | 12-02-2009 01:27 PM |
Interactive ebooks | Alan Pearce | Introduce Yourself | 0 | 07-01-2009 11:32 AM |
Interactive story | spooky69 | Lounge | 6 | 06-26-2008 02:13 AM |