From 718ab0963f012606f48cd6cf993761ec04521b44 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 11 Jul 2008 07:52:11 -0700 Subject: [PATCH 1/4] IGN:... --- src/calibre/gui2/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index b70f02c576..d09922848f 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -1259,12 +1259,12 @@ path_to_ebook to the database. if __name__ == '__main__': try: sys.exit(main()) - except: + except Exception, err: if not iswindows: raise + tb = traceback.format_exc() from PyQt4.QtGui import QErrorMessage logfile = os.path.join(os.path.expanduser('~'), 'calibre.log') if os.path.exists(logfile): - log = open(logfile).read() - if log.strip(): - d = QErrorMessage() - d.showMessage(log) + log = open(logfile).read().decode('utf-8', 'ignore') + d = QErrorMessage('Error:%s
Traceback:
%sLog:
'%(unicode(err), unicode(tb), log)) + d.exec_() From b28b7343547ab4bcb3f2eb0f772f962b84164ecd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 11 Jul 2008 08:02:40 -0700 Subject: [PATCH 2/4] Implement #870 (Convert Mobipocket proprietary attributes to CSS) --- src/calibre/ebooks/mobi/reader.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index d2c1327714..dd44393672 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -13,7 +13,7 @@ except ImportError: import Image as PILImage from calibre import __appname__ -from calibre.ebooks.BeautifulSoup import BeautifulSoup +from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag from calibre.ebooks.mobi import MobiError from calibre.ebooks.mobi.huffcdic import HuffReader from calibre.ebooks.mobi.palmdoc import decompress_doc @@ -165,13 +165,14 @@ class MobiReader(object): self.processed_html = self.processed_html.decode(self.book_header.codec, 'ignore') self.extract_images(processed_records, output_dir) self.replace_page_breaks() - self.cleanup() + self.cleanup_html() self.processed_html = re.compile('', re.IGNORECASE).sub( '\n\n', self.processed_html) soup = BeautifulSoup(self.processed_html.replace('> <', '>\n<')) + self.cleanup_soup(soup) guide = soup.find('guide') for elem in soup.findAll(['metadata', 'guide']): elem.extract() @@ -192,9 +193,30 @@ class MobiReader(object): if ncx: open(os.path.splitext(htmlfile)[0]+'.ncx', 'wb').write(ncx) - def cleanup(self): + def cleanup_html(self): self.processed_html = re.sub(r'
', '', self.processed_html) + def cleanup_soup(self, soup): + for tag in soup.recursiveChildGenerator(): + if not isinstance(tag, Tag): continue + styles = [] + try: + styles.append(tag['style']) + except KeyError: + pass + try: + styles.append('margin-top: %s' % tag['height']) + del tag['height'] + except KeyError: + pass + try: + styles.append('text-indent: %s' % tag['width']) + del tag['width'] + except KeyError: + pass + if styles: + tag['style'] = '; '.join(styles) + def create_opf(self, htmlfile, guide=None): mi = self.book_header.exth.mi opf = OPFCreator(os.path.dirname(htmlfile), mi) From d7c3df5f43146b6f2fcfb28c41a3aac728b83831 Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Sat, 12 Jul 2008 12:01:15 -0400 Subject: [PATCH 3/4] Fix HUFF/CDIC decompression regression. --- src/calibre/ebooks/mobi/huffcdic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/huffcdic.py b/src/calibre/ebooks/mobi/huffcdic.py index aa3de47925..693eb314d5 100644 --- a/src/calibre/ebooks/mobi/huffcdic.py +++ b/src/calibre/ebooks/mobi/huffcdic.py @@ -32,7 +32,7 @@ class BitReader(object): class HuffReader(object): - def __init__(self, huffs, extra_flags): + def __init__(self, huffs): self.huffs = huffs if huffs[0][0:4] != 'HUFF' or huffs[0][4:8] != '\x00\x00\x00\x18': From 36d987eed63ac98d6565b168793d704522827958 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 12 Jul 2008 14:38:20 -0700 Subject: [PATCH 4/4] IGN:... --- src/calibre/manual/faq.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst index 9a12253b62..cb381cb8aa 100644 --- a/src/calibre/manual/faq.rst +++ b/src/calibre/manual/faq.rst @@ -131,7 +131,14 @@ Why does |app| show only some of my fonts on OS X? The graphical user interface of |app| is not starting on Windows? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If you've never used the graphical user interface before, try deleting the file library1.db (it will be somewhere under :file:`C:\\Documents and Settings` on Windows XP and :file:`C:\\Users` on Windows Vista. If that doesn't fix the problem, locate the file calibre.log (in the same places as library1.db) and post its contents in a help message on the `Forums `_. +If you've never used the graphical user interface before, try deleting the file library1.db (it will be somewhere under :file:`C:\\Documents and Settings` on Windows XP and :file:`C:\\Users` on Windows Vista. If that doesn't fix the problem, locate the file calibre.log (in the same places as library1.db) and post its contents in a help message on the `Forums `_. If you can't find either file, try using the windows find feature to search for them. If the files dont exist on your system, try the following: + +Start a command prompt (press the windows key and R and type cmd.exe in the run dialog). At the command prompt type the command `calibre-debug` and press enter. You will se a new, green prompt. At theis prompt, type the following two lines:: + + from calibre.gui2.main import main + main() + +Post any output you see when asking for help. I want some feature added to |app|. What can I do? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~