Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Sony Reader > Sony Reader Dev Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 04-28-2007, 03:38 AM   #1
EatingPie
Blueberry!
EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.
 
EatingPie's Avatar
 
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
Exclamation pielrf beta - Text to LRF with Easy TOC, autoflow, etc.

Out of beta, now officially released on the Reader Content forum. All new versions will be posted there, as well as questions answered and whatnot.
Announcing pielrf, a Python command line tool to convert text to Reader lrf format, utilizing Fallstaff's pylrs.

I've only tested this using Python 2.5 on Mac OS X 10.4.9 (Intel). The main features are easy Table of Content creation, curly quotes, top-of-page header and paragraph autoflow.
pielrf -i flatland.txt -o flatland.lrf -t "Flatland" -a "Edwin A. Abbott"
Please feel free to give this a run. I've been using it primarily for Guteberg and OCR books. I've included a few short examples with the executable.

Chapters.

To create chapters, simply add "<chapter>" before the chapter name.
<chapter>Chapter One
This will add "Chapter One" to the main Table of Contents, along with a button on the Table of Contents page at the beginning of the book.

Paragraphs

There's several ways to delimit paragraphs. Gutenberg uses vertical whitespace (CRs), while other files use tabs on the first line of the paragraph, while still others use spaces. By default, the program automatically the actual method used. You can also force it using the "-b" flag: "-b tab" or "-b cr" for example.

Features.

+ Curly (typographic) quotes.
+ Top-of-page header like those in books from the Sony Connect Store.
+ Paragraph auto-flow.
+ Table of Contents and Chapterization if you use the <chapter> tag.
+ Understands HTML tags <i></i>, <b></b>, <center></center>, <sub></sub>, <sup></sup>, <p></p>.
+ Understands ALL HTML Ampersand tags - &amp;, &pound, &uumlat, etc.
+ Paragraphs can be delimited by tabs, spaces, vertical whitespace.
+ Font size / weight (bold) can be controlled from command line.
+ Ability to control almost everything else from the command line too!

Requirements

Requires install of Python 2.5 from the Developer Tools / Tiger Install CD. Also requires pylrs-1.0.0, along with ElementTree 1.2.6.
-Pie

Versions provided here, see subsequent posts for discussion of changes.
Attached Files
File Type: zip pielrf-1.0.zip (34.9 KB, 952 views)
File Type: zip pielrf-1.1.zip (42.0 KB, 981 views)
File Type: zip pielrf-1.2.zip (42.9 KB, 948 views)

Last edited by EatingPie; 05-08-2007 at 07:59 AM.
EatingPie is offline   Reply With Quote
Old 04-28-2007, 08:33 PM   #2
fireproof
Enthusiast
fireproof began at the beginning.
 
Posts: 45
Karma: 16
Join Date: Mar 2004
Device: Palm Tungsten|TX, Sony Reader^H^H^H^H, iLiad, iPhone
Rats! having trouble with python

This looks like a great tool! I've run into a little trouble, though, and while I google around looking for an answer I figured I'd run it by you, too (I'm no Python expert).

When I run
Code:
pielrf -h
I get the following error:

Code:
Traceback (most recent call last):
  File "/usr/local/bin/pielrf", line 43, in ?
    from pylrs.pylrs import *
ImportError: No module named pylrs.pylrs
Background info -- this is running on an intel Mac mini, OS X 10.4.9, Python 2.5.1 from python.org, and pylrs 1.0.0 and elementtree-1.2.6-20050316 installed per your recommendation.

It seems to be having trouble finding the pylrs library or module, right? Any suggestions?
fireproof is offline   Reply With Quote
Advert
Old 04-28-2007, 09:44 PM   #3
EatingPie
Blueberry!
EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.
 
EatingPie's Avatar
 
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
EDIT: Version 1.2 solves this issue, so no need for links/edits as suggested below.

This is probably not a good time to admit that I knew absolutely NO Python whatsoever a week ago (that's no exaggeration, I'd never even seen the syntax).

I suspect that python.org's version went into the "wrong" place.

Pielrf depends on python being installed in "/usr/bin/python." If you type "/usr/bin/python -V" that will tell you if 2.5.1 installed in the right place. I'm betting that's still Python 2.3.

Next just type "python -V" to see if your default version of Python is 2.5. If it is, you can run pielrf by forcing it to use the right python:

python pielrf -h
(millions of options follow)
That assumes you're in the same directory as pielrf, otherwise you need the full path.

At this point you have a couple of options.

(1) Always run it by starting with python.

python pielrf -i infile -o outfile [etc.]
(2) Make a symbolic link from python2.5 to /usr/bin/python

sudo mv /usr/bin/python /usr/bin/python2.3
sudo ln -s /path/to/python2.5 /usr/bin/python
(3) Edit that first line in pielrf to point to your python install.

Finally, to see where pylrs actuall ended up, you can use the following (slow) command:
sudo find / -name pylrs\*
-Pie

Last edited by EatingPie; 05-06-2007 at 02:42 AM.
EatingPie is offline   Reply With Quote
Old 04-29-2007, 12:40 AM   #4
fireproof
Enthusiast
fireproof began at the beginning.
 
Posts: 45
Karma: 16
Join Date: Mar 2004
Device: Palm Tungsten|TX, Sony Reader^H^H^H^H, iLiad, iPhone
Quite Right -- that fixed it.

You know, I've got to put a post-it on my monitor reminding me to use "find" instead of "locate", too.

Thanks!
fireproof is offline   Reply With Quote
Old 04-29-2007, 02:30 AM   #5
fireproof
Enthusiast
fireproof began at the beginning.
 
Posts: 45
Karma: 16
Join Date: Mar 2004
Device: Palm Tungsten|TX, Sony Reader^H^H^H^H, iLiad, iPhone
Thanks for the help -- I'm using pielrf at manybooks.net now (look for "Sony (beta)" at the bottom of the download menu), and it seems to be working alright... but I no longer have a Reader to test with!

If anyone would care to try one or two I'd be very grateful.

The "headerfontsize" switch is very good news -- will that work with <h1> type header tags?
fireproof is offline   Reply With Quote
Advert
Old 04-29-2007, 01:44 PM   #6
EatingPie
Blueberry!
EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.
 
EatingPie's Avatar
 
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
Pielrf Version 1.1

Quote:
Originally Posted by fireproof
The "headerfontsize" switch is very good news -- will that work with <h1> type header tags?
Now it will.

New version, pielrf-1.1 (see first post in thread to download).

+Added support for <h1>|<h2>|<h3> tags.

These tags provide only one level of header size (same as chapter header). These are uncentered, but you can use them with the <center> tag. See "h1-test.txt" in the examples directory for usage.

+ Added "--without-toc" switch

This switch keeps pielrf from generating the Table of Conents Menu for the Reader. The separate Table of Contents Page is still generated.

EDIT: Issue discussed below is FIXED as of version 1.7, and now TOC Menus load INSTANTLY! I still left in the "--without-toc" flag.

I added this flag because I had extremely slow performance with one book I generated using about ~30 TOC entries. Don't know why this happened, because I have several other books generated with at least the same amount of TOC entries, and they work fine. (I have a suspicion as to the cause, and it's not related to the lrf itself, but I need to explore this further.)

Bugs

There is an outstanding bug with Unicode in the input file. This causes pielrf to crash with a message like the following:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0:
ordinal not in range(128)

The workaround is to remove Unicode characters from your input text file. I hope to fix this in my next update.

-Pie

Last edited by EatingPie; 05-15-2007 at 11:46 AM.
EatingPie is offline   Reply With Quote
Old 04-29-2007, 02:17 PM   #7
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 76,368
Karma: 136006198
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Very nice job!
JSWolf is offline   Reply With Quote
Old 05-05-2007, 04:59 PM   #8
EatingPie
Blueberry!
EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.
 
EatingPie's Avatar
 
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
Pielrf Version 1.2 -- Header Support!

New version, pielrf-1.2 -- "feature-complete" at this point, and my next release should be "official." I will, of course, still take feature requests. As always, see first post in thread to download.

Added Header Support ala the title that appears top/right in Sony Connect Books Book title is automatically taken as top-of-page header, but you can use Chapter Names or Book Title plus Chapter Name, or no header if you so choose. You can even specify the text from the command line via the "--headertext" switch.

The List

+ ADDED HEADER AT TOP OF EACH PAGE
+ Added "--headerstyle" to set how to determine the header.
  • 'title': (default) use the the book title
  • 'chapter': use name of each chapter
  • 'titlechapter': combine book title and chapter name
  • 'none': use no header at all

+ Added "--headertext" to force header to specified text

When using this option, "--headerstyle" setting is ignored.
+ Added "--chapterfontsize" and "--chapterfontweight"

These correctly identify options related to <chapter> Tagged font controls. These were originally called "headers", so the problem is pretty obvious there.
+ Options "--headerfontsize" and "--headerfontweight" now refer to top-of-page headers.
+ Added "--headerheight" to set header height
+ Updated page and margin defaults to fit a header
+ Now uses default python interpreter, which is more likel to be the "right one."
Bugs

Still not handling unicode in input files.

-Pie
EatingPie is offline   Reply With Quote
Old 05-11-2007, 06:42 AM   #9
utrost
Junior Member
utrost began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Mar 2007
Device: Sony reader
Quote:
Originally Posted by EatingPie
Bugs

Still not handling unicode in input files.

-Pie
Hi EatingPie,

for my webbased conversion engine I use pylrs, too.
Maybe you should try instead open an input file like
f = open(infile, 'rb')
with
import codecs

f = codecs.open(infile, 'wU', 'utf-8')
utrost is offline   Reply With Quote
Old 05-11-2007, 11:51 PM   #10
EatingPie
Blueberry!
EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.EatingPie puts his or her pants on both legs at a time.
 
EatingPie's Avatar
 
Posts: 888
Karma: 133343
Join Date: Mar 2007
Device: Sony PRS-500 (RIP); PRS-600 (Good Riddance); PRS-505; PRS-650; PRS-350
Thanks utrost, I'll give that a shot!

I dabbled very briefly in the unicode string conversion, but it made everything else in my program totally fail. I was so busy with preparing a release version of the program, I just bailed. With your suggestion, I'll see if I can make some progress.

-Pie
EatingPie is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
An Easy Way to Create Kindle-ready eBooks with working TOC. Dr. Wily Amazon Kindle 3 01-27-2010 06:17 PM
Making a TOC for LRFs? Issues with Calibre + LRF TOC editor not working Magitek LRF 0 05-06-2009 02:25 PM
What does formatting exactly do to lrf? Easy way to do Collection management? lovemov Sony Reader 4 03-30-2009 03:56 PM
Pielrf - Text to LRF with Easy TOC, Headers, Curly-Quotes, etc. (Mac!) EatingPie LRF 104 01-12-2009 01:35 PM
Quick/easy LIT to LRF converter? OUTATIME Sony Reader Dev Corner 10 02-29-2008 10:44 AM


All times are GMT -4. The time now is 11:22 AM.


MobileRead.com is a privately owned, operated and funded community.