diff --git a/.project b/.project
new file mode 100644
index 0000000000..e988877507
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ libprs500
+
+
+
+
+
+ org.python.pydev.PyDevBuilder
+
+
+
+
+
+ org.python.pydev.pythonNature
+
+
diff --git a/.pydevproject b/.pydevproject
new file mode 100644
index 0000000000..ce1227533e
--- /dev/null
+++ b/.pydevproject
@@ -0,0 +1,9 @@
+
+
+
+
+python 2.5
+
+/libprs500/src
+
+
diff --git a/setup.py b/setup.py
index a65e2b4ae6..b505010c09 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@
## You should have received a copy of the GNU General Public License along
## 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 python2.5
+#!/usr/bin/env python
import sys
import ez_setup
@@ -33,8 +33,9 @@ except Exception, e:
"WARNING: Could not install the Python Imaging Library.", \
"Some functionality will be unavailable"
-import sys
+
from setuptools import setup, find_packages
+sys.path.append('src')
from libprs500 import __version__ as VERSION
if sys.hexversion < 0x2050000:
@@ -44,34 +45,35 @@ if sys.hexversion < 0x2050000:
setup(
- name='libprs500',
- packages = find_packages(),
- version=VERSION,
- author='Kovid Goyal',
- author_email='kovid@kovidgoyal.net',
- url = 'http://libprs500.kovidgoyal.net',
+ name='libprs500',
+ packages = find_packages('src'),
+ package_dir = { '' : 'src' },
+ version=VERSION,
+ author='Kovid Goyal',
+ author_email='kovid@kovidgoyal.net',
+ url = 'http://libprs500.kovidgoyal.net',
package_data = { \
'libprs500.gui' : ['*.ui'], \
'libprs500.lrf' : ['*.jar', '*.jpg'] \
- },
+ },
entry_points = {
'console_scripts': [ \
- 'prs500 = libprs500.cli.main:main', \
+ 'prs500 = libprs500.cli.main:main', \
'lrf-meta = libprs500.lrf.meta:main', \
'makelrf = libprs500.lrf.makelrf:main'\
- ],
+ ],
'gui_scripts' : [ 'prs500-gui = libprs500.gui.main:main']
- },
- zip_safe = True,
- install_requires=["pyusb>=0.3.5","pyxml>=0.8.4"],
- dependency_links=["http://sourceforge.net/project/showfiles.php?group_id=6473",
- "http://easynews.dl.sourceforge.net/sourceforge/pyusb/pyusb-0.3.5.tar.gz",
- ],
+ },
+ zip_safe = True,
+ install_requires=["pyusb>=0.3.5", "pyxml>=0.8.4"],
+ dependency_links=["http://sourceforge.net/project/showfiles.php?group_id=6473",
+ "http://easynews.dl.sourceforge.net/sourceforge/pyusb/pyusb-0.3.5.tar.gz",
+ ],
description =
"""
Library to interface with the Sony Portable Reader 500
over USB. Also has a GUI with library management features.
- """,
+ """,
long_description =
"""
libprs500 is library to interface with the
@@ -91,19 +93,19 @@ setup(
.. _SONY Portable Reader: http://Sony.com/reader
.. _USB: http://www.usb.org
- """,
- license = 'GPL',
+ """,
+ license = 'GPL',
classifiers = [
- 'Development Status :: 3 - Alpha',
- 'Environment :: Console',
- 'Environment :: X11 Applications :: Qt',
- 'Intended Audience :: Developers',
- 'Intended Audience :: End Users/Desktop',
- 'License :: OSI Approved :: GNU General Public License (GPL)',
- 'Natural Language :: English',
- 'Operating System :: POSIX :: Linux',
- 'Programming Language :: Python',
- 'Topic :: Software Development :: Libraries :: Python Modules',
+ 'Development Status :: 3 - Alpha',
+ 'Environment :: Console',
+ 'Environment :: X11 Applications :: Qt',
+ 'Intended Audience :: Developers',
+ 'Intended Audience :: End Users/Desktop',
+ 'License :: OSI Approved :: GNU General Public License (GPL)',
+ 'Natural Language :: English',
+ 'Operating System :: POSIX :: Linux',
+ 'Programming Language :: Python',
+ 'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Hardware :: Hardware Drivers'
]
)
@@ -111,7 +113,8 @@ setup(
try:
import PyQt4
except ImportError:
- print "You do not have PyQt4 installed. The GUI will not work. You can obtain PyQt4 from http://www.riverbankcomputing.co.uk/pyqt/download.php"
+ print "You do not have PyQt4 installed. The GUI will not work.", \
+ "You can obtain PyQt4 from http://www.riverbankcomputing.co.uk/pyqt/download.php"
else:
import PyQt4.Qt
if PyQt4.Qt.PYQT_VERSION < 0x40101:
diff --git a/src/libprs500/cli/main.py b/src/libprs500/cli/main.py
index 7d55289775..7029ca4d78 100755
--- a/src/libprs500/cli/main.py
+++ b/src/libprs500/cli/main.py
@@ -59,7 +59,7 @@ class FileFormatter(object):
if self.is_readonly: mode += "r-"+x+"r-"+x+"r-"+x
else: mode += "rw"+x+"rw"+x+"rw"+x
return mode
- return property(**locals())
+ return property(doc=doc, fget=fget)
@apply
def name_in_color():
@@ -73,28 +73,28 @@ class FileFormatter(object):
ext = self.name[self.name.rfind("."):]
if ext in (".pdf", ".rtf", ".lrf", ".lrx", ".txt"): cname = green + self.name + normal
return cname
- return property(**locals())
+ return property(doc=doc, fget=fget)
@apply
def human_readable_size():
doc=""" File size in human readable form """
def fget(self):
human_readable(self.size)
- return property(**locals())
+ return property(doc=doc, fget=fget)
@apply
def modification_time():
doc=""" Last modified time in the Linux ls -l format """
def fget(self):
return time.strftime("%Y-%m-%d %H:%M", time.localtime(self.wtime))
- return property(**locals())
+ return property(doc=doc, fget=fget)
@apply
def creation_time():
doc=""" Last modified time in the Linux ls -l format """
def fget(self):
return time.strftime("%Y-%m-%d %H:%M", time.localtime(self.ctime))
- return property(**locals())
+ return property(doc=doc, fget=fget)
def info(dev):
info = dev.get_device_information()
diff --git a/src/libprs500/gui/main.py b/src/libprs500/gui/main.py
index d17c7987cc..6e0c9affdf 100644
--- a/src/libprs500/gui/main.py
+++ b/src/libprs500/gui/main.py
@@ -122,7 +122,7 @@ class Main(QObject, Ui_MainWindow):
for c in range(topleft.column(), bottomright.column()+1):
self.current_view.resizeColumnToContents(c)
for r in range(topleft.row(), bottomright.row()+1):
- self.current_view.resizeRowToContents(c)
+ self.current_view.resizeRowToContents(r)
def show_book(self, current, previous):
if not len(self.current_view.selectedIndexes()):
@@ -239,14 +239,12 @@ class Main(QObject, Ui_MainWindow):
@report_error
def edit(self, action):
if self.library_view.isVisible():
- rows = self.library_view.selectionModel().selectedRows()
- accepted = False
+ rows = self.library_view.selectionModel().selectedRows()
for row in rows:
_id = self.library_model.id_from_index(row)
dialog = QDialog(self.window)
ebd = EditBookDialog(dialog, _id, self.library_model.db)
if dialog.exec_() == QDialog.Accepted:
- accepted = True
title = unicode(ebd.title.text().toUtf8(), 'utf-8').strip()
authors = unicode(ebd.authors.text().toUtf8(), 'utf-8').strip()
rating = ebd.rating.value()
diff --git a/src/libprs500/gui/widgets.py b/src/libprs500/gui/widgets.py
index e63565a079..c4fd62b168 100644
--- a/src/libprs500/gui/widgets.py
+++ b/src/libprs500/gui/widgets.py
@@ -17,7 +17,6 @@ import os
import textwrap
import time
import traceback
-import sys
from operator import itemgetter, attrgetter
from socket import gethostname
from urlparse import urlparse, urlunparse
@@ -32,11 +31,9 @@ from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.Qt import QApplication, QString, QFont, QAbstractListModel, \
QVariant, QAbstractTableModel, QTableView, QListView, \
QLabel, QAbstractItemView, QPixmap, QIcon, QSize, \
- QMessageBox, QSettings, QFileDialog, QErrorMessage, \
- QSpinBox, QPoint, \
- QIODevice, QPainterPath, QItemDelegate, QPainter, QPen, \
- QColor, QLinearGradient, QBrush, QStyle, QStringList, \
- QByteArray, QBuffer, QMimeData, QTextStream, QIODevice, \
+ QSpinBox, QPoint, QPainterPath, QItemDelegate, QPainter, QPen, \
+ QColor, QLinearGradient, QBrush, QStyle, \
+ QByteArray, QBuffer, QMimeData, \
QDrag, QRect
NONE = QVariant() #: Null value to return from the data function of item models
@@ -138,7 +135,7 @@ class FileDragAndDrop(object):
self._dragged_files, urls = [], []
for _file in files:
urls.append(urlunparse(('file', quote(gethostname()), \
- quote(_file.name.encode('utf-8')), '','','')))
+ quote(_file.name.encode('utf-8')), '', '', '')))
self._dragged_files.append(_file)
mime_data.setData("text/uri-list", QByteArray("\n".join(urls)))
user = os.getenv('USER')
@@ -298,10 +295,10 @@ class LibraryBooksView(TableView):
class LibraryDelegate(QItemDelegate):
COLOR = QColor("blue")
SIZE = 16
- PEN = QPen(COLOR, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
+ PEN = QPen(COLOR, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
def __init__(self, parent, rating_column=-1):
- QItemDelegate.__init__(self, parent )
+ QItemDelegate.__init__(self, parent)
self.rating_column = rating_column
self.star_path = QPainterPath()
self.star_path.moveTo(90, 50)
@@ -585,7 +582,7 @@ class LibraryBooksModel(QAbstractTableModel):
if text == None:
text = "Unknown"
return QVariant(text)
- elif role == Qt.TextAlignmentRole and index.column() in [2,3,4]:
+ elif role == Qt.TextAlignmentRole and index.column() in [2, 3, 4]:
return QVariant(Qt.AlignRight | Qt.AlignVCenter)
elif role == Qt.ToolTipRole and index.isValid():
if index.column() in [0, 1, 4, 5]:
@@ -658,7 +655,7 @@ class LibraryBooksModel(QAbstractTableModel):
class DeviceBooksModel(QAbstractTableModel):
@apply
- def booklist():
+ def booklist():
doc = """ The booklist this model is based on """
def fget(self):
return self._orig_data
@@ -674,8 +671,11 @@ class DeviceBooksModel(QAbstractTableModel):
self._orig_data = book_list
self.reset()
- def rowCount(self, parent): return len(self._data)
- def columnCount(self, parent): return 4
+ def rowCount(self, parent):
+ return len(self._data)
+
+ def columnCount(self, parent):
+ return 4
def headerData(self, section, orientation, role):
if role != Qt.DisplayRole:
@@ -705,7 +705,7 @@ class DeviceBooksModel(QAbstractTableModel):
elif col == 3:
text = time.strftime(TIME_WRITE_FMT, book.datetime)
return QVariant(text)
- elif role == Qt.TextAlignmentRole and index.column() in [2,3]:
+ elif role == Qt.TextAlignmentRole and index.column() in [2, 3]:
return QVariant(Qt.AlignRight | Qt.AlignVCenter)
return NONE
diff --git a/src/libprs500/lrf/meta.py b/src/libprs500/lrf/meta.py
index ff4522d0c2..2b5ba2984c 100644
--- a/src/libprs500/lrf/meta.py
+++ b/src/libprs500/lrf/meta.py
@@ -25,7 +25,6 @@ to get and set meta information. For example:
"""
import struct
-import array
import zlib
import xml.dom.minidom as dom