From 7a21b56f2218caef439affb1522b5c29538fe86c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 21 May 2007 18:03:08 +0000 Subject: [PATCH] Fix handling of empty rows. Add option to disable autorotation. --- setup.py | 31 ++++++++++++++++++++------ src/libprs500/__init__.py | 2 +- src/libprs500/ebooks/lrf/html/table.py | 5 ++++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index c2638aa074..f10d440d4b 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #!/usr/bin/env python -import sys, re +import sys, re, os, shutil sys.path.append('src') from libprs500 import __version__ as VERSION @@ -21,13 +21,13 @@ import ez_setup ez_setup.use_setuptools() from setuptools import setup, find_packages - ################################# py2exe ####################################### py2exe_options = {} if sys.argv[1] == 'py2exe': - py2exe_dir = 'C:\libprs500' + py2exe_dir = 'c:\libprs500' + fonts = ['src/libprs500/ebooks/lrf/fonts/prs500'] try: - import py2exe + import py2exe, glob console = [ {'script' : 'src/libprs500/devices/prs500/cli/main.py', 'dest_base':'prs500'}, {'script' : 'src/libprs500/ebooks/lrf/html/convert_from.py', 'dest_base':'html2lrf'}, @@ -45,6 +45,20 @@ if sys.argv[1] == 'py2exe': 'excludes' : excludes}} py2exe_options = {'console' : console, 'windows' : windows, 'options' : options} + + dest_dir = py2exe_dir + '\\fonts\\' + if os.path.exists(dest_dir): + shutil.rmtree(dest_dir, True) + from distutils.filelist import FileList + fl = FileList() + fl.include_pattern('^src.*\.ttf$', is_regex=True) + fl.findall() + + for file in fl.files: + dir = dest_dir + os.path.basename(os.path.dirname(file)) + if not os.path.exists(dir): + os.makedirs(dir) + shutil.copy(file, dir) except ImportError: print >>sys.stderr, 'Must be in Windows to run py2exe' sys.exit(1) @@ -255,7 +269,11 @@ setup( author='Kovid Goyal', author_email='kovid@kovidgoyal.net', url = 'http://libprs500.kovidgoyal.net', - package_data = { 'libprs500.ebooks' : ['*.jpg', '*.pl'], }, + package_data = { + 'libprs500.ebooks' : ['*.jpg', '*.pl'], + 'libpre500.ebooks.lrf.fonts' : ['*.ttf'], + }, + include_package_data = True, entry_points = { 'console_scripts': [ \ 'prs500 = libprs500.devices.prs500.cli.main:main', \ @@ -270,8 +288,7 @@ setup( install_requires = ['sqlalchemy >= 0.3.7'], description = """ - Library to interface with the Sony Portable Reader 500 - over USB. Also has a GUI with library management features. + Ebook management application. """, long_description = """ diff --git a/src/libprs500/__init__.py b/src/libprs500/__init__.py index 77efd5e339..e4127c75bd 100644 --- a/src/libprs500/__init__.py +++ b/src/libprs500/__init__.py @@ -33,7 +33,7 @@ You may have to adjust the GROUP and the location of the rules file to suit your distribution. """ -__version__ = "0.3.34" +__version__ = "0.3.35" __docformat__ = "epytext" __author__ = "Kovid Goyal " diff --git a/src/libprs500/ebooks/lrf/html/table.py b/src/libprs500/ebooks/lrf/html/table.py index 7cfeecb963..96f740e7aa 100644 --- a/src/libprs500/ebooks/lrf/html/table.py +++ b/src/libprs500/ebooks/lrf/html/table.py @@ -193,6 +193,8 @@ class Row(object): width = sum(widths[i:i+cell.colspan]) heights.append(cell.height(width)) i += cell.colspan + if not heights: + return 0 return max(heights) def preferred_width(self, col): @@ -205,7 +207,8 @@ class Row(object): i += 1 if i == col: break - + if not cell: + return 0 return 0 if cell.colspan > 1 else cell.preferred_width() def cell_iterator(self):