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>
|
11
setup.py
11
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:
|
||||||
@ -45,7 +46,8 @@ if sys.hexversion < 0x2050000:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='libprs500',
|
name='libprs500',
|
||||||
packages = find_packages(),
|
packages = find_packages('src'),
|
||||||
|
package_dir = { '' : 'src' },
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
author='Kovid Goyal',
|
author='Kovid Goyal',
|
||||||
author_email='kovid@kovidgoyal.net',
|
author_email='kovid@kovidgoyal.net',
|
||||||
@ -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()):
|
||||||
@ -240,13 +240,11 @@ class Main(QObject, Ui_MainWindow):
|
|||||||
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
|
||||||
@ -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:
|
||||||
|
@ -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