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