mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
7e398d3006
@ -9,7 +9,7 @@ engadget.com
|
|||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class Engadget(BasicNewsRecipe):
|
class Engadget(BasicNewsRecipe):
|
||||||
title = u'Engadget_Full'
|
title = u'Engadget'
|
||||||
__author__ = 'Starson17'
|
__author__ = 'Starson17'
|
||||||
__version__ = 'v1.00'
|
__version__ = 'v1.00'
|
||||||
__date__ = '02, July 2011'
|
__date__ = '02, July 2011'
|
||||||
|
BIN
recipes/icons/pecat.png
Normal file
BIN
recipes/icons/pecat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 383 B |
72
recipes/pecat.recipe
Normal file
72
recipes/pecat.recipe
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
'''
|
||||||
|
www.pecat.co.rs
|
||||||
|
'''
|
||||||
|
|
||||||
|
import re
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
class Pecat_rs(BasicNewsRecipe):
|
||||||
|
title = 'Pecat'
|
||||||
|
__author__ = 'Darko Miletic'
|
||||||
|
description = 'Internet portal slobodne Srbije'
|
||||||
|
oldest_article = 15
|
||||||
|
max_articles_per_feed = 100
|
||||||
|
language = 'sr'
|
||||||
|
encoding = 'utf-8'
|
||||||
|
no_stylesheets = True
|
||||||
|
use_embedded_content = True
|
||||||
|
masthead_url = 'http://www.pecat.co.rs/wp-content/themes/zenko-v1/images/logo.jpg'
|
||||||
|
publication_type = 'magazine'
|
||||||
|
extra_css = """
|
||||||
|
@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
|
||||||
|
@font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
|
||||||
|
body{font-family: Arial,Helvetica,sans1,sans-serif}
|
||||||
|
img{display: block; margin-bottom: 1em; margin-top: 1em}
|
||||||
|
p{display: block; margin-bottom: 1em; margin-top: 1em}
|
||||||
|
"""
|
||||||
|
|
||||||
|
conversion_options = {
|
||||||
|
'comment' : description
|
||||||
|
, 'tags' : 'politika, Srbija'
|
||||||
|
, 'publisher': 'Pecat'
|
||||||
|
, 'language' : language
|
||||||
|
}
|
||||||
|
|
||||||
|
preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
|
||||||
|
|
||||||
|
feeds = [(u'Clanci', u'http://www.pecat.co.rs/feed/')]
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
for item in soup.findAll(style=True):
|
||||||
|
del item['style']
|
||||||
|
for item in soup.findAll('a'):
|
||||||
|
limg = item.find('img')
|
||||||
|
if item.string is not None:
|
||||||
|
str = item.string
|
||||||
|
item.replaceWith(str)
|
||||||
|
else:
|
||||||
|
if limg:
|
||||||
|
limg.extract()
|
||||||
|
item.replaceWith(limg)
|
||||||
|
else:
|
||||||
|
str = self.tag_to_string(item)
|
||||||
|
item.replaceWith(str)
|
||||||
|
for item in soup.findAll('img'):
|
||||||
|
dad = item.findParent('p')
|
||||||
|
if dad:
|
||||||
|
mydad = dad.parent
|
||||||
|
myIndex = mydad.contents.index(dad)
|
||||||
|
item.extract()
|
||||||
|
mydad.insert(myIndex,item)
|
||||||
|
for item in soup.findAll('strong'):
|
||||||
|
dad = item.findParent('p')
|
||||||
|
if dad:
|
||||||
|
mydad = dad.parent
|
||||||
|
myIndex = mydad.contents.index(dad)
|
||||||
|
item.extract()
|
||||||
|
item.name='h4'
|
||||||
|
mydad.insert(myIndex,item)
|
||||||
|
return soup
|
@ -1,5 +1,5 @@
|
|||||||
" Project wide builtins
|
" Project wide builtins
|
||||||
let g:pyflakes_builtins += ["dynamic_property", "__", "P", "I", "lopen", "icu_lower", "icu_upper", "icu_title"]
|
let g:pyflakes_builtins += ["dynamic_property", "__", "P", "I", "lopen", "icu_lower", "icu_upper", "icu_title", "ngettext"]
|
||||||
|
|
||||||
python << EOFPY
|
python << EOFPY
|
||||||
import os
|
import os
|
||||||
|
@ -64,7 +64,7 @@ class Check(Command):
|
|||||||
description = 'Check for errors in the calibre source code'
|
description = 'Check for errors in the calibre source code'
|
||||||
|
|
||||||
BUILTINS = ['_', '__', 'dynamic_property', 'I', 'P', 'lopen', 'icu_lower',
|
BUILTINS = ['_', '__', 'dynamic_property', 'I', 'P', 'lopen', 'icu_lower',
|
||||||
'icu_upper', 'icu_title']
|
'icu_upper', 'icu_title', 'ngettext']
|
||||||
CACHE = '.check-cache.pickle'
|
CACHE = '.check-cache.pickle'
|
||||||
|
|
||||||
def get_files(self, cache):
|
def get_files(self, cache):
|
||||||
|
@ -1,646 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
# Originally written by Barry Warsaw <barry@zope.com>
|
|
||||||
#
|
|
||||||
# Minimally patched to make it even more xgettext compatible
|
|
||||||
# by Peter Funk <pf@artcom-gmbh.de>
|
|
||||||
#
|
|
||||||
# 2002-11-22 Jrgen Hermann <jh@web.de>
|
|
||||||
# Added checks that _() only contains string literals, and
|
|
||||||
# command line args are resolved to module lists, i.e. you
|
|
||||||
# can now pass a filename, a module or package name, or a
|
|
||||||
# directory (including globbing chars, important for Win32).
|
|
||||||
# Made docstring fit in 80 chars wide displays using pydoc.
|
|
||||||
#
|
|
||||||
|
|
||||||
__doc__ = """pygettext -- Python equivalent of xgettext(1)
|
|
||||||
|
|
||||||
Many systems (Solaris, Linux, Gnu) provide extensive tools that ease the
|
|
||||||
internationalization of C programs. Most of these tools are independent of
|
|
||||||
the programming language and can be used from within Python programs.
|
|
||||||
Martin von Loewis' work[1] helps considerably in this regard.
|
|
||||||
|
|
||||||
There's one problem though; xgettext is the program that scans source code
|
|
||||||
looking for message strings, but it groks only C (or C++). Python
|
|
||||||
introduces a few wrinkles, such as dual quoting characters, triple quoted
|
|
||||||
strings, and raw strings. xgettext understands none of this.
|
|
||||||
|
|
||||||
Enter pygettext, which uses Python's standard tokenize module to scan
|
|
||||||
Python source code, generating .pot files identical to what GNU xgettext[2]
|
|
||||||
generates for C and C++ code. From there, the standard GNU tools can be
|
|
||||||
used.
|
|
||||||
|
|
||||||
A word about marking Python strings as candidates for translation. GNU
|
|
||||||
xgettext recognizes the following keywords: gettext, dgettext, dcgettext,
|
|
||||||
and gettext_noop. But those can be a lot of text to include all over your
|
|
||||||
code. C and C++ have a trick: they use the C preprocessor. Most
|
|
||||||
internationalized C source includes a #define for gettext() to _() so that
|
|
||||||
what has to be written in the source is much less. Thus these are both
|
|
||||||
translatable strings:
|
|
||||||
|
|
||||||
gettext("Translatable String")
|
|
||||||
_("Translatable String")
|
|
||||||
|
|
||||||
Python of course has no preprocessor so this doesn't work so well. Thus,
|
|
||||||
pygettext searches only for _() by default, but see the -k/--keyword flag
|
|
||||||
below for how to augment this.
|
|
||||||
|
|
||||||
[1] http://www.python.org/workshops/1997-10/proceedings/loewis.html
|
|
||||||
[2] http://www.gnu.org/software/gettext/gettext.html
|
|
||||||
|
|
||||||
NOTE: pygettext attempts to be option and feature compatible with GNU
|
|
||||||
xgettext where ever possible. However some options are still missing or are
|
|
||||||
not fully implemented. Also, xgettext's use of command line switches with
|
|
||||||
option arguments is broken, and in these cases, pygettext just defines
|
|
||||||
additional switches.
|
|
||||||
|
|
||||||
Usage: pygettext [options] inputfile ...
|
|
||||||
|
|
||||||
Options:
|
|
||||||
|
|
||||||
-a
|
|
||||||
--extract-all
|
|
||||||
Extract all strings.
|
|
||||||
|
|
||||||
-d name
|
|
||||||
--default-domain=name
|
|
||||||
Rename the default output file from messages.pot to name.pot.
|
|
||||||
|
|
||||||
-E
|
|
||||||
--escape
|
|
||||||
Replace non-ASCII characters with octal escape sequences.
|
|
||||||
|
|
||||||
-D
|
|
||||||
--docstrings
|
|
||||||
Extract module, class, method, and function docstrings. These do
|
|
||||||
not need to be wrapped in _() markers, and in fact cannot be for
|
|
||||||
Python to consider them docstrings. (See also the -X option).
|
|
||||||
|
|
||||||
-h
|
|
||||||
--help
|
|
||||||
Print this help message and exit.
|
|
||||||
|
|
||||||
-k word
|
|
||||||
--keyword=word
|
|
||||||
Keywords to look for in addition to the default set, which are:
|
|
||||||
%(DEFAULTKEYWORDS)s
|
|
||||||
|
|
||||||
You can have multiple -k flags on the command line.
|
|
||||||
|
|
||||||
-K
|
|
||||||
--no-default-keywords
|
|
||||||
Disable the default set of keywords (see above). Any keywords
|
|
||||||
explicitly added with the -k/--keyword option are still recognized.
|
|
||||||
|
|
||||||
--no-location
|
|
||||||
Do not write filename/lineno location comments.
|
|
||||||
|
|
||||||
-n
|
|
||||||
--add-location
|
|
||||||
Write filename/lineno location comments indicating where each
|
|
||||||
extracted string is found in the source. These lines appear before
|
|
||||||
each msgid. The style of comments is controlled by the -S/--style
|
|
||||||
option. This is the default.
|
|
||||||
|
|
||||||
-o filename
|
|
||||||
--output=filename
|
|
||||||
Rename the default output file from messages.pot to filename. If
|
|
||||||
filename is `-' then the output is sent to standard out.
|
|
||||||
|
|
||||||
-p dir
|
|
||||||
--output-dir=dir
|
|
||||||
Output files will be placed in directory dir.
|
|
||||||
|
|
||||||
-S stylename
|
|
||||||
--style stylename
|
|
||||||
Specify which style to use for location comments. Two styles are
|
|
||||||
supported:
|
|
||||||
|
|
||||||
Solaris # File: filename, line: line-number
|
|
||||||
GNU #: filename:line
|
|
||||||
|
|
||||||
The style name is case insensitive. GNU style is the default.
|
|
||||||
|
|
||||||
-v
|
|
||||||
--verbose
|
|
||||||
Print the names of the files being processed.
|
|
||||||
|
|
||||||
-V
|
|
||||||
--version
|
|
||||||
Print the version of pygettext and exit.
|
|
||||||
|
|
||||||
-w columns
|
|
||||||
--width=columns
|
|
||||||
Set width of output to columns.
|
|
||||||
|
|
||||||
-x filename
|
|
||||||
--exclude-file=filename
|
|
||||||
Specify a file that contains a list of strings that are not be
|
|
||||||
extracted from the input files. Each string to be excluded must
|
|
||||||
appear on a line by itself in the file.
|
|
||||||
|
|
||||||
-X filename
|
|
||||||
--no-docstrings=filename
|
|
||||||
Specify a file that contains a list of files (one per line) that
|
|
||||||
should not have their docstrings extracted. This is only useful in
|
|
||||||
conjunction with the -D option above.
|
|
||||||
|
|
||||||
If `inputfile' is -, standard input is read.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
import imp
|
|
||||||
import sys
|
|
||||||
import glob
|
|
||||||
import time
|
|
||||||
import getopt
|
|
||||||
import token
|
|
||||||
import tokenize
|
|
||||||
import operator
|
|
||||||
|
|
||||||
__version__ = '1.5'
|
|
||||||
|
|
||||||
default_keywords = ['_']
|
|
||||||
DEFAULTKEYWORDS = ', '.join(default_keywords)
|
|
||||||
|
|
||||||
EMPTYSTRING = ''
|
|
||||||
|
|
||||||
from setup import __appname__, __version__ as version
|
|
||||||
|
|
||||||
# The normal pot-file header. msgmerge and Emacs's po-mode work better if it's
|
|
||||||
# there.
|
|
||||||
pot_header = '''\
|
|
||||||
# Translation template file..
|
|
||||||
# Copyright (C) %(year)s Kovid Goyal
|
|
||||||
# Kovid Goyal <kovid@kovidgoyal.net>, %(year)s.
|
|
||||||
#
|
|
||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: %(appname)s %(version)s\\n"
|
|
||||||
"POT-Creation-Date: %%(time)s\\n"
|
|
||||||
"PO-Revision-Date: %%(time)s\\n"
|
|
||||||
"Last-Translator: Automatically generated\\n"
|
|
||||||
"Language-Team: LANGUAGE\\n"
|
|
||||||
"MIME-Version: 1.0\\n"
|
|
||||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
|
||||||
"Content-Transfer-Encoding: 8bit\\n"
|
|
||||||
"Generated-By: pygettext.py %%(version)s\\n"
|
|
||||||
|
|
||||||
'''%dict(appname=__appname__, version=version, year=time.strftime('%Y'))
|
|
||||||
|
|
||||||
def usage(code, msg=''):
|
|
||||||
print >> sys.stderr, __doc__ % globals()
|
|
||||||
if msg:
|
|
||||||
print >> sys.stderr, msg
|
|
||||||
sys.exit(code)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
escapes = []
|
|
||||||
|
|
||||||
def make_escapes(pass_iso8859):
|
|
||||||
global escapes
|
|
||||||
if pass_iso8859:
|
|
||||||
# Allow iso-8859 characters to pass through so that e.g. 'msgid
|
|
||||||
# would result not result in 'msgid "H\366he"'. Otherwise we
|
|
||||||
# escape any character outside the 32..126 range.
|
|
||||||
mod = 128
|
|
||||||
else:
|
|
||||||
mod = 256
|
|
||||||
for i in range(256):
|
|
||||||
if 32 <= (i % mod) <= 126:
|
|
||||||
escapes.append(chr(i))
|
|
||||||
else:
|
|
||||||
escapes.append("\\%03o" % i)
|
|
||||||
escapes[ord('\\')] = '\\\\'
|
|
||||||
escapes[ord('\t')] = '\\t'
|
|
||||||
escapes[ord('\r')] = '\\r'
|
|
||||||
escapes[ord('\n')] = '\\n'
|
|
||||||
escapes[ord('\"')] = '\\"'
|
|
||||||
|
|
||||||
|
|
||||||
def escape(s):
|
|
||||||
global escapes
|
|
||||||
s = list(s)
|
|
||||||
for i in range(len(s)):
|
|
||||||
s[i] = escapes[ord(s[i])]
|
|
||||||
return EMPTYSTRING.join(s)
|
|
||||||
|
|
||||||
|
|
||||||
def safe_eval(s):
|
|
||||||
# unwrap quotes, safely
|
|
||||||
return eval(s, {'__builtins__':{}}, {})
|
|
||||||
|
|
||||||
|
|
||||||
def normalize(s):
|
|
||||||
# This converts the various Python string types into a format that is
|
|
||||||
# appropriate for .po files, namely much closer to C style.
|
|
||||||
lines = s.split('\n')
|
|
||||||
if len(lines) == 1:
|
|
||||||
s = '"' + escape(s) + '"'
|
|
||||||
else:
|
|
||||||
if not lines[-1]:
|
|
||||||
del lines[-1]
|
|
||||||
lines[-1] = lines[-1] + '\n'
|
|
||||||
for i in range(len(lines)):
|
|
||||||
lines[i] = escape(lines[i])
|
|
||||||
lineterm = '\\n"\n"'
|
|
||||||
s = '""\n"' + lineterm.join(lines) + '"'
|
|
||||||
return s
|
|
||||||
|
|
||||||
|
|
||||||
def containsAny(str, set):
|
|
||||||
"""Check whether 'str' contains ANY of the chars in 'set'"""
|
|
||||||
return 1 in [c in str for c in set]
|
|
||||||
|
|
||||||
|
|
||||||
def _visit_pyfiles(list, dirname, names):
|
|
||||||
"""Helper for getFilesForName()."""
|
|
||||||
# get extension for python source files
|
|
||||||
if not globals().has_key('_py_ext'):
|
|
||||||
global _py_ext
|
|
||||||
_py_ext = [triple[0] for triple in imp.get_suffixes()
|
|
||||||
if triple[2] == imp.PY_SOURCE][0]
|
|
||||||
|
|
||||||
# don't recurse into CVS directories
|
|
||||||
if 'CVS' in names:
|
|
||||||
names.remove('CVS')
|
|
||||||
|
|
||||||
# add all *.py files to list
|
|
||||||
list.extend(
|
|
||||||
[os.path.join(dirname, file) for file in names
|
|
||||||
if os.path.splitext(file)[1] == _py_ext]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _get_modpkg_path(dotted_name, pathlist=None):
|
|
||||||
"""Get the filesystem path for a module or a package.
|
|
||||||
|
|
||||||
Return the file system path to a file for a module, and to a directory for
|
|
||||||
a package. Return None if the name is not found, or is a builtin or
|
|
||||||
extension module.
|
|
||||||
"""
|
|
||||||
# split off top-most name
|
|
||||||
parts = dotted_name.split('.', 1)
|
|
||||||
|
|
||||||
if len(parts) > 1:
|
|
||||||
# we have a dotted path, import top-level package
|
|
||||||
try:
|
|
||||||
file, pathname, description = imp.find_module(parts[0], pathlist)
|
|
||||||
if file: file.close()
|
|
||||||
except ImportError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
# check if it's indeed a package
|
|
||||||
if description[2] == imp.PKG_DIRECTORY:
|
|
||||||
# recursively handle the remaining name parts
|
|
||||||
pathname = _get_modpkg_path(parts[1], [pathname])
|
|
||||||
else:
|
|
||||||
pathname = None
|
|
||||||
else:
|
|
||||||
# plain name
|
|
||||||
try:
|
|
||||||
file, pathname, description = imp.find_module(
|
|
||||||
dotted_name, pathlist)
|
|
||||||
if file:
|
|
||||||
file.close()
|
|
||||||
if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]:
|
|
||||||
pathname = None
|
|
||||||
except ImportError:
|
|
||||||
pathname = None
|
|
||||||
|
|
||||||
return pathname
|
|
||||||
|
|
||||||
|
|
||||||
def getFilesForName(name):
|
|
||||||
"""Get a list of module files for a filename, a module or package name,
|
|
||||||
or a directory.
|
|
||||||
"""
|
|
||||||
if not os.path.exists(name):
|
|
||||||
# check for glob chars
|
|
||||||
if containsAny(name, "*?[]"):
|
|
||||||
files = glob.glob(name)
|
|
||||||
list = []
|
|
||||||
for file in files:
|
|
||||||
list.extend(getFilesForName(file))
|
|
||||||
return list
|
|
||||||
|
|
||||||
# try to find module or package
|
|
||||||
name = _get_modpkg_path(name)
|
|
||||||
if not name:
|
|
||||||
return []
|
|
||||||
|
|
||||||
if os.path.isdir(name):
|
|
||||||
# find all python files in directory
|
|
||||||
list = []
|
|
||||||
os.path.walk(name, _visit_pyfiles, list)
|
|
||||||
return list
|
|
||||||
elif os.path.exists(name):
|
|
||||||
# a single file
|
|
||||||
return [name]
|
|
||||||
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
class TokenEater:
|
|
||||||
def __init__(self, options):
|
|
||||||
self.__options = options
|
|
||||||
self.__messages = {}
|
|
||||||
self.__state = self.__waiting
|
|
||||||
self.__data = []
|
|
||||||
self.__lineno = -1
|
|
||||||
self.__freshmodule = 1
|
|
||||||
self.__curfile = None
|
|
||||||
|
|
||||||
def __call__(self, ttype, tstring, stup, etup, line):
|
|
||||||
# dispatch
|
|
||||||
## import token
|
|
||||||
## print >> sys.stderr, 'ttype:', token.tok_name[ttype], \
|
|
||||||
## 'tstring:', tstring
|
|
||||||
self.__state(ttype, tstring, stup[0])
|
|
||||||
|
|
||||||
def __waiting(self, ttype, tstring, lineno):
|
|
||||||
opts = self.__options
|
|
||||||
# Do docstring extractions, if enabled
|
|
||||||
if opts.docstrings and not opts.nodocstrings.get(self.__curfile):
|
|
||||||
# module docstring?
|
|
||||||
if self.__freshmodule:
|
|
||||||
if ttype == tokenize.STRING:
|
|
||||||
self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
|
|
||||||
self.__freshmodule = 0
|
|
||||||
elif ttype not in (tokenize.COMMENT, tokenize.NL):
|
|
||||||
self.__freshmodule = 0
|
|
||||||
return
|
|
||||||
# class docstring?
|
|
||||||
if ttype == tokenize.NAME and tstring in ('class', 'def'):
|
|
||||||
self.__state = self.__suiteseen
|
|
||||||
return
|
|
||||||
if ttype == tokenize.NAME and tstring in opts.keywords:
|
|
||||||
self.__state = self.__keywordseen
|
|
||||||
|
|
||||||
def __suiteseen(self, ttype, tstring, lineno):
|
|
||||||
# ignore anything until we see the colon
|
|
||||||
if ttype == tokenize.OP and tstring == ':':
|
|
||||||
self.__state = self.__suitedocstring
|
|
||||||
|
|
||||||
def __suitedocstring(self, ttype, tstring, lineno):
|
|
||||||
# ignore any intervening noise
|
|
||||||
if ttype == tokenize.STRING:
|
|
||||||
self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
|
|
||||||
self.__state = self.__waiting
|
|
||||||
elif ttype not in (tokenize.NEWLINE, tokenize.INDENT,
|
|
||||||
tokenize.COMMENT):
|
|
||||||
# there was no class docstring
|
|
||||||
self.__state = self.__waiting
|
|
||||||
|
|
||||||
def __keywordseen(self, ttype, tstring, lineno):
|
|
||||||
if ttype == tokenize.OP and tstring == '(':
|
|
||||||
self.__data = []
|
|
||||||
self.__lineno = lineno
|
|
||||||
self.__state = self.__openseen
|
|
||||||
else:
|
|
||||||
self.__state = self.__waiting
|
|
||||||
|
|
||||||
def __openseen(self, ttype, tstring, lineno):
|
|
||||||
if ttype == tokenize.OP and tstring == ')':
|
|
||||||
# We've seen the last of the translatable strings. Record the
|
|
||||||
# line number of the first line of the strings and update the list
|
|
||||||
# of messages seen. Reset state for the next batch. If there
|
|
||||||
# were no strings inside _(), then just ignore this entry.
|
|
||||||
if self.__data:
|
|
||||||
self.__addentry(EMPTYSTRING.join(self.__data))
|
|
||||||
self.__state = self.__waiting
|
|
||||||
elif ttype == tokenize.STRING:
|
|
||||||
self.__data.append(safe_eval(tstring))
|
|
||||||
elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT,
|
|
||||||
token.NEWLINE, tokenize.NL]:
|
|
||||||
# warn if we see anything else than STRING or whitespace
|
|
||||||
print >> sys.stderr, \
|
|
||||||
'*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"'\
|
|
||||||
% {
|
|
||||||
'token': tstring,
|
|
||||||
'file': self.__curfile,
|
|
||||||
'lineno': self.__lineno
|
|
||||||
}
|
|
||||||
self.__state = self.__waiting
|
|
||||||
|
|
||||||
def __addentry(self, msg, lineno=None, isdocstring=0):
|
|
||||||
if lineno is None:
|
|
||||||
lineno = self.__lineno
|
|
||||||
if not msg in self.__options.toexclude:
|
|
||||||
entry = (self.__curfile, lineno)
|
|
||||||
self.__messages.setdefault(msg, {})[entry] = isdocstring
|
|
||||||
|
|
||||||
def set_filename(self, filename):
|
|
||||||
self.__curfile = filename
|
|
||||||
self.__freshmodule = 1
|
|
||||||
|
|
||||||
def write(self, fp):
|
|
||||||
options = self.__options
|
|
||||||
timestamp = time.strftime('%Y-%m-%d %H:%M+%Z')
|
|
||||||
# The time stamp in the header doesn't have the same format as that
|
|
||||||
# generated by xgettext...
|
|
||||||
print >> fp, pot_header % {'time': timestamp, 'version': __version__}
|
|
||||||
# Sort the entries. First sort each particular entry's keys, then
|
|
||||||
# sort all the entries by their first item.
|
|
||||||
reverse = {}
|
|
||||||
for k, v in self.__messages.items():
|
|
||||||
keys = v.keys()
|
|
||||||
keys.sort()
|
|
||||||
reverse.setdefault(tuple(keys), []).append((k, v))
|
|
||||||
rkeys = reverse.keys()
|
|
||||||
rkeys.sort()
|
|
||||||
for rkey in rkeys:
|
|
||||||
rentries = reverse[rkey]
|
|
||||||
rentries.sort()
|
|
||||||
for k, v in rentries:
|
|
||||||
isdocstring = 0
|
|
||||||
# If the entry was gleaned out of a docstring, then add a
|
|
||||||
# comment stating so. This is to aid translators who may wish
|
|
||||||
# to skip translating some unimportant docstrings.
|
|
||||||
if reduce(operator.__add__, v.values()):
|
|
||||||
isdocstring = 1
|
|
||||||
# k is the message string, v is a dictionary-set of (filename,
|
|
||||||
# lineno) tuples. We want to sort the entries in v first by
|
|
||||||
# file name and then by line number.
|
|
||||||
v = v.keys()
|
|
||||||
v.sort()
|
|
||||||
if not options.writelocations:
|
|
||||||
pass
|
|
||||||
# location comments are different b/w Solaris and GNU:
|
|
||||||
elif options.locationstyle == options.SOLARIS:
|
|
||||||
for filename, lineno in v:
|
|
||||||
d = {'filename': filename, 'lineno': lineno}
|
|
||||||
print >>fp, \
|
|
||||||
'# File: %(filename)s, line: %(lineno)d' % d
|
|
||||||
elif options.locationstyle == options.GNU:
|
|
||||||
# fit as many locations on one line, as long as the
|
|
||||||
# resulting line length doesn't exceeds 'options.width'
|
|
||||||
locline = '#:'
|
|
||||||
for filename, lineno in v:
|
|
||||||
d = {'filename': filename, 'lineno': lineno}
|
|
||||||
s = ' %(filename)s:%(lineno)d' % d
|
|
||||||
if len(locline) + len(s) <= options.width:
|
|
||||||
locline = locline + s
|
|
||||||
else:
|
|
||||||
print >> fp, locline
|
|
||||||
locline = "#:" + s
|
|
||||||
if len(locline) > 2:
|
|
||||||
print >> fp, locline
|
|
||||||
if isdocstring:
|
|
||||||
print >> fp, '#, docstring'
|
|
||||||
print >> fp, 'msgid', normalize(k)
|
|
||||||
print >> fp, 'msgstr ""\n'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main(outfile, args=sys.argv[1:]):
|
|
||||||
global default_keywords
|
|
||||||
try:
|
|
||||||
opts, args = getopt.getopt(
|
|
||||||
args,
|
|
||||||
'ad:DEhk:Kno:p:S:Vvw:x:X:',
|
|
||||||
['extract-all', 'default-domain=', 'escape', 'help',
|
|
||||||
'keyword=', 'no-default-keywords',
|
|
||||||
'add-location', 'no-location', 'output=', 'output-dir=',
|
|
||||||
'style=', 'verbose', 'version', 'width=', 'exclude-file=',
|
|
||||||
'docstrings', 'no-docstrings',
|
|
||||||
])
|
|
||||||
except getopt.error, msg:
|
|
||||||
usage(1, msg)
|
|
||||||
|
|
||||||
# for holding option values
|
|
||||||
class Options:
|
|
||||||
# constants
|
|
||||||
GNU = 1
|
|
||||||
SOLARIS = 2
|
|
||||||
# defaults
|
|
||||||
extractall = 0 # FIXME: currently this option has no effect at all.
|
|
||||||
escape = 0
|
|
||||||
keywords = []
|
|
||||||
outpath = ''
|
|
||||||
outfile = 'messages.pot'
|
|
||||||
writelocations = 1
|
|
||||||
locationstyle = GNU
|
|
||||||
verbose = 0
|
|
||||||
width = 78
|
|
||||||
excludefilename = ''
|
|
||||||
docstrings = 0
|
|
||||||
nodocstrings = {}
|
|
||||||
|
|
||||||
options = Options()
|
|
||||||
locations = {'gnu' : options.GNU,
|
|
||||||
'solaris' : options.SOLARIS,
|
|
||||||
}
|
|
||||||
|
|
||||||
# parse options
|
|
||||||
for opt, arg in opts:
|
|
||||||
if opt in ('-h', '--help'):
|
|
||||||
usage(0)
|
|
||||||
elif opt in ('-a', '--extract-all'):
|
|
||||||
options.extractall = 1
|
|
||||||
elif opt in ('-d', '--default-domain'):
|
|
||||||
options.outfile = arg + '.pot'
|
|
||||||
elif opt in ('-E', '--escape'):
|
|
||||||
options.escape = 1
|
|
||||||
elif opt in ('-D', '--docstrings'):
|
|
||||||
options.docstrings = 1
|
|
||||||
elif opt in ('-k', '--keyword'):
|
|
||||||
options.keywords.append(arg)
|
|
||||||
elif opt in ('-K', '--no-default-keywords'):
|
|
||||||
default_keywords = []
|
|
||||||
elif opt in ('-n', '--add-location'):
|
|
||||||
options.writelocations = 1
|
|
||||||
elif opt in ('--no-location',):
|
|
||||||
options.writelocations = 0
|
|
||||||
elif opt in ('-S', '--style'):
|
|
||||||
options.locationstyle = locations.get(arg.lower())
|
|
||||||
if options.locationstyle is None:
|
|
||||||
usage(1, ('Invalid value for --style: %s') % arg)
|
|
||||||
elif opt in ('-o', '--output'):
|
|
||||||
options.outfile = arg
|
|
||||||
elif opt in ('-p', '--output-dir'):
|
|
||||||
options.outpath = arg
|
|
||||||
elif opt in ('-v', '--verbose'):
|
|
||||||
options.verbose = 1
|
|
||||||
elif opt in ('-V', '--version'):
|
|
||||||
print ('pygettext.py (xgettext for Python) %s') % __version__
|
|
||||||
sys.exit(0)
|
|
||||||
elif opt in ('-w', '--width'):
|
|
||||||
try:
|
|
||||||
options.width = int(arg)
|
|
||||||
except ValueError:
|
|
||||||
usage(1, ('--width argument must be an integer: %s') % arg)
|
|
||||||
elif opt in ('-x', '--exclude-file'):
|
|
||||||
options.excludefilename = arg
|
|
||||||
elif opt in ('-X', '--no-docstrings'):
|
|
||||||
fp = open(arg)
|
|
||||||
try:
|
|
||||||
while 1:
|
|
||||||
line = fp.readline()
|
|
||||||
if not line:
|
|
||||||
break
|
|
||||||
options.nodocstrings[line[:-1]] = 1
|
|
||||||
finally:
|
|
||||||
fp.close()
|
|
||||||
|
|
||||||
# calculate escapes
|
|
||||||
make_escapes(options.escape)
|
|
||||||
|
|
||||||
# calculate all keywords
|
|
||||||
options.keywords.extend(default_keywords)
|
|
||||||
|
|
||||||
# initialize list of strings to exclude
|
|
||||||
if options.excludefilename:
|
|
||||||
try:
|
|
||||||
fp = open(options.excludefilename)
|
|
||||||
options.toexclude = fp.readlines()
|
|
||||||
fp.close()
|
|
||||||
except IOError:
|
|
||||||
print >> sys.stderr, (
|
|
||||||
"Can't read --exclude-file: %s") % options.excludefilename
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
options.toexclude = []
|
|
||||||
|
|
||||||
# resolve args to module lists
|
|
||||||
expanded = []
|
|
||||||
for arg in args:
|
|
||||||
if arg == '-':
|
|
||||||
expanded.append(arg)
|
|
||||||
else:
|
|
||||||
expanded.extend(getFilesForName(arg))
|
|
||||||
args = expanded
|
|
||||||
|
|
||||||
# slurp through all the files
|
|
||||||
eater = TokenEater(options)
|
|
||||||
for filename in args:
|
|
||||||
if filename == '-':
|
|
||||||
if options.verbose:
|
|
||||||
print ('Reading standard input')
|
|
||||||
fp = sys.stdin
|
|
||||||
closep = 0
|
|
||||||
else:
|
|
||||||
if options.verbose:
|
|
||||||
print ('Working on %s') % filename
|
|
||||||
fp = open(filename)
|
|
||||||
closep = 1
|
|
||||||
try:
|
|
||||||
eater.set_filename(filename)
|
|
||||||
try:
|
|
||||||
tokenize.tokenize(fp.readline, eater)
|
|
||||||
except tokenize.TokenError, e:
|
|
||||||
print >> sys.stderr, '%s: %s, line %d, column %d' % (
|
|
||||||
e[0], filename, e[1][0], e[1][1])
|
|
||||||
except IndentationError, e:
|
|
||||||
print >> sys.stderr, '%s: %s, line %s, column %s' % (
|
|
||||||
e[0], filename, e.lineno, e[1][1])
|
|
||||||
|
|
||||||
finally:
|
|
||||||
if closep:
|
|
||||||
fp.close()
|
|
||||||
|
|
||||||
# write the output
|
|
||||||
eater.write(outfile)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main(sys.stdout)
|
|
@ -6,11 +6,10 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, cStringIO, tempfile, shutil, atexit, subprocess, glob, re
|
import os, tempfile, shutil, subprocess, glob, re, time, textwrap
|
||||||
from distutils import sysconfig
|
from distutils import sysconfig
|
||||||
|
|
||||||
from setup import Command, __appname__
|
from setup import Command, __appname__, __version__
|
||||||
from setup.pygettext import main as pygettext
|
|
||||||
from setup.build_environment import pyqt
|
from setup.build_environment import pyqt
|
||||||
|
|
||||||
class POT(Command):
|
class POT(Command):
|
||||||
@ -60,19 +59,50 @@ class POT(Command):
|
|||||||
|
|
||||||
|
|
||||||
def run(self, opts):
|
def run(self, opts):
|
||||||
|
pot_header = textwrap.dedent('''\
|
||||||
|
# Translation template file..
|
||||||
|
# Copyright (C) %(year)s Kovid Goyal
|
||||||
|
# Kovid Goyal <kovid@kovidgoyal.net>, %(year)s.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: %(appname)s %(version)s\\n"
|
||||||
|
"POT-Creation-Date: %(time)s\\n"
|
||||||
|
"PO-Revision-Date: %(time)s\\n"
|
||||||
|
"Last-Translator: Automatically generated\\n"
|
||||||
|
"Language-Team: LANGUAGE\\n"
|
||||||
|
"MIME-Version: 1.0\\n"
|
||||||
|
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/calibre\\n"
|
||||||
|
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\\n"
|
||||||
|
|
||||||
|
''')%dict(appname=__appname__, version=__version__,
|
||||||
|
year=time.strftime('%Y'),
|
||||||
|
time=time.strftime('%Y-%m-%d %H:%M+%Z'))
|
||||||
|
|
||||||
files = self.source_files()
|
files = self.source_files()
|
||||||
buf = cStringIO.StringIO()
|
with tempfile.NamedTemporaryFile() as fl:
|
||||||
self.info('Creating translations template...')
|
fl.write('\n'.join(files))
|
||||||
tempdir = tempfile.mkdtemp()
|
fl.flush()
|
||||||
atexit.register(shutil.rmtree, tempdir)
|
out = tempfile.NamedTemporaryFile(suffix='.pot', delete=False)
|
||||||
pygettext(buf, ['-k', '__', '-p', tempdir]+files)
|
out.close()
|
||||||
src = buf.getvalue()
|
self.info('Creating translations template...')
|
||||||
src += '\n\n' + self.get_tweaks_docs()
|
subprocess.check_call(['xgettext', '-f', fl.name,
|
||||||
pot = os.path.join(self.PATH, __appname__+'.pot')
|
'--default-domain=calibre', '-o', out.name, '-L', 'Python',
|
||||||
with open(pot, 'wb') as f:
|
'--from-code=UTF-8', '--sort-by-file', '--omit-header',
|
||||||
f.write(src)
|
'--no-wrap', '-k__',
|
||||||
self.info('Translations template:', os.path.abspath(pot))
|
])
|
||||||
return pot
|
with open(out.name, 'rb') as f:
|
||||||
|
src = f.read()
|
||||||
|
os.remove(out.name)
|
||||||
|
src = pot_header + '\n' + src
|
||||||
|
src += '\n\n' + self.get_tweaks_docs()
|
||||||
|
pot = os.path.join(self.PATH, __appname__+'.pot')
|
||||||
|
with open(pot, 'wb') as f:
|
||||||
|
f.write(src)
|
||||||
|
self.info('Translations template:', os.path.abspath(pot))
|
||||||
|
return pot
|
||||||
|
|
||||||
|
|
||||||
class Translations(POT):
|
class Translations(POT):
|
||||||
|
@ -211,6 +211,28 @@ if __name__ == '__main__':
|
|||||||
class TestSHLock(unittest.TestCase):
|
class TestSHLock(unittest.TestCase):
|
||||||
"""Testcases for SHLock class."""
|
"""Testcases for SHLock class."""
|
||||||
|
|
||||||
|
def test_multithread_deadlock(self):
|
||||||
|
lock = SHLock()
|
||||||
|
def two_shared():
|
||||||
|
r = RWLockWrapper(lock)
|
||||||
|
with r:
|
||||||
|
time.sleep(0.2)
|
||||||
|
with r:
|
||||||
|
pass
|
||||||
|
def one_exclusive():
|
||||||
|
time.sleep(0.1)
|
||||||
|
w = RWLockWrapper(lock, is_shared=False)
|
||||||
|
with w:
|
||||||
|
pass
|
||||||
|
threads = [Thread(target=two_shared), Thread(target=one_exclusive)]
|
||||||
|
for t in threads:
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
for t in threads:
|
||||||
|
t.join(5)
|
||||||
|
live = [t for t in threads if t.is_alive()]
|
||||||
|
self.assertListEqual(live, [], 'ShLock hung')
|
||||||
|
|
||||||
def test_upgrade(self):
|
def test_upgrade(self):
|
||||||
lock = SHLock()
|
lock = SHLock()
|
||||||
lock.acquire(shared=True)
|
lock.acquire(shared=True)
|
||||||
|
@ -124,11 +124,11 @@ class ANDROID(USBMS):
|
|||||||
'IDEOS_TABLET', 'MYTOUCH_4G', 'UMS_COMPOSITE', 'SCH-I800_CARD',
|
'IDEOS_TABLET', 'MYTOUCH_4G', 'UMS_COMPOSITE', 'SCH-I800_CARD',
|
||||||
'7', 'A956', 'A955', 'A43', 'ANDROID_PLATFORM', 'TEGRA_2',
|
'7', 'A956', 'A955', 'A43', 'ANDROID_PLATFORM', 'TEGRA_2',
|
||||||
'MB860', 'MULTI-CARD', 'MID7015A', 'INCREDIBLE', 'A7EB', 'STREAK',
|
'MB860', 'MULTI-CARD', 'MID7015A', 'INCREDIBLE', 'A7EB', 'STREAK',
|
||||||
'MB525', 'ANDROID2.3']
|
'MB525', 'ANDROID2.3', 'SGH-I997']
|
||||||
WINDOWS_CARD_A_MEM = ['ANDROID_PHONE', 'GT-I9000_CARD', 'SGH-I897',
|
WINDOWS_CARD_A_MEM = ['ANDROID_PHONE', 'GT-I9000_CARD', 'SGH-I897',
|
||||||
'FILE-STOR_GADGET', 'SGH-T959', 'SAMSUNG_ANDROID', 'GT-P1000_CARD',
|
'FILE-STOR_GADGET', 'SGH-T959', 'SAMSUNG_ANDROID', 'GT-P1000_CARD',
|
||||||
'A70S', 'A101IT', '7', 'INCREDIBLE', 'A7EB', 'SGH-T849_CARD',
|
'A70S', 'A101IT', '7', 'INCREDIBLE', 'A7EB', 'SGH-T849_CARD',
|
||||||
'__UMS_COMPOSITE']
|
'__UMS_COMPOSITE', 'SGH-I997_CARD']
|
||||||
|
|
||||||
OSX_MAIN_MEM = 'Android Device Main Memory'
|
OSX_MAIN_MEM = 'Android Device Main Memory'
|
||||||
|
|
||||||
|
@ -446,7 +446,8 @@ class ITUNES(DriverBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.report_progress is not None:
|
if self.report_progress is not None:
|
||||||
self.report_progress((i+1)/book_count, _('%d of %d') % (i+1, book_count))
|
self.report_progress((i+1)/book_count,
|
||||||
|
_('%(num)d of %(tot)d') % dict(num=i+1, tot=book_count))
|
||||||
self._purge_orphans(library_books, cached_books)
|
self._purge_orphans(library_books, cached_books)
|
||||||
|
|
||||||
elif iswindows:
|
elif iswindows:
|
||||||
@ -485,7 +486,8 @@ class ITUNES(DriverBase):
|
|||||||
|
|
||||||
if self.report_progress is not None:
|
if self.report_progress is not None:
|
||||||
self.report_progress((i+1)/book_count,
|
self.report_progress((i+1)/book_count,
|
||||||
_('%d of %d') % (i+1, book_count))
|
_('%(num)d of %(tot)d') % dict(num=i+1,
|
||||||
|
tot=book_count))
|
||||||
self._purge_orphans(library_books, cached_books)
|
self._purge_orphans(library_books, cached_books)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
@ -1075,7 +1077,8 @@ class ITUNES(DriverBase):
|
|||||||
|
|
||||||
# Report progress
|
# Report progress
|
||||||
if self.report_progress is not None:
|
if self.report_progress is not None:
|
||||||
self.report_progress((i+1)/file_count, _('%d of %d') % (i+1, file_count))
|
self.report_progress((i+1)/file_count,
|
||||||
|
_('%(num)d of %(tot)d') % dict(num=i+1, tot=file_count))
|
||||||
|
|
||||||
elif iswindows:
|
elif iswindows:
|
||||||
try:
|
try:
|
||||||
@ -1118,7 +1121,8 @@ class ITUNES(DriverBase):
|
|||||||
|
|
||||||
# Report progress
|
# Report progress
|
||||||
if self.report_progress is not None:
|
if self.report_progress is not None:
|
||||||
self.report_progress((i+1)/file_count, _('%d of %d') % (i+1, file_count))
|
self.report_progress((i+1)/file_count,
|
||||||
|
_('%(num)d of %(tot)d') % dict(num=i+1, tot=file_count))
|
||||||
finally:
|
finally:
|
||||||
pythoncom.CoUninitialize()
|
pythoncom.CoUninitialize()
|
||||||
|
|
||||||
@ -3107,7 +3111,8 @@ class ITUNES_ASYNC(ITUNES):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.report_progress is not None:
|
if self.report_progress is not None:
|
||||||
self.report_progress((i+1)/book_count, _('%d of %d') % (i+1, book_count))
|
self.report_progress((i+1)/book_count,
|
||||||
|
_('%(num)d of %(tot)d') % dict(num=i+1, tot=book_count))
|
||||||
|
|
||||||
elif iswindows:
|
elif iswindows:
|
||||||
try:
|
try:
|
||||||
@ -3147,7 +3152,8 @@ class ITUNES_ASYNC(ITUNES):
|
|||||||
|
|
||||||
if self.report_progress is not None:
|
if self.report_progress is not None:
|
||||||
self.report_progress((i+1)/book_count,
|
self.report_progress((i+1)/book_count,
|
||||||
_('%d of %d') % (i+1, book_count))
|
_('%(num)d of %(tot)d') % dict(num=i+1,
|
||||||
|
tot=book_count))
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
pythoncom.CoUninitialize()
|
pythoncom.CoUninitialize()
|
||||||
|
@ -57,6 +57,7 @@ class KOBO(USBMS):
|
|||||||
def initialize(self):
|
def initialize(self):
|
||||||
USBMS.initialize(self)
|
USBMS.initialize(self)
|
||||||
self.book_class = Book
|
self.book_class = Book
|
||||||
|
self.dbversion = 7
|
||||||
|
|
||||||
def books(self, oncard=None, end_session=True):
|
def books(self, oncard=None, end_session=True):
|
||||||
from calibre.ebooks.metadata.meta import path_to_ext
|
from calibre.ebooks.metadata.meta import path_to_ext
|
||||||
@ -214,7 +215,7 @@ class KOBO(USBMS):
|
|||||||
'BookID is Null and ( ___ExpirationStatus <> "3" or ___ExpirationStatus is Null)'
|
'BookID is Null and ( ___ExpirationStatus <> "3" or ___ExpirationStatus is Null)'
|
||||||
elif self.dbversion < 16 and self.dbversion >= 14:
|
elif self.dbversion < 16 and self.dbversion >= 14:
|
||||||
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
||||||
'ImageID, ReadStatus, ___ExpirationStatus, "-1" as FavouritesIndex, "-1" as Accessibility from content where ' \
|
'ImageID, ReadStatus, ___ExpirationStatus, FavouritesIndex, "-1" as Accessibility from content where ' \
|
||||||
'BookID is Null and ( ___ExpirationStatus <> "3" or ___ExpirationStatus is Null)'
|
'BookID is Null and ( ___ExpirationStatus <> "3" or ___ExpirationStatus is Null)'
|
||||||
elif self.dbversion < 14 and self.dbversion >= 8:
|
elif self.dbversion < 14 and self.dbversion >= 8:
|
||||||
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
||||||
@ -319,8 +320,15 @@ class KOBO(USBMS):
|
|||||||
# Kobo does not delete the Book row (ie the row where the BookID is Null)
|
# Kobo does not delete the Book row (ie the row where the BookID is Null)
|
||||||
# The next server sync should remove the row
|
# The next server sync should remove the row
|
||||||
cursor.execute('delete from content where BookID = ?', t)
|
cursor.execute('delete from content where BookID = ?', t)
|
||||||
cursor.execute('update content set ReadStatus=0, FirstTimeReading = \'true\', ___PercentRead=0, ___ExpirationStatus=3 ' \
|
try:
|
||||||
|
cursor.execute('update content set ReadStatus=0, FirstTimeReading = \'true\', ___PercentRead=0, ___ExpirationStatus=3 ' \
|
||||||
'where BookID is Null and ContentID =?',t)
|
'where BookID is Null and ContentID =?',t)
|
||||||
|
except Exception as e:
|
||||||
|
if 'no such column' not in str(e):
|
||||||
|
raise
|
||||||
|
cursor.execute('update content set ReadStatus=0, FirstTimeReading = \'true\', ___PercentRead=0 ' \
|
||||||
|
'where BookID is Null and ContentID =?',t)
|
||||||
|
|
||||||
|
|
||||||
connection.commit()
|
connection.commit()
|
||||||
|
|
||||||
@ -609,9 +617,10 @@ class KOBO(USBMS):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
try:
|
try:
|
||||||
cursor.execute (query)
|
cursor.execute (query)
|
||||||
except:
|
except Exception as e:
|
||||||
debug_print(' Database Exception: Unable to reset Shortlist list')
|
debug_print(' Database Exception: Unable to reset Shortlist list')
|
||||||
raise
|
if 'no such column' not in str(e):
|
||||||
|
raise
|
||||||
else:
|
else:
|
||||||
connection.commit()
|
connection.commit()
|
||||||
debug_print(' Commit: Reset FavouritesIndex list')
|
debug_print(' Commit: Reset FavouritesIndex list')
|
||||||
@ -623,9 +632,10 @@ class KOBO(USBMS):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute('update content set FavouritesIndex=1 where BookID is Null and ContentID = ?', t)
|
cursor.execute('update content set FavouritesIndex=1 where BookID is Null and ContentID = ?', t)
|
||||||
except:
|
except Exception as e:
|
||||||
debug_print(' Database Exception: Unable set book as Shortlist')
|
debug_print(' Database Exception: Unable set book as Shortlist')
|
||||||
raise
|
if 'no such column' not in str(e):
|
||||||
|
raise
|
||||||
else:
|
else:
|
||||||
connection.commit()
|
connection.commit()
|
||||||
debug_print(' Commit: Set FavouritesIndex')
|
debug_print(' Commit: Set FavouritesIndex')
|
||||||
@ -664,7 +674,8 @@ class KOBO(USBMS):
|
|||||||
# Need to reset the collections outside the particular loops
|
# Need to reset the collections outside the particular loops
|
||||||
# otherwise the last item will not be removed
|
# otherwise the last item will not be removed
|
||||||
self.reset_readstatus(connection, oncard)
|
self.reset_readstatus(connection, oncard)
|
||||||
self.reset_favouritesindex(connection, oncard)
|
if self.dbversion >= 14:
|
||||||
|
self.reset_favouritesindex(connection, oncard)
|
||||||
|
|
||||||
# Process any collections that exist
|
# Process any collections that exist
|
||||||
for category, books in collections.items():
|
for category, books in collections.items():
|
||||||
@ -682,7 +693,7 @@ class KOBO(USBMS):
|
|||||||
if category in readstatuslist.keys():
|
if category in readstatuslist.keys():
|
||||||
# Manage ReadStatus
|
# Manage ReadStatus
|
||||||
self.set_readstatus(connection, ContentID, readstatuslist.get(category))
|
self.set_readstatus(connection, ContentID, readstatuslist.get(category))
|
||||||
if category == 'Shortlist':
|
if category == 'Shortlist' and self.dbversion >= 14:
|
||||||
# Manage FavouritesIndex/Shortlist
|
# Manage FavouritesIndex/Shortlist
|
||||||
self.set_favouritesindex(connection, ContentID)
|
self.set_favouritesindex(connection, ContentID)
|
||||||
if category in accessibilitylist.keys():
|
if category in accessibilitylist.keys():
|
||||||
@ -692,8 +703,9 @@ class KOBO(USBMS):
|
|||||||
# Since no collections exist the ReadStatus needs to be reset to 0 (Unread)
|
# Since no collections exist the ReadStatus needs to be reset to 0 (Unread)
|
||||||
debug_print("No Collections - reseting ReadStatus")
|
debug_print("No Collections - reseting ReadStatus")
|
||||||
self.reset_readstatus(connection, oncard)
|
self.reset_readstatus(connection, oncard)
|
||||||
debug_print("No Collections - reseting FavouritesIndex")
|
if self.dbversion >= 14:
|
||||||
self.reset_favouritesindex(connection, oncard)
|
debug_print("No Collections - reseting FavouritesIndex")
|
||||||
|
self.reset_favouritesindex(connection, oncard)
|
||||||
|
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
|
@ -67,10 +67,10 @@ class PRS505(USBMS):
|
|||||||
_('Comma separated list of metadata fields '
|
_('Comma separated list of metadata fields '
|
||||||
'to turn into collections on the device. Possibilities include: ')+\
|
'to turn into collections on the device. Possibilities include: ')+\
|
||||||
'series, tags, authors' +\
|
'series, tags, authors' +\
|
||||||
_('. Two special collections are available: %s:%s and %s:%s. Add '
|
_('. Two special collections are available: %(abt)s:%(abtv)s and %(aba)s:%(abav)s. Add '
|
||||||
'these values to the list to enable them. The collections will be '
|
'these values to the list to enable them. The collections will be '
|
||||||
'given the name provided after the ":" character.')%(
|
'given the name provided after the ":" character.')%dict(
|
||||||
'abt', ALL_BY_TITLE, 'aba', ALL_BY_AUTHOR),
|
abt='abt', abtv=ALL_BY_TITLE, aba='aba', abav=ALL_BY_AUTHOR),
|
||||||
_('Upload separate cover thumbnails for books (newer readers)') +
|
_('Upload separate cover thumbnails for books (newer readers)') +
|
||||||
':::'+_('Normally, the SONY readers get the cover image from the'
|
':::'+_('Normally, the SONY readers get the cover image from the'
|
||||||
' ebook file itself. With this option, calibre will send a '
|
' ebook file itself. With this option, calibre will send a '
|
||||||
|
@ -144,9 +144,9 @@ def add_pipeline_options(parser, plumber):
|
|||||||
|
|
||||||
'HEURISTIC PROCESSING' : (
|
'HEURISTIC PROCESSING' : (
|
||||||
_('Modify the document text and structure using common'
|
_('Modify the document text and structure using common'
|
||||||
' patterns. Disabled by default. Use %s to enable. '
|
' patterns. Disabled by default. Use %(en)s to enable. '
|
||||||
' Individual actions can be disabled with the %s options.')
|
' Individual actions can be disabled with the %(dis)s options.')
|
||||||
% ('--enable-heuristics', '--disable-*'),
|
% dict(en='--enable-heuristics', dis='--disable-*'),
|
||||||
['enable_heuristics'] + HEURISTIC_OPTIONS
|
['enable_heuristics'] + HEURISTIC_OPTIONS
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ class ParseError(ValueError):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.desc = desc
|
self.desc = desc
|
||||||
ValueError.__init__(self,
|
ValueError.__init__(self,
|
||||||
_('Failed to parse: %s with error: %s')%(name, desc))
|
_('Failed to parse: %(name)s with error: %(err)s')%dict(
|
||||||
|
name=name, err=desc))
|
||||||
|
|
||||||
class ePubFixer(Plugin):
|
class ePubFixer(Plugin):
|
||||||
|
|
||||||
|
@ -561,7 +561,9 @@ class HTMLConverter(object):
|
|||||||
para = children[i]
|
para = children[i]
|
||||||
break
|
break
|
||||||
if para is None:
|
if para is None:
|
||||||
raise ConversionError(_('Failed to parse link %s %s')%(tag, children))
|
raise ConversionError(
|
||||||
|
_('Failed to parse link %(tag)s %(children)s')%dict(
|
||||||
|
tag=tag, children=children))
|
||||||
text = self.get_text(tag, 1000)
|
text = self.get_text(tag, 1000)
|
||||||
if not text:
|
if not text:
|
||||||
text = 'Link'
|
text = 'Link'
|
||||||
@ -954,7 +956,9 @@ class HTMLConverter(object):
|
|||||||
self.scaled_images[path] = pt
|
self.scaled_images[path] = pt
|
||||||
return pt.name
|
return pt.name
|
||||||
except (IOError, SystemError) as err: # PIL chokes on interlaced PNG images as well a some GIF images
|
except (IOError, SystemError) as err: # PIL chokes on interlaced PNG images as well a some GIF images
|
||||||
self.log.warning(_('Unable to process image %s. Error: %s')%(path, err))
|
self.log.warning(
|
||||||
|
_('Unable to process image %(path)s. Error: %(err)s')%dict(
|
||||||
|
path=path, err=err))
|
||||||
|
|
||||||
if width == None or height == None:
|
if width == None or height == None:
|
||||||
width, height = im.size
|
width, height = im.size
|
||||||
@ -1014,7 +1018,7 @@ class HTMLConverter(object):
|
|||||||
try:
|
try:
|
||||||
self.images[path] = ImageStream(path, encoding=encoding)
|
self.images[path] = ImageStream(path, encoding=encoding)
|
||||||
except LrsError as err:
|
except LrsError as err:
|
||||||
self.log.warning(_('Could not process image: %s\n%s')%(
|
self.log.warning(('Could not process image: %s\n%s')%(
|
||||||
original_path, err))
|
original_path, err))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -4,8 +4,9 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import sys, array, os, re, codecs, logging
|
import sys, array, os, re, codecs, logging
|
||||||
|
|
||||||
from calibre import setup_cli_handlers, sanitize_file_name
|
from calibre import setup_cli_handlers
|
||||||
from calibre.utils.config import OptionParser
|
from calibre.utils.config import OptionParser
|
||||||
|
from calibre.utils.filenames import ascii_filename
|
||||||
from calibre.ebooks.lrf.meta import LRFMetaFile
|
from calibre.ebooks.lrf.meta import LRFMetaFile
|
||||||
from calibre.ebooks.lrf.objects import get_object, PageTree, StyleObject, \
|
from calibre.ebooks.lrf.objects import get_object, PageTree, StyleObject, \
|
||||||
Font, Text, TOCObject, BookAttr, ruby_tags
|
Font, Text, TOCObject, BookAttr, ruby_tags
|
||||||
@ -89,7 +90,7 @@ class LRFDocument(LRFMetaFile):
|
|||||||
bookinfo += u'<FreeText reading="">%s</FreeText>\n</BookInfo>\n<DocInfo>\n'%(self.metadata.free_text,)
|
bookinfo += u'<FreeText reading="">%s</FreeText>\n</BookInfo>\n<DocInfo>\n'%(self.metadata.free_text,)
|
||||||
th = self.doc_info.thumbnail
|
th = self.doc_info.thumbnail
|
||||||
if th:
|
if th:
|
||||||
prefix = sanitize_file_name(self.metadata.title, as_unicode=True)
|
prefix = ascii_filename(self.metadata.title)
|
||||||
bookinfo += u'<CThumbnail file="%s" />\n'%(prefix+'_thumbnail.'+self.doc_info.thumbnail_extension,)
|
bookinfo += u'<CThumbnail file="%s" />\n'%(prefix+'_thumbnail.'+self.doc_info.thumbnail_extension,)
|
||||||
if write_files:
|
if write_files:
|
||||||
open(prefix+'_thumbnail.'+self.doc_info.thumbnail_extension, 'wb').write(th)
|
open(prefix+'_thumbnail.'+self.doc_info.thumbnail_extension, 'wb').write(th)
|
||||||
|
@ -742,7 +742,7 @@ class Metadata(object):
|
|||||||
ans += [('ISBN', unicode(self.isbn))]
|
ans += [('ISBN', unicode(self.isbn))]
|
||||||
ans += [(_('Tags'), u', '.join([unicode(t) for t in self.tags]))]
|
ans += [(_('Tags'), u', '.join([unicode(t) for t in self.tags]))]
|
||||||
if self.series:
|
if self.series:
|
||||||
ans += [(_('Series'), unicode(self.series)+ ' #%s'%self.format_series_index())]
|
ans += [_('Series'), unicode(self.series) + ' #%s'%self.format_series_index()]
|
||||||
ans += [(_('Language'), unicode(self.language))]
|
ans += [(_('Language'), unicode(self.language))]
|
||||||
if self.timestamp is not None:
|
if self.timestamp is not None:
|
||||||
ans += [(_('Timestamp'), unicode(self.timestamp.isoformat(' ')))]
|
ans += [(_('Timestamp'), unicode(self.timestamp.isoformat(' ')))]
|
||||||
|
@ -21,9 +21,9 @@ USAGE='%%prog ebook_file [' + _('options') + ']\n' + \
|
|||||||
_('''
|
_('''
|
||||||
Read/Write metadata from/to ebook files.
|
Read/Write metadata from/to ebook files.
|
||||||
|
|
||||||
Supported formats for reading metadata: %s
|
Supported formats for reading metadata: %(read)s
|
||||||
|
|
||||||
Supported formats for writing metadata: %s
|
Supported formats for writing metadata: %(write)s
|
||||||
|
|
||||||
Different file types support different kinds of metadata. If you try to set
|
Different file types support different kinds of metadata. If you try to set
|
||||||
some metadata on a file type that does not support it, the metadata will be
|
some metadata on a file type that does not support it, the metadata will be
|
||||||
@ -99,7 +99,7 @@ def option_parser():
|
|||||||
for w in metadata_writers():
|
for w in metadata_writers():
|
||||||
writers = writers.union(set(w.file_types))
|
writers = writers.union(set(w.file_types))
|
||||||
ft, w = ', '.join(sorted(filetypes())), ', '.join(sorted(writers))
|
ft, w = ', '.join(sorted(filetypes())), ', '.join(sorted(writers))
|
||||||
return config().option_parser(USAGE%(ft, w))
|
return config().option_parser(USAGE%dict(read=ft, write=w))
|
||||||
|
|
||||||
def do_set_metadata(opts, mi, stream, stream_type):
|
def do_set_metadata(opts, mi, stream, stream_type):
|
||||||
mi = MetaInformation(mi)
|
mi = MetaInformation(mi)
|
||||||
|
@ -95,9 +95,9 @@ class CoverManager(object):
|
|||||||
authors = [unicode(x) for x in m.creator if x.role == 'aut']
|
authors = [unicode(x) for x in m.creator if x.role == 'aut']
|
||||||
series_string = None
|
series_string = None
|
||||||
if m.series and m.series_index:
|
if m.series and m.series_index:
|
||||||
series_string = _('Book %s of %s')%(
|
series_string = _('Book %(sidx)s of %(series)s')%dict(
|
||||||
fmt_sidx(m.series_index[0], use_roman=True),
|
sidx=fmt_sidx(m.series_index[0], use_roman=True),
|
||||||
unicode(m.series[0]))
|
series=unicode(m.series[0]))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from calibre.ebooks import calibre_cover
|
from calibre.ebooks import calibre_cover
|
||||||
|
@ -32,8 +32,8 @@ class SplitError(ValueError):
|
|||||||
size = len(tostring(root))/1024.
|
size = len(tostring(root))/1024.
|
||||||
ValueError.__init__(self,
|
ValueError.__init__(self,
|
||||||
_('Could not find reasonable point at which to split: '
|
_('Could not find reasonable point at which to split: '
|
||||||
'%s Sub-tree size: %d KB')%
|
'%(path)s Sub-tree size: %(size)d KB')%dict(
|
||||||
(path, size))
|
path=path, size=size))
|
||||||
|
|
||||||
class Split(object):
|
class Split(object):
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# coding:utf8
|
# coding:utf-8
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2010, Hiroshi Miura <miurahr@linux.com>'
|
__copyright__ = '2010, Hiroshi Miura <miurahr@linux.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -74,6 +74,13 @@ gprefs.defaults['action-layout-context-menu-device'] = (
|
|||||||
'Add To Library', 'Edit Collections',
|
'Add To Library', 'Edit Collections',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
gprefs.defaults['action-layout-context-menu-cover-browser'] = (
|
||||||
|
'Edit Metadata', 'Send To Device', 'Save To Disk',
|
||||||
|
'Connect Share', 'Copy To Library', None,
|
||||||
|
'Convert Books', 'View', 'Open Folder', 'Show Book Details',
|
||||||
|
'Similar Books', 'Tweak ePub', None, 'Remove Books',
|
||||||
|
)
|
||||||
|
|
||||||
gprefs.defaults['show_splash_screen'] = True
|
gprefs.defaults['show_splash_screen'] = True
|
||||||
gprefs.defaults['toolbar_icon_size'] = 'medium'
|
gprefs.defaults['toolbar_icon_size'] = 'medium'
|
||||||
gprefs.defaults['automerge'] = 'ignore'
|
gprefs.defaults['automerge'] = 'ignore'
|
||||||
|
@ -120,16 +120,16 @@ class FetchAnnotationsAction(InterfaceAction):
|
|||||||
spanTag['style'] = 'font-weight:bold'
|
spanTag['style'] = 'font-weight:bold'
|
||||||
if bookmark.book_format == 'pdf':
|
if bookmark.book_format == 'pdf':
|
||||||
spanTag.insert(0,NavigableString(
|
spanTag.insert(0,NavigableString(
|
||||||
_("%s<br />Last Page Read: %d (%d%%)") % \
|
_("%(time)s<br />Last Page Read: %(loc)d (%(pr)d%%)") % \
|
||||||
(strftime(u'%x', timestamp.timetuple()),
|
dict(time=strftime(u'%x', timestamp.timetuple()),
|
||||||
last_read_location,
|
loc=last_read_location,
|
||||||
percent_read)))
|
pr=percent_read)))
|
||||||
else:
|
else:
|
||||||
spanTag.insert(0,NavigableString(
|
spanTag.insert(0,NavigableString(
|
||||||
_("%s<br />Last Page Read: Location %d (%d%%)") % \
|
_("%(time)s<br />Last Page Read: Location %(loc)d (%(pr)d%%)") % \
|
||||||
(strftime(u'%x', timestamp.timetuple()),
|
dict(time=strftime(u'%x', timestamp.timetuple()),
|
||||||
last_read_location,
|
loc=last_read_location,
|
||||||
percent_read)))
|
pr=percent_read)))
|
||||||
|
|
||||||
divTag.insert(dtc, spanTag)
|
divTag.insert(dtc, spanTag)
|
||||||
dtc += 1
|
dtc += 1
|
||||||
@ -145,23 +145,23 @@ class FetchAnnotationsAction(InterfaceAction):
|
|||||||
for location in sorted(user_notes):
|
for location in sorted(user_notes):
|
||||||
if user_notes[location]['text']:
|
if user_notes[location]['text']:
|
||||||
annotations.append(
|
annotations.append(
|
||||||
_('<b>Location %d • %s</b><br />%s<br />') % \
|
_('<b>Location %(dl)d • %(typ)s</b><br />%(text)s<br />') % \
|
||||||
(user_notes[location]['displayed_location'],
|
dict(dl=user_notes[location]['displayed_location'],
|
||||||
user_notes[location]['type'],
|
typ=user_notes[location]['type'],
|
||||||
user_notes[location]['text'] if \
|
text=(user_notes[location]['text'] if \
|
||||||
user_notes[location]['type'] == 'Note' else \
|
user_notes[location]['type'] == 'Note' else \
|
||||||
'<i>%s</i>' % user_notes[location]['text']))
|
'<i>%s</i>' % user_notes[location]['text'])))
|
||||||
else:
|
else:
|
||||||
if bookmark.book_format == 'pdf':
|
if bookmark.book_format == 'pdf':
|
||||||
annotations.append(
|
annotations.append(
|
||||||
_('<b>Page %d • %s</b><br />') % \
|
_('<b>Page %(dl)d • %(typ)s</b><br />') % \
|
||||||
(user_notes[location]['displayed_location'],
|
dict(dl=user_notes[location]['displayed_location'],
|
||||||
user_notes[location]['type']))
|
typ=user_notes[location]['type']))
|
||||||
else:
|
else:
|
||||||
annotations.append(
|
annotations.append(
|
||||||
_('<b>Location %d • %s</b><br />') % \
|
_('<b>Location %(dl)d • %(typ)s</b><br />') % \
|
||||||
(user_notes[location]['displayed_location'],
|
dict(dl=user_notes[location]['displayed_location'],
|
||||||
user_notes[location]['type']))
|
typ=user_notes[location]['type']))
|
||||||
|
|
||||||
for annotation in annotations:
|
for annotation in annotations:
|
||||||
divTag.insert(dtc, annotation)
|
divTag.insert(dtc, annotation)
|
||||||
|
@ -82,7 +82,8 @@ class GenerateCatalogAction(InterfaceAction):
|
|||||||
self.gui.sync_catalogs()
|
self.gui.sync_catalogs()
|
||||||
if job.fmt not in ['EPUB','MOBI']:
|
if job.fmt not in ['EPUB','MOBI']:
|
||||||
export_dir = choose_dir(self.gui, _('Export Catalog Directory'),
|
export_dir = choose_dir(self.gui, _('Export Catalog Directory'),
|
||||||
_('Select destination for %s.%s') % (job.catalog_title, job.fmt.lower()))
|
_('Select destination for %(title)s.%(fmt)s') % dict(
|
||||||
|
title=job.catalog_title, fmt=job.fmt.lower()))
|
||||||
if export_dir:
|
if export_dir:
|
||||||
destination = os.path.join(export_dir, '%s.%s' % (job.catalog_title, job.fmt.lower()))
|
destination = os.path.join(export_dir, '%s.%s' % (job.catalog_title, job.fmt.lower()))
|
||||||
shutil.copyfile(job.catalog_file_path, destination)
|
shutil.copyfile(job.catalog_file_path, destination)
|
||||||
|
@ -160,8 +160,9 @@ class CopyToLibraryAction(InterfaceAction):
|
|||||||
error_dialog(self.gui, _('Failed'), _('Could not copy books: ') + e,
|
error_dialog(self.gui, _('Failed'), _('Could not copy books: ') + e,
|
||||||
det_msg=tb, show=True)
|
det_msg=tb, show=True)
|
||||||
else:
|
else:
|
||||||
self.gui.status_bar.show_message(_('Copied %d books to %s') %
|
self.gui.status_bar.show_message(
|
||||||
(len(ids), loc), 2000)
|
_('Copied %(num)d books to %(loc)s') %
|
||||||
|
dict(num=len(ids), loc=loc), 2000)
|
||||||
if delete_after and self.worker.processed:
|
if delete_after and self.worker.processed:
|
||||||
v = self.gui.library_view
|
v = self.gui.library_view
|
||||||
ci = v.currentIndex()
|
ci = v.currentIndex()
|
||||||
|
@ -159,9 +159,9 @@ def render_data(mi, use_roman_numbers=True, all_fields=False):
|
|||||||
sidx = mi.get(field+'_index')
|
sidx = mi.get(field+'_index')
|
||||||
if sidx is None:
|
if sidx is None:
|
||||||
sidx = 1.0
|
sidx = 1.0
|
||||||
val = _('Book %s of <span class="series_name">%s</span>')%(fmt_sidx(sidx,
|
val = _('Book %(sidx)s of <span class="series_name">%(series)s</span>')%dict(
|
||||||
use_roman=use_roman_numbers),
|
sidx=fmt_sidx(sidx, use_roman=use_roman_numbers),
|
||||||
prepare_string_for_xml(getattr(mi, field)))
|
series=prepare_string_for_xml(getattr(mi, field)))
|
||||||
|
|
||||||
ans.append((field, u'<td class="title">%s</td><td>%s</td>'%(name, val)))
|
ans.append((field, u'<td class="title">%s</td><td>%s</td>'%(name, val)))
|
||||||
|
|
||||||
@ -541,7 +541,8 @@ class BookDetails(QWidget): # {{{
|
|||||||
self.setToolTip(
|
self.setToolTip(
|
||||||
'<p>'+_('Double-click to open Book Details window') +
|
'<p>'+_('Double-click to open Book Details window') +
|
||||||
'<br><br>' + _('Path') + ': ' + self.current_path +
|
'<br><br>' + _('Path') + ': ' + self.current_path +
|
||||||
'<br><br>' + _('Cover size: %dx%d')%(sz.width(), sz.height())
|
'<br><br>' + _('Cover size: %(width)d x %(height)d')%dict(
|
||||||
|
width=sz.width(), height=sz.height())
|
||||||
)
|
)
|
||||||
|
|
||||||
def reset_info(self):
|
def reset_info(self):
|
||||||
|
@ -9,8 +9,8 @@ Module to implement the Cover Flow feature
|
|||||||
|
|
||||||
import sys, os, time
|
import sys, os, time
|
||||||
|
|
||||||
from PyQt4.Qt import QImage, QSizePolicy, QTimer, QDialog, Qt, QSize, \
|
from PyQt4.Qt import (QImage, QSizePolicy, QTimer, QDialog, Qt, QSize,
|
||||||
QStackedLayout, QLabel, QByteArray, pyqtSignal
|
QStackedLayout, QLabel, QByteArray, pyqtSignal)
|
||||||
|
|
||||||
from calibre import plugins
|
from calibre import plugins
|
||||||
from calibre.gui2 import config, available_height, available_width, gprefs
|
from calibre.gui2 import config, available_height, available_width, gprefs
|
||||||
@ -84,6 +84,7 @@ if pictureflow is not None:
|
|||||||
class CoverFlow(pictureflow.PictureFlow):
|
class CoverFlow(pictureflow.PictureFlow):
|
||||||
|
|
||||||
dc_signal = pyqtSignal()
|
dc_signal = pyqtSignal()
|
||||||
|
context_menu_requested = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
pictureflow.PictureFlow.__init__(self, parent,
|
pictureflow.PictureFlow.__init__(self, parent,
|
||||||
@ -94,6 +95,17 @@ if pictureflow is not None:
|
|||||||
QSizePolicy.Expanding))
|
QSizePolicy.Expanding))
|
||||||
self.dc_signal.connect(self._data_changed,
|
self.dc_signal.connect(self._data_changed,
|
||||||
type=Qt.QueuedConnection)
|
type=Qt.QueuedConnection)
|
||||||
|
self.context_menu = None
|
||||||
|
self.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||||
|
|
||||||
|
def set_context_menu(self, cm):
|
||||||
|
self.context_menu = cm
|
||||||
|
|
||||||
|
def contextMenuEvent(self, event):
|
||||||
|
if self.context_menu is not None:
|
||||||
|
self.context_menu_requested.emit()
|
||||||
|
self.context_menu.popup(event.globalPos())
|
||||||
|
event.accept()
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
return self.minimumSize()
|
return self.minimumSize()
|
||||||
@ -149,6 +161,7 @@ class CoverFlowMixin(object):
|
|||||||
self.cover_flow_sync_flag = True
|
self.cover_flow_sync_flag = True
|
||||||
self.cover_flow = CoverFlow(parent=self)
|
self.cover_flow = CoverFlow(parent=self)
|
||||||
self.cover_flow.currentChanged.connect(self.sync_listview_to_cf)
|
self.cover_flow.currentChanged.connect(self.sync_listview_to_cf)
|
||||||
|
self.cover_flow.context_menu_requested.connect(self.cf_context_menu_requested)
|
||||||
self.library_view.selectionModel().currentRowChanged.connect(
|
self.library_view.selectionModel().currentRowChanged.connect(
|
||||||
self.sync_cf_to_listview)
|
self.sync_cf_to_listview)
|
||||||
self.db_images = DatabaseImages(self.library_view.model())
|
self.db_images = DatabaseImages(self.library_view.model())
|
||||||
@ -234,6 +247,14 @@ class CoverFlowMixin(object):
|
|||||||
self.cover_flow.setCurrentSlide(current.row())
|
self.cover_flow.setCurrentSlide(current.row())
|
||||||
self.cover_flow_sync_flag = True
|
self.cover_flow_sync_flag = True
|
||||||
|
|
||||||
|
def cf_context_menu_requested(self):
|
||||||
|
row = self.cover_flow.currentSlide()
|
||||||
|
m = self.library_view.model()
|
||||||
|
index = m.index(row, 0)
|
||||||
|
sm = self.library_view.selectionModel()
|
||||||
|
sm.select(index, sm.ClearAndSelect|sm.Rows)
|
||||||
|
self.library_view.setCurrentIndex(index)
|
||||||
|
|
||||||
def cover_flow_do_sync(self):
|
def cover_flow_do_sync(self):
|
||||||
self.cover_flow_sync_flag = True
|
self.cover_flow_sync_flag = True
|
||||||
try:
|
try:
|
||||||
|
@ -912,8 +912,9 @@ class DeviceMixin(object): # {{{
|
|||||||
format_count[f] = 1
|
format_count[f] = 1
|
||||||
for f in self.device_manager.device.settings().format_map:
|
for f in self.device_manager.device.settings().format_map:
|
||||||
if f in format_count.keys():
|
if f in format_count.keys():
|
||||||
formats.append((f, _('%i of %i Books') % (format_count[f],
|
formats.append((f, _('%(num)i of %(total)i Books') % dict(
|
||||||
len(rows)), True if f in aval_out_formats else False))
|
num=format_count[f], total=len(rows)),
|
||||||
|
True if f in aval_out_formats else False))
|
||||||
elif f in aval_out_formats:
|
elif f in aval_out_formats:
|
||||||
formats.append((f, _('0 of %i Books') % len(rows), True))
|
formats.append((f, _('0 of %i Books') % len(rows), True))
|
||||||
d = ChooseFormatDeviceDialog(self, _('Choose format to send to device'), formats)
|
d = ChooseFormatDeviceDialog(self, _('Choose format to send to device'), formats)
|
||||||
|
@ -106,7 +106,8 @@ class BookInfo(QDialog, Ui_BookInfo):
|
|||||||
Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||||
self.cover.set_pixmap(pixmap)
|
self.cover.set_pixmap(pixmap)
|
||||||
sz = pixmap.size()
|
sz = pixmap.size()
|
||||||
self.cover.setToolTip(_('Cover size: %dx%d')%(sz.width(), sz.height()))
|
self.cover.setToolTip(_('Cover size: %(width)d x %(height)d')%dict(
|
||||||
|
width=sz.width(), height=sz.height()))
|
||||||
|
|
||||||
def refresh(self, row):
|
def refresh(self, row):
|
||||||
if isinstance(row, QModelIndex):
|
if isinstance(row, QModelIndex):
|
||||||
|
@ -173,10 +173,10 @@ class MyBlockingBusy(QDialog): # {{{
|
|||||||
mi = self.db.get_metadata(id, index_is_id=True)
|
mi = self.db.get_metadata(id, index_is_id=True)
|
||||||
series_string = None
|
series_string = None
|
||||||
if mi.series:
|
if mi.series:
|
||||||
series_string = _('Book %s of %s')%(
|
series_string = _('Book %(sidx)s of %(series)s')%dict(
|
||||||
fmt_sidx(mi.series_index,
|
sidx=fmt_sidx(mi.series_index,
|
||||||
use_roman=config['use_roman_numerals_for_series_number']),
|
use_roman=config['use_roman_numerals_for_series_number']),
|
||||||
mi.series)
|
series=mi.series)
|
||||||
|
|
||||||
cdata = calibre_cover(mi.title, mi.format_field('authors')[-1],
|
cdata = calibre_cover(mi.title, mi.format_field('authors')[-1],
|
||||||
series_string=series_string)
|
series_string=series_string)
|
||||||
|
@ -701,7 +701,9 @@ class PluginUpdaterDialog(SizePersistedDialog):
|
|||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
prints('Locating zip file for %s: %s'% (display_plugin.name, display_plugin.forum_link))
|
prints('Locating zip file for %s: %s'% (display_plugin.name, display_plugin.forum_link))
|
||||||
self.gui.status_bar.showMessage(_('Locating zip file for %s: %s') % (display_plugin.name, display_plugin.forum_link))
|
self.gui.status_bar.showMessage(
|
||||||
|
_('Locating zip file for %(name)s: %(link)s') % dict(
|
||||||
|
name=display_plugin.name, link=display_plugin.forum_link))
|
||||||
plugin_zip_url = self._read_zip_attachment_url(display_plugin.forum_link)
|
plugin_zip_url = self._read_zip_attachment_url(display_plugin.forum_link)
|
||||||
if not plugin_zip_url:
|
if not plugin_zip_url:
|
||||||
return error_dialog(self.gui, _('Install Plugin Failed'),
|
return error_dialog(self.gui, _('Install Plugin Failed'),
|
||||||
|
@ -381,7 +381,9 @@ class SchedulerDialog(QDialog, Ui_Dialog):
|
|||||||
d = utcnow() - last_downloaded
|
d = utcnow() - last_downloaded
|
||||||
def hm(x): return (x-x%3600)//3600, (x%3600 - (x%3600)%60)//60
|
def hm(x): return (x-x%3600)//3600, (x%3600 - (x%3600)%60)//60
|
||||||
hours, minutes = hm(d.seconds)
|
hours, minutes = hm(d.seconds)
|
||||||
tm = _('%d days, %d hours and %d minutes ago')%(d.days, hours, minutes)
|
tm = _('%(days)d days, %(hours)d hours'
|
||||||
|
' and %(mins)d minutes ago')%dict(
|
||||||
|
days=d.days, hours=hours, mins=minutes)
|
||||||
if d < timedelta(days=366):
|
if d < timedelta(days=366):
|
||||||
ld_text = tm
|
ld_text = tm
|
||||||
else:
|
else:
|
||||||
|
@ -57,7 +57,7 @@ class TagCategories(QDialog, Ui_TagCategories):
|
|||||||
lambda: [n for (id, n) in self.db.all_publishers()],
|
lambda: [n for (id, n) in self.db.all_publishers()],
|
||||||
lambda: self.db.all_tags()
|
lambda: self.db.all_tags()
|
||||||
]
|
]
|
||||||
category_names = ['', _('Authors'), _('Series'), _('Publishers'), _('Tags')]
|
category_names = ['', _('Authors'), ngettext('Series', 'Series', 2), _('Publishers'), _('Tags')]
|
||||||
|
|
||||||
cvals = {}
|
cvals = {}
|
||||||
for key,cc in self.db.custom_field_metadata().iteritems():
|
for key,cc in self.db.custom_field_metadata().iteritems():
|
||||||
@ -284,4 +284,4 @@ class TagCategories(QDialog, Ui_TagCategories):
|
|||||||
self.category_box.blockSignals(True)
|
self.category_box.blockSignals(True)
|
||||||
self.category_box.clear()
|
self.category_box.clear()
|
||||||
self.category_box.addItems(sorted(self.categories.keys(), key=sort_key))
|
self.category_box.addItems(sorted(self.categories.keys(), key=sort_key))
|
||||||
self.category_box.blockSignals(False)
|
self.category_box.blockSignals(False)
|
||||||
|
@ -18,7 +18,8 @@ class ListWidgetItem(QListWidgetItem):
|
|||||||
def data(self, role):
|
def data(self, role):
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
if self.initial_value != self.current_value:
|
if self.initial_value != self.current_value:
|
||||||
return _('%s (was %s)')%(self.current_value, self.initial_value)
|
return _('%(curr)s (was %(initial)s)')%dict(
|
||||||
|
curr=self.current_value, initial=self.initial_value)
|
||||||
else:
|
else:
|
||||||
return self.current_value
|
return self.current_value
|
||||||
elif role == Qt.EditRole:
|
elif role == Qt.EditRole:
|
||||||
|
@ -143,7 +143,9 @@ class UserProfiles(ResizableDialog, Ui_Dialog):
|
|||||||
pt = PersistentTemporaryFile(suffix='.recipe')
|
pt = PersistentTemporaryFile(suffix='.recipe')
|
||||||
pt.write(src.encode('utf-8'))
|
pt.write(src.encode('utf-8'))
|
||||||
pt.close()
|
pt.close()
|
||||||
body = _('The attached file: %s is a recipe to download %s.')%(os.path.basename(pt.name), title)
|
body = _('The attached file: %(fname)s is a '
|
||||||
|
'recipe to download %(title)s.')%dict(
|
||||||
|
fname=os.path.basename(pt.name), title=title)
|
||||||
subject = _('Recipe for ')+title
|
subject = _('Recipe for ')+title
|
||||||
url = QUrl('mailto:')
|
url = QUrl('mailto:')
|
||||||
url.addQueryItem('subject', subject)
|
url.addQueryItem('subject', subject)
|
||||||
|
@ -51,8 +51,8 @@ class DownloadDialog(QDialog): # {{{
|
|||||||
self.setWindowTitle(_('Download %s')%fname)
|
self.setWindowTitle(_('Download %s')%fname)
|
||||||
self.l = QVBoxLayout(self)
|
self.l = QVBoxLayout(self)
|
||||||
self.purl = urlparse(url)
|
self.purl = urlparse(url)
|
||||||
self.msg = QLabel(_('Downloading <b>%s</b> from %s')%(fname,
|
self.msg = QLabel(_('Downloading <b>%(fname)s</b> from %(url)s')%dict(
|
||||||
self.purl.netloc))
|
fname=fname, url=self.purl.netloc))
|
||||||
self.msg.setWordWrap(True)
|
self.msg.setWordWrap(True)
|
||||||
self.l.addWidget(self.msg)
|
self.l.addWidget(self.msg)
|
||||||
self.pb = QProgressBar(self)
|
self.pb = QProgressBar(self)
|
||||||
@ -82,9 +82,9 @@ class DownloadDialog(QDialog): # {{{
|
|||||||
self.exec_()
|
self.exec_()
|
||||||
if self.worker.err is not None:
|
if self.worker.err is not None:
|
||||||
error_dialog(self.parent(), _('Download failed'),
|
error_dialog(self.parent(), _('Download failed'),
|
||||||
_('Failed to download from %r with error: %s')%(
|
_('Failed to download from %(url)r with error: %(err)s')%dict(
|
||||||
self.worker.url, self.worker.err),
|
url=self.worker.url, err=self.worker.err),
|
||||||
det_msg=self.worker.tb, show=True)
|
det_msg=self.worker.tb, show=True)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.rejected:
|
if self.rejected:
|
||||||
|
@ -120,7 +120,7 @@ def send_mails(jobnames, callback, attachments, to_s, subjects,
|
|||||||
texts, attachment_names, job_manager):
|
texts, attachment_names, job_manager):
|
||||||
for name, attachment, to, subject, text, aname in zip(jobnames,
|
for name, attachment, to, subject, text, aname in zip(jobnames,
|
||||||
attachments, to_s, subjects, texts, attachment_names):
|
attachments, to_s, subjects, texts, attachment_names):
|
||||||
description = _('Email %s to %s') % (name, to)
|
description = _('Email %(name)s to %(to)s') % dict(name=name, to=to)
|
||||||
job = ThreadedJob('email', description, gui_sendmail, (attachment, aname, to,
|
job = ThreadedJob('email', description, gui_sendmail, (attachment, aname, to,
|
||||||
subject, text), {}, callback)
|
subject, text), {}, callback)
|
||||||
job_manager.run_threaded_job(job)
|
job_manager.run_threaded_job(job)
|
||||||
|
@ -62,7 +62,6 @@ class LibraryViewMixin(object): # {{{
|
|||||||
view = getattr(self, view+'_view')
|
view = getattr(self, view+'_view')
|
||||||
view.verticalHeader().sectionDoubleClicked.connect(self.iactions['View'].view_specific_book)
|
view.verticalHeader().sectionDoubleClicked.connect(self.iactions['View'].view_specific_book)
|
||||||
|
|
||||||
self.build_context_menus()
|
|
||||||
self.library_view.model().set_highlight_only(config['highlight_search_matches'])
|
self.library_view.model().set_highlight_only(config['highlight_search_matches'])
|
||||||
|
|
||||||
def build_context_menus(self):
|
def build_context_menus(self):
|
||||||
@ -81,6 +80,11 @@ class LibraryViewMixin(object): # {{{
|
|||||||
for v in (self.memory_view, self.card_a_view, self.card_b_view):
|
for v in (self.memory_view, self.card_a_view, self.card_b_view):
|
||||||
v.set_context_menu(dm, ec)
|
v.set_context_menu(dm, ec)
|
||||||
|
|
||||||
|
if self.cover_flow is not None:
|
||||||
|
cm = QMenu(self.cover_flow)
|
||||||
|
populate_menu(cm,
|
||||||
|
gprefs['action-layout-context-menu-cover-browser'])
|
||||||
|
self.cover_flow.set_context_menu(cm)
|
||||||
|
|
||||||
def search_done(self, view, ok):
|
def search_done(self, view, ok):
|
||||||
if view is self.current_view():
|
if view is self.current_view():
|
||||||
|
@ -878,9 +878,10 @@ class Cover(ImageView): # {{{
|
|||||||
series = self.dialog.series.current_val
|
series = self.dialog.series.current_val
|
||||||
series_string = None
|
series_string = None
|
||||||
if series:
|
if series:
|
||||||
series_string = _('Book %s of %s')%(
|
series_string = _('Book %(sidx)s of %(series)s')%dict(
|
||||||
fmt_sidx(self.dialog.series_index.current_val,
|
sidx=fmt_sidx(self.dialog.series_index.current_val,
|
||||||
use_roman=config['use_roman_numerals_for_series_number']), series)
|
use_roman=config['use_roman_numerals_for_series_number']),
|
||||||
|
series=series)
|
||||||
self.current_val = calibre_cover(title, author,
|
self.current_val = calibre_cover(title, author,
|
||||||
series_string=series_string)
|
series_string=series_string)
|
||||||
|
|
||||||
@ -921,8 +922,8 @@ class Cover(ImageView): # {{{
|
|||||||
self.setPixmap(pm)
|
self.setPixmap(pm)
|
||||||
tt = _('This book has no cover')
|
tt = _('This book has no cover')
|
||||||
if self._cdata:
|
if self._cdata:
|
||||||
tt = _('Cover size: %dx%d pixels') % \
|
tt = _('Cover size: %(width)d x %(height)d pixels') % \
|
||||||
(pm.width(), pm.height())
|
dict(width=pm.width(), height=pm.height())
|
||||||
self.setToolTip(tt)
|
self.setToolTip(tt)
|
||||||
|
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
|
@ -196,7 +196,7 @@ def download(ids, db, do_identify, covers,
|
|||||||
ans[i] = mi
|
ans[i] = mi
|
||||||
count += 1
|
count += 1
|
||||||
notifications.put((count/len(ids),
|
notifications.put((count/len(ids),
|
||||||
_('Downloaded %d of %d')%(count, len(ids))))
|
_('Downloaded %(num)d of %(tot)d')%dict(num=count, tot=len(ids))))
|
||||||
log('Download complete, with %d failures'%len(failed_ids))
|
log('Download complete, with %d failures'%len(failed_ids))
|
||||||
return (ans, failed_ids, failed_covers, title_map, all_failed)
|
return (ans, failed_ids, failed_covers, title_map, all_failed)
|
||||||
|
|
||||||
|
@ -726,8 +726,8 @@ class CoversWidget(QWidget): # {{{
|
|||||||
if num < 2:
|
if num < 2:
|
||||||
txt = _('Could not find any covers for <b>%s</b>')%self.book.title
|
txt = _('Could not find any covers for <b>%s</b>')%self.book.title
|
||||||
else:
|
else:
|
||||||
txt = _('Found <b>%d</b> covers of %s. Pick the one you like'
|
txt = _('Found <b>%(num)d</b> covers of %(title)s. Pick the one you like'
|
||||||
' best.')%(num-1, self.title)
|
' best.')%dict(num=num-1, title=self.title)
|
||||||
self.msg.setText(txt)
|
self.msg.setText(txt)
|
||||||
|
|
||||||
self.finished.emit()
|
self.finished.emit()
|
||||||
|
@ -1332,6 +1332,7 @@ void PictureFlow::mousePressEvent(QMouseEvent* event)
|
|||||||
|
|
||||||
void PictureFlow::mouseReleaseEvent(QMouseEvent* event)
|
void PictureFlow::mouseReleaseEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
|
bool accepted = false;
|
||||||
int sideWidth = (d->buffer.width() - slideSize().width()) /2;
|
int sideWidth = (d->buffer.width() - slideSize().width()) /2;
|
||||||
|
|
||||||
if (d->singlePress)
|
if (d->singlePress)
|
||||||
@ -1339,13 +1340,20 @@ void PictureFlow::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
if (event->x() < sideWidth )
|
if (event->x() < sideWidth )
|
||||||
{
|
{
|
||||||
showPrevious();
|
showPrevious();
|
||||||
|
accepted = true;
|
||||||
} else if ( event->x() > sideWidth + slideSize().width() ) {
|
} else if ( event->x() > sideWidth + slideSize().width() ) {
|
||||||
showNext();
|
showNext();
|
||||||
|
accepted = true;
|
||||||
} else {
|
} else {
|
||||||
emit itemActivated(d->getTarget());
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
emit itemActivated(d->getTarget());
|
||||||
|
accepted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event->accept();
|
if (accepted) {
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit inputReceived();
|
emit inputReceived();
|
||||||
|
@ -445,15 +445,15 @@ class RulesModel(QAbstractListModel): # {{{
|
|||||||
def rule_to_html(self, col, rule):
|
def rule_to_html(self, col, rule):
|
||||||
if not isinstance(rule, Rule):
|
if not isinstance(rule, Rule):
|
||||||
return _('''
|
return _('''
|
||||||
<p>Advanced Rule for column <b>%s</b>:
|
<p>Advanced Rule for column <b>%(col)s</b>:
|
||||||
<pre>%s</pre>
|
<pre>%(rule)s</pre>
|
||||||
''')%(col, prepare_string_for_xml(rule))
|
''')%dict(col=col, rule=prepare_string_for_xml(rule))
|
||||||
conditions = [self.condition_to_html(c) for c in rule.conditions]
|
conditions = [self.condition_to_html(c) for c in rule.conditions]
|
||||||
return _('''\
|
return _('''\
|
||||||
<p>Set the color of <b>%s</b> to <b>%s</b> if the following
|
<p>Set the color of <b>%(col)s</b> to <b>%(color)s</b> if the following
|
||||||
conditions are met:</p>
|
conditions are met:</p>
|
||||||
<ul>%s</ul>
|
<ul>%(rule)s</ul>
|
||||||
''') % (col, rule.color, ''.join(conditions))
|
''') % dict(col=col, color=rule.color, rule=''.join(conditions))
|
||||||
|
|
||||||
def condition_to_html(self, condition):
|
def condition_to_html(self, condition):
|
||||||
c, a, v = condition
|
c, a, v = condition
|
||||||
@ -464,8 +464,8 @@ class RulesModel(QAbstractListModel): # {{{
|
|||||||
action_name = trans
|
action_name = trans
|
||||||
|
|
||||||
return (
|
return (
|
||||||
_('<li>If the <b>%s</b> column <b>%s</b> value: <b>%s</b>') %
|
_('<li>If the <b>%(col)s</b> column <b>%(action)s</b> value: <b>%(val)s</b>') %
|
||||||
(c, action_name, prepare_string_for_xml(v)))
|
dict(col=c, action=action_name, val=prepare_string_for_xml(v)))
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -262,8 +262,8 @@ class PluginConfig(QWidget): # {{{
|
|||||||
|
|
||||||
self.l = l = QVBoxLayout()
|
self.l = l = QVBoxLayout()
|
||||||
self.setLayout(l)
|
self.setLayout(l)
|
||||||
self.c = c = QLabel(_('<b>Configure %s</b><br>%s') % (plugin.name,
|
self.c = c = QLabel(_('<b>Configure %(name)s</b><br>%(desc)s') % dict(
|
||||||
plugin.description))
|
name=plugin.name, desc=plugin.description))
|
||||||
c.setAlignment(Qt.AlignHCenter)
|
c.setAlignment(Qt.AlignHCenter)
|
||||||
l.addWidget(c)
|
l.addWidget(c)
|
||||||
|
|
||||||
|
@ -225,6 +225,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
'calibre library')),
|
'calibre library')),
|
||||||
('context-menu-device', _('The context menu for the books on '
|
('context-menu-device', _('The context menu for the books on '
|
||||||
'the device')),
|
'the device')),
|
||||||
|
('context-menu-cover-browser', _('The context menu for the cover '
|
||||||
|
'browser')),
|
||||||
]
|
]
|
||||||
|
|
||||||
def genesis(self, gui):
|
def genesis(self, gui):
|
||||||
|
@ -18,11 +18,11 @@ from calibre import browser
|
|||||||
from calibre.gui2.store.search_result import SearchResult
|
from calibre.gui2.store.search_result import SearchResult
|
||||||
|
|
||||||
class CacheUpdateThread(Thread, QObject):
|
class CacheUpdateThread(Thread, QObject):
|
||||||
|
|
||||||
total_changed = pyqtSignal(int)
|
total_changed = pyqtSignal(int)
|
||||||
update_progress = pyqtSignal(int)
|
update_progress = pyqtSignal(int)
|
||||||
update_details = pyqtSignal(unicode)
|
update_details = pyqtSignal(unicode)
|
||||||
|
|
||||||
def __init__(self, config, seralize_books_function, timeout):
|
def __init__(self, config, seralize_books_function, timeout):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
QObject.__init__(self)
|
QObject.__init__(self)
|
||||||
@ -32,19 +32,19 @@ class CacheUpdateThread(Thread, QObject):
|
|||||||
self.seralize_books = seralize_books_function
|
self.seralize_books = seralize_books_function
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self._run = True
|
self._run = True
|
||||||
|
|
||||||
def abort(self):
|
def abort(self):
|
||||||
self._run = False
|
self._run = False
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
url = 'http://www.mobileread.com/forums/ebooks.php?do=getlist&type=html'
|
url = 'http://www.mobileread.com/forums/ebooks.php?do=getlist&type=html'
|
||||||
|
|
||||||
self.update_details.emit(_('Checking last download date.'))
|
self.update_details.emit(_('Checking last download date.'))
|
||||||
last_download = self.config.get('last_download', None)
|
last_download = self.config.get('last_download', None)
|
||||||
# Don't update the book list if our cache is less than one week old.
|
# Don't update the book list if our cache is less than one week old.
|
||||||
if last_download and (time.time() - last_download) < 604800:
|
if last_download and (time.time() - last_download) < 604800:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.update_details.emit(_('Downloading book list from MobileRead.'))
|
self.update_details.emit(_('Downloading book list from MobileRead.'))
|
||||||
# Download the book list HTML file from MobileRead.
|
# Download the book list HTML file from MobileRead.
|
||||||
br = browser()
|
br = browser()
|
||||||
@ -54,10 +54,10 @@ class CacheUpdateThread(Thread, QObject):
|
|||||||
raw_data = f.read()
|
raw_data = f.read()
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not raw_data or not self._run:
|
if not raw_data or not self._run:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.update_details.emit(_('Processing books.'))
|
self.update_details.emit(_('Processing books.'))
|
||||||
# Turn books listed in the HTML file into SearchResults's.
|
# Turn books listed in the HTML file into SearchResults's.
|
||||||
books = []
|
books = []
|
||||||
@ -65,21 +65,23 @@ class CacheUpdateThread(Thread, QObject):
|
|||||||
data = html.fromstring(raw_data)
|
data = html.fromstring(raw_data)
|
||||||
raw_books = data.xpath('//ul/li')
|
raw_books = data.xpath('//ul/li')
|
||||||
self.total_changed.emit(len(raw_books))
|
self.total_changed.emit(len(raw_books))
|
||||||
|
|
||||||
for i, book_data in enumerate(raw_books):
|
for i, book_data in enumerate(raw_books):
|
||||||
self.update_details.emit(_('%s of %s books processed.') % (i, len(raw_books)))
|
self.update_details.emit(
|
||||||
|
_('%(num)s of %(tot)s books processed.') % dict(
|
||||||
|
num=i, tot=len(raw_books)))
|
||||||
book = SearchResult()
|
book = SearchResult()
|
||||||
book.detail_item = ''.join(book_data.xpath('.//a/@href'))
|
book.detail_item = ''.join(book_data.xpath('.//a/@href'))
|
||||||
book.formats = ''.join(book_data.xpath('.//i/text()'))
|
book.formats = ''.join(book_data.xpath('.//i/text()'))
|
||||||
book.formats = book.formats.strip()
|
book.formats = book.formats.strip()
|
||||||
|
|
||||||
text = ''.join(book_data.xpath('.//a/text()'))
|
text = ''.join(book_data.xpath('.//a/text()'))
|
||||||
if ':' in text:
|
if ':' in text:
|
||||||
book.author, q, text = text.partition(':')
|
book.author, q, text = text.partition(':')
|
||||||
book.author = book.author.strip()
|
book.author = book.author.strip()
|
||||||
book.title = text.strip()
|
book.title = text.strip()
|
||||||
books.append(book)
|
books.append(book)
|
||||||
|
|
||||||
if not self._run:
|
if not self._run:
|
||||||
books = []
|
books = []
|
||||||
break
|
break
|
||||||
|
@ -384,8 +384,8 @@ class TagsView(QTreeView): # {{{
|
|||||||
action='delete_search', key=tag.name))
|
action='delete_search', key=tag.name))
|
||||||
if key.startswith('@') and not item.is_gst:
|
if key.startswith('@') and not item.is_gst:
|
||||||
self.context_menu.addAction(self.user_category_icon,
|
self.context_menu.addAction(self.user_category_icon,
|
||||||
_('Remove %s from category %s')%
|
_('Remove %(item)s from category %(cat)s')%
|
||||||
(display_name(tag), item.py_name),
|
dict(item=display_name(tag), cat=item.py_name),
|
||||||
partial(self.context_menu_handler,
|
partial(self.context_menu_handler,
|
||||||
action='delete_item_from_user_category',
|
action='delete_item_from_user_category',
|
||||||
key = key, index = tag_item))
|
key = key, index = tag_item))
|
||||||
|
@ -94,8 +94,8 @@ def convert_single_ebook(parent, db, book_ids, auto_conversion=False, # {{{
|
|||||||
|
|
||||||
msg = '%s' % '\n'.join(res)
|
msg = '%s' % '\n'.join(res)
|
||||||
warning_dialog(parent, _('Could not convert some books'),
|
warning_dialog(parent, _('Could not convert some books'),
|
||||||
_('Could not convert %d of %d books, because no suitable source'
|
_('Could not convert %(num)d of %(tot)d books, because no suitable source'
|
||||||
' format was found.') % (len(res), total),
|
' format was found.') % dict(num=len(res), tot=total),
|
||||||
msg).exec_()
|
msg).exec_()
|
||||||
|
|
||||||
return jobs, changed, bad
|
return jobs, changed, bad
|
||||||
@ -187,7 +187,8 @@ class QueueBulk(QProgressDialog):
|
|||||||
except:
|
except:
|
||||||
dtitle = repr(mi.title)
|
dtitle = repr(mi.title)
|
||||||
self.setLabelText(_('Queueing ')+dtitle)
|
self.setLabelText(_('Queueing ')+dtitle)
|
||||||
desc = _('Convert book %d of %d (%s)') % (self.i, len(self.book_ids), dtitle)
|
desc = _('Convert book %(num)d of %(tot)d (%(title)s)') % dict(
|
||||||
|
num=self.i, tot=len(self.book_ids), title=dtitle)
|
||||||
|
|
||||||
args = [in_file.name, out_file.name, lrecs]
|
args = [in_file.name, out_file.name, lrecs]
|
||||||
temp_files.append(out_file)
|
temp_files.append(out_file)
|
||||||
@ -209,8 +210,8 @@ class QueueBulk(QProgressDialog):
|
|||||||
|
|
||||||
msg = '%s' % '\n'.join(res)
|
msg = '%s' % '\n'.join(res)
|
||||||
warning_dialog(self.parent, _('Could not convert some books'),
|
warning_dialog(self.parent, _('Could not convert some books'),
|
||||||
_('Could not convert %d of %d books, because no suitable '
|
_('Could not convert %(num)d of %(tot)d books, because no suitable '
|
||||||
'source format was found.') % (len(res), len(self.book_ids)),
|
'source format was found.') % dict(num=len(res), tot=len(self.book_ids)),
|
||||||
msg).exec_()
|
msg).exec_()
|
||||||
self.parent = None
|
self.parent = None
|
||||||
self.jobs.reverse()
|
self.jobs.reverse()
|
||||||
|
@ -308,6 +308,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
self.height())
|
self.height())
|
||||||
self.resize(self.width(), self._calculated_available_height)
|
self.resize(self.width(), self._calculated_available_height)
|
||||||
|
|
||||||
|
self.build_context_menus()
|
||||||
|
|
||||||
for ac in self.iactions.values():
|
for ac in self.iactions.values():
|
||||||
try:
|
try:
|
||||||
ac.gui_layout_complete()
|
ac.gui_layout_complete()
|
||||||
|
@ -70,10 +70,10 @@ class UpdateNotification(QDialog):
|
|||||||
self.logo.setPixmap(QPixmap(I('lt.png')).scaled(100, 100,
|
self.logo.setPixmap(QPixmap(I('lt.png')).scaled(100, 100,
|
||||||
Qt.IgnoreAspectRatio, Qt.SmoothTransformation))
|
Qt.IgnoreAspectRatio, Qt.SmoothTransformation))
|
||||||
self.label = QLabel(('<p>'+
|
self.label = QLabel(('<p>'+
|
||||||
_('%s has been updated to version <b>%s</b>. '
|
_('%(app)s has been updated to version <b>%(ver)s</b>. '
|
||||||
'See the <a href="http://calibre-ebook.com/whats-new'
|
'See the <a href="http://calibre-ebook.com/whats-new'
|
||||||
'">new features</a>.'))%(
|
'">new features</a>.'))%dict(
|
||||||
__appname__, calibre_version))
|
app=__appname__, ver=calibre_version))
|
||||||
self.label.setOpenExternalLinks(True)
|
self.label.setOpenExternalLinks(True)
|
||||||
self.label.setWordWrap(True)
|
self.label.setWordWrap(True)
|
||||||
self.setWindowTitle(_('Update available!'))
|
self.setWindowTitle(_('Update available!'))
|
||||||
|
@ -492,11 +492,11 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
|||||||
self.set_page_number(frac)
|
self.set_page_number(frac)
|
||||||
|
|
||||||
def magnification_changed(self, val):
|
def magnification_changed(self, val):
|
||||||
tt = _('Make font size %s\nCurrent magnification: %.1f')
|
tt = _('Make font size %(which)s\nCurrent magnification: %(mag).1f')
|
||||||
self.action_font_size_larger.setToolTip(
|
self.action_font_size_larger.setToolTip(
|
||||||
tt %(_('larger'), val))
|
tt %dict(which=_('larger'), mag=val))
|
||||||
self.action_font_size_smaller.setToolTip(
|
self.action_font_size_smaller.setToolTip(
|
||||||
tt %(_('smaller'), val))
|
tt %dict(which=_('smaller'), mag=val))
|
||||||
|
|
||||||
def find(self, text, repeat=False, backwards=False):
|
def find(self, text, repeat=False, backwards=False):
|
||||||
if not text:
|
if not text:
|
||||||
|
@ -569,9 +569,9 @@ def move_library(oldloc, newloc, parent, callback_on_complete):
|
|||||||
det = traceback.format_exc()
|
det = traceback.format_exc()
|
||||||
error_dialog(parent, _('Invalid database'),
|
error_dialog(parent, _('Invalid database'),
|
||||||
_('<p>An invalid library already exists at '
|
_('<p>An invalid library already exists at '
|
||||||
'%s, delete it before trying to move the '
|
'%(loc)s, delete it before trying to move the '
|
||||||
'existing library.<br>Error: %s')%(newloc,
|
'existing library.<br>Error: %(err)s')%dict(loc=newloc,
|
||||||
str(err)), det, show=True)
|
err=str(err)), det, show=True)
|
||||||
callback(None)
|
callback(None)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -31,9 +31,9 @@ class TestEmail(QDialog, TE_Dialog):
|
|||||||
if pa:
|
if pa:
|
||||||
self.to.setText(pa)
|
self.to.setText(pa)
|
||||||
if opts.relay_host:
|
if opts.relay_host:
|
||||||
self.label.setText(_('Using: %s:%s@%s:%s and %s encryption')%
|
self.label.setText(_('Using: %(un)s:%(pw)s@%(host)s:%(port)s and %(enc)s encryption')%
|
||||||
(opts.relay_username, unhexlify(opts.relay_password),
|
dict(un=opts.relay_username, pw=unhexlify(opts.relay_password),
|
||||||
opts.relay_host, opts.relay_port, opts.encryption))
|
host=opts.relay_host, port=opts.relay_port, enc=opts.encryption))
|
||||||
|
|
||||||
def test(self, *args):
|
def test(self, *args):
|
||||||
self.log.setPlainText(_('Sending...'))
|
self.log.setPlainText(_('Sending...'))
|
||||||
|
@ -54,12 +54,12 @@ class CSV_XML(CatalogPlugin): # {{{
|
|||||||
action = None,
|
action = None,
|
||||||
help = _('The fields to output when cataloging books in the '
|
help = _('The fields to output when cataloging books in the '
|
||||||
'database. Should be a comma-separated list of fields.\n'
|
'database. Should be a comma-separated list of fields.\n'
|
||||||
'Available fields: %s,\n'
|
'Available fields: %(fields)s,\n'
|
||||||
'plus user-created custom fields.\n'
|
'plus user-created custom fields.\n'
|
||||||
'Example: %s=title,authors,tags\n'
|
'Example: %(opt)s=title,authors,tags\n'
|
||||||
"Default: '%%default'\n"
|
"Default: '%%default'\n"
|
||||||
"Applies to: CSV, XML output formats")%(', '.join(FIELDS),
|
"Applies to: CSV, XML output formats")%dict(
|
||||||
'--fields')),
|
fields=', '.join(FIELDS), opt='--fields')),
|
||||||
|
|
||||||
Option('--sort-by',
|
Option('--sort-by',
|
||||||
default = 'id',
|
default = 'id',
|
||||||
@ -250,12 +250,12 @@ class BIBTEX(CatalogPlugin): # {{{
|
|||||||
action = None,
|
action = None,
|
||||||
help = _('The fields to output when cataloging books in the '
|
help = _('The fields to output when cataloging books in the '
|
||||||
'database. Should be a comma-separated list of fields.\n'
|
'database. Should be a comma-separated list of fields.\n'
|
||||||
'Available fields: %s.\n'
|
'Available fields: %(fields)s.\n'
|
||||||
'plus user-created custom fields.\n'
|
'plus user-created custom fields.\n'
|
||||||
'Example: %s=title,authors,tags\n'
|
'Example: %(opt)s=title,authors,tags\n'
|
||||||
"Default: '%%default'\n"
|
"Default: '%%default'\n"
|
||||||
"Applies to: BIBTEX output format")%(', '.join(FIELDS),
|
"Applies to: BIBTEX output format")%dict(
|
||||||
'--fields')),
|
fields=', '.join(FIELDS), opt='--fields')),
|
||||||
|
|
||||||
Option('--sort-by',
|
Option('--sort-by',
|
||||||
default = 'id',
|
default = 'id',
|
||||||
|
@ -62,7 +62,8 @@ class Tag(object):
|
|||||||
if self.avg_rating > 0:
|
if self.avg_rating > 0:
|
||||||
if tooltip:
|
if tooltip:
|
||||||
tooltip = tooltip + ': '
|
tooltip = tooltip + ': '
|
||||||
tooltip = _('%sAverage rating is %3.1f')%(tooltip, self.avg_rating)
|
tooltip = _('%(tt)sAverage rating is %(rating)3.1f')%dict(
|
||||||
|
tt=tooltip, rating=self.avg_rating)
|
||||||
self.tooltip = tooltip
|
self.tooltip = tooltip
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
self.category = category
|
self.category = category
|
||||||
|
@ -121,7 +121,7 @@ class FieldMetadata(dict):
|
|||||||
'datatype':'series',
|
'datatype':'series',
|
||||||
'is_multiple':{},
|
'is_multiple':{},
|
||||||
'kind':'field',
|
'kind':'field',
|
||||||
'name':_('Series'),
|
'name':ngettext('Series', 'Series', 2),
|
||||||
'search_terms':['series'],
|
'search_terms':['series'],
|
||||||
'is_custom':False,
|
'is_custom':False,
|
||||||
'is_category':True,
|
'is_category':True,
|
||||||
|
@ -92,16 +92,17 @@ def config(defaults=None):
|
|||||||
' By default all available formats are saved.'))
|
' By default all available formats are saved.'))
|
||||||
x('template', default=DEFAULT_TEMPLATE,
|
x('template', default=DEFAULT_TEMPLATE,
|
||||||
help=_('The template to control the filename and directory structure of the saved files. '
|
help=_('The template to control the filename and directory structure of the saved files. '
|
||||||
'Default is "%s" which will save books into a per-author '
|
'Default is "%(templ)s" which will save books into a per-author '
|
||||||
'subdirectory with filenames containing title and author. '
|
'subdirectory with filenames containing title and author. '
|
||||||
'Available controls are: {%s}')%(DEFAULT_TEMPLATE, ', '.join(FORMAT_ARGS)))
|
'Available controls are: {%(controls)s}')%dict(
|
||||||
|
templ=DEFAULT_TEMPLATE, controls=', '.join(FORMAT_ARGS)))
|
||||||
x('send_template', default=DEFAULT_SEND_TEMPLATE,
|
x('send_template', default=DEFAULT_SEND_TEMPLATE,
|
||||||
help=_('The template to control the filename and directory structure of files '
|
help=_('The template to control the filename and directory structure of files '
|
||||||
'sent to the device. '
|
'sent to the device. '
|
||||||
'Default is "%s" which will save books into a per-author '
|
'Default is "%(templ)s" which will save books into a per-author '
|
||||||
'directory with filenames containing title and author. '
|
'directory with filenames containing title and author. '
|
||||||
'Available controls are: {%s}')%(DEFAULT_SEND_TEMPLATE, ', '.join(FORMAT_ARGS)))
|
'Available controls are: {%(controls)s}')%dict(
|
||||||
|
templ=DEFAULT_SEND_TEMPLATE, controls=', '.join(FORMAT_ARGS)))
|
||||||
x('asciiize', default=True,
|
x('asciiize', default=True,
|
||||||
help=_('Normally, calibre will convert all non English characters into English equivalents '
|
help=_('Normally, calibre will convert all non English characters into English equivalents '
|
||||||
'for the file names. '
|
'for the file names. '
|
||||||
|
@ -124,7 +124,8 @@ def render_rating(rating, url_prefix, container='span', prefix=None): # {{{
|
|||||||
added = 0
|
added = 0
|
||||||
if prefix is None:
|
if prefix is None:
|
||||||
prefix = _('Average rating')
|
prefix = _('Average rating')
|
||||||
rstring = xml(_('%s: %.1f stars')% (prefix, rating if rating else 0.0),
|
rstring = xml(_('%(prefix)s: %(rating).1f stars')%dict(
|
||||||
|
prefix=prefix, rating=rating if rating else 0.0),
|
||||||
True)
|
True)
|
||||||
ans = ['<%s class="rating">' % (container)]
|
ans = ['<%s class="rating">' % (container)]
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
|
@ -171,9 +171,9 @@ def ACQUISITION_ENTRY(item, version, db, updated, CFM, CKEYS, prefix):
|
|||||||
no_tag_count=True)))
|
no_tag_count=True)))
|
||||||
series = item[FM['series']]
|
series = item[FM['series']]
|
||||||
if series:
|
if series:
|
||||||
extra.append(_('SERIES: %s [%s]<br />')%\
|
extra.append(_('SERIES: %(series)s [%(sidx)s]<br />')%\
|
||||||
(xml(series),
|
dict(series=xml(series),
|
||||||
fmt_sidx(float(item[FM['series_index']]))))
|
sidx=fmt_sidx(float(item[FM['series_index']]))))
|
||||||
for key in CKEYS:
|
for key in CKEYS:
|
||||||
mi = db.get_metadata(item[CFM['id']['rec_index']], index_is_id=True)
|
mi = db.get_metadata(item[CFM['id']['rec_index']], index_is_id=True)
|
||||||
name, val = mi.format_field(key)
|
name, val = mi.format_field(key)
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user