mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Sync to trunk.
This commit is contained in:
commit
d39a8d0dd3
@ -59,7 +59,7 @@ class ANDROID(USBMS):
|
|||||||
0x0489 : { 0xc001 : [0x0226], 0xc004 : [0x0226], },
|
0x0489 : { 0xc001 : [0x0226], 0xc004 : [0x0226], },
|
||||||
|
|
||||||
# Acer
|
# Acer
|
||||||
0x502 : { 0x3203 : [0x0100]},
|
0x502 : { 0x3203 : [0x0100, 0x224]},
|
||||||
|
|
||||||
# Dell
|
# Dell
|
||||||
0x413c : { 0xb007 : [0x0100, 0x0224, 0x0226]},
|
0x413c : { 0xb007 : [0x0100, 0x0224, 0x0226]},
|
||||||
|
@ -211,7 +211,10 @@ class Douban(Source):
|
|||||||
'q': q,
|
'q': q,
|
||||||
})
|
})
|
||||||
if self.DOUBAN_API_KEY and self.DOUBAN_API_KEY != '':
|
if self.DOUBAN_API_KEY and self.DOUBAN_API_KEY != '':
|
||||||
url = url + "?apikey=" + self.DOUBAN_API_KEY
|
if t == "isbn" or t == "subject":
|
||||||
|
url = url + "?apikey=" + self.DOUBAN_API_KEY
|
||||||
|
else:
|
||||||
|
url = url + "&apikey=" + self.DOUBAN_API_KEY
|
||||||
return url
|
return url
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
|
||||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
|
||||||
__docformat__ = 'restructuredtext en'
|
|
||||||
|
|
||||||
'''
|
|
||||||
Config widget access functions for enabling and disabling stores.
|
|
||||||
'''
|
|
||||||
|
|
||||||
def config_widget():
|
|
||||||
from calibre.gui2.store.config.chooser.chooser_widget import StoreChooserWidget
|
|
||||||
return StoreChooserWidget()
|
|
||||||
|
|
||||||
def save_settings(config_widget):
|
|
||||||
pass
|
|
@ -130,9 +130,9 @@ class Matches(QAbstractItemModel):
|
|||||||
elif col == 1:
|
elif col == 1:
|
||||||
text = match.name
|
text = match.name
|
||||||
elif col == 2:
|
elif col == 2:
|
||||||
text = 'b' if match.drm else 'a'
|
text = 'b' if getattr(match, 'drm', True) else 'a'
|
||||||
elif col == 3:
|
elif col == 3:
|
||||||
text = match.headquarteres
|
text = getattr(match, 'headquarters', '')
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def sort(self, col, order, reset=True):
|
def sort(self, col, order, reset=True):
|
||||||
|
@ -138,7 +138,7 @@ Follow these steps to find the problem:
|
|||||||
My device is non-standard or unusual. What can I do to connect to it?
|
My device is non-standard or unusual. What can I do to connect to it?
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
In addition to the :guilabel:`Connect to Folder` function found under the Connect/Share button, |app| provides a ``User Defined`` device plugin that can be used to connect to any USB device that presents that shows up as a disk drive in your operating system. See the device plugin ``Preferences -> Plugins -> Device Plugins -> User Defined`` and ``Preferences -> Miscellaneous -> Get information to setup the user defined device`` for more information.
|
In addition to the :guilabel:`Connect to Folder` function found under the Connect/Share button, |app| provides a ``User Defined`` device plugin that can be used to connect to any USB device that shows up as a disk drive in your operating system. Note: on windows, the device must have a drive letter for calibre to use it. See the device plugin ``Preferences -> Plugins -> Device Plugins -> User Defined`` and ``Preferences -> Miscellaneous -> Get information to setup the user defined device`` for more information.
|
||||||
|
|
||||||
How does |app| manage collections on my SONY reader?
|
How does |app| manage collections on my SONY reader?
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -229,13 +229,14 @@ For various values of series_index, the program returns:
|
|||||||
|
|
||||||
The following functions are available in addition to those described in single-function mode. Remember from the example above that the single-function mode functions require an additional first parameter specifying the field to operate on. With the exception of the ``id`` parameter of assign, all parameters can be statements (sequences of expressions):
|
The following functions are available in addition to those described in single-function mode. Remember from the example above that the single-function mode functions require an additional first parameter specifying the field to operate on. With the exception of the ``id`` parameter of assign, all parameters can be statements (sequences of expressions):
|
||||||
|
|
||||||
|
* ``and(value, value, ...)`` -- returns the string "1" if all values are not empty, otherwise returns the empty string. This function works well with test or first_non_empty. You can have as many values as you want.
|
||||||
* ``add(x, y)`` -- returns x + y. Throws an exception if either x or y are not numbers.
|
* ``add(x, y)`` -- returns x + y. Throws an exception if either x or y are not numbers.
|
||||||
* ``assign(id, val)`` -- assigns val to id, then returns val. id must be an identifier, not an expression
|
* ``assign(id, val)`` -- assigns val to id, then returns val. id must be an identifier, not an expression
|
||||||
* ``booksize()`` -- returns the value of the |app| 'size' field. Returns '' if there are no formats.
|
* ``booksize()`` -- returns the value of the |app| 'size' field. Returns '' if there are no formats.
|
||||||
* ``cmp(x, y, lt, eq, gt)`` -- compares x and y after converting both to numbers. Returns ``lt`` if x < y. Returns ``eq`` if x == y. Otherwise returns ``gt``.
|
* ``cmp(x, y, lt, eq, gt)`` -- compares x and y after converting both to numbers. Returns ``lt`` if x < y. Returns ``eq`` if x == y. Otherwise returns ``gt``.
|
||||||
* ``divide(x, y)`` -- returns x / y. Throws an exception if either x or y are not numbers.
|
* ``divide(x, y)`` -- returns x / y. Throws an exception if either x or y are not numbers.
|
||||||
* ``field(name)`` -- returns the metadata field named by ``name``.
|
* ``field(name)`` -- returns the metadata field named by ``name``.
|
||||||
* ``first_non_empty(value, value, ...) -- returns the first value that is not empty. If all values are empty, then the empty value is returned. You can have as many values as you want.
|
* ``first_non_empty(value, value, ...)`` -- returns the first value that is not empty. If all values are empty, then the empty value is returned. You can have as many values as you want.
|
||||||
* ``format_date(x, date_format)`` -- format_date(val, format_string) -- format the value, which must be a date field, using the format_string, returning a string. The formatting codes are::
|
* ``format_date(x, date_format)`` -- format_date(val, format_string) -- format the value, which must be a date field, using the format_string, returning a string. The formatting codes are::
|
||||||
|
|
||||||
d : the day as number without a leading zero (1 to 31)
|
d : the day as number without a leading zero (1 to 31)
|
||||||
@ -251,7 +252,9 @@ The following functions are available in addition to those described in single-f
|
|||||||
iso : the date with time and timezone. Must be the only format present.
|
iso : the date with time and timezone. Must be the only format present.
|
||||||
|
|
||||||
* ``eval(string)`` -- evaluates the string as a program, passing the local variables (those ``assign`` ed to). This permits using the template processor to construct complex results from local variables.
|
* ``eval(string)`` -- evaluates the string as a program, passing the local variables (those ``assign`` ed to). This permits using the template processor to construct complex results from local variables.
|
||||||
|
* ``not(value)`` -- returns the string "1" if the value is empty, otherwise returns the empty string. This function works well with test or first_non_empty. You can have as many values as you want.
|
||||||
* ``multiply(x, y)`` -- returns x * y. Throws an exception if either x or y are not numbers.
|
* ``multiply(x, y)`` -- returns x * y. Throws an exception if either x or y are not numbers.
|
||||||
|
* ``or(value, value, ...)`` -- returns the string "1" if any value is not empty, otherwise returns the empty string. This function works well with test or first_non_empty. You can have as many values as you want.
|
||||||
* ``print(a, b, ...)`` -- prints the arguments to standard output. Unless you start calibre from the command line (``calibre-debug -g``), the output will go to a black hole.
|
* ``print(a, b, ...)`` -- prints the arguments to standard output. Unless you start calibre from the command line (``calibre-debug -g``), the output will go to a black hole.
|
||||||
* ``raw_field(name)`` -- returns the metadata field named by name without applying any formatting.
|
* ``raw_field(name)`` -- returns the metadata field named by name without applying any formatting.
|
||||||
* ``strcat(a, b, ...)`` -- can take any number of arguments. Returns a string formed by concatenating all the arguments.
|
* ``strcat(a, b, ...)`` -- can take any number of arguments. Returns a string formed by concatenating all the arguments.
|
||||||
@ -260,6 +263,21 @@ The following functions are available in addition to those described in single-f
|
|||||||
* ``subtract(x, y)`` -- returns x - y. Throws an exception if either x or y are not numbers.
|
* ``subtract(x, y)`` -- returns x - y. Throws an exception if either x or y are not numbers.
|
||||||
* ``template(x)`` -- evaluates x as a template. The evaluation is done in its own context, meaning that variables are not shared between the caller and the template evaluation. Because the `{` and `}` characters are special, you must use `[[` for the `{` character and `]]` for the '}' character; they are converted automatically. For example, ``template('[[title_sort]]') will evaluate the template ``{title_sort}`` and return its value.
|
* ``template(x)`` -- evaluates x as a template. The evaluation is done in its own context, meaning that variables are not shared between the caller and the template evaluation. Because the `{` and `}` characters are special, you must use `[[` for the `{` character and `]]` for the '}' character; they are converted automatically. For example, ``template('[[title_sort]]') will evaluate the template ``{title_sort}`` and return its value.
|
||||||
|
|
||||||
|
Function classification summary:
|
||||||
|
|
||||||
|
* Get values from metadata: ``field``. ``raw_field``. In some situations, ``lookup`` can be used in place of ``field``.
|
||||||
|
* Arithmetic: ``add``, ``subtract``, ``multiply``, ``divide``
|
||||||
|
* Boolean: ``and``, ``or``, ``not``. The function ``if_empty`` is similar to ``and`` called with one argument.
|
||||||
|
* If-then-else: ``contains``, ``test``
|
||||||
|
* Iterating over values: ``first_non_empty``, ``lookup``, ``switch``
|
||||||
|
* List lookup: ``in_list``, ``list_item``, ``select``,
|
||||||
|
* List manipulation: ``count``, ``sublist``, ``subitems``
|
||||||
|
* Recursion: ``eval``, ``template``
|
||||||
|
* Relational: ``cmp`` , ``strcmp`` for strings
|
||||||
|
* String case changes: ``lowercase``, ``uppercase``, ``titlecase``, ``capitalize``
|
||||||
|
* String manipulation: ``re``, ``shorten``, ``substr``
|
||||||
|
* Other: ``assign``, ``booksize``, ``print``, ``format_date``,
|
||||||
|
|
||||||
.. _general_mode:
|
.. _general_mode:
|
||||||
|
|
||||||
Using general program mode
|
Using general program mode
|
||||||
|
@ -594,7 +594,56 @@ class BuiltinFirstNonEmpty(BuiltinFormatterFunction):
|
|||||||
i += 1
|
i += 1
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
class BuiltinAnd(BuiltinFormatterFunction):
|
||||||
|
name = 'and'
|
||||||
|
arg_count = -1
|
||||||
|
doc = _('and(value, value, ...) -- '
|
||||||
|
'returns the string "1" if all values are not empty, otherwise '
|
||||||
|
'returns the empty string. This function works well with test or '
|
||||||
|
'first_non_empty. You can have as many values as you want.')
|
||||||
|
|
||||||
|
def evaluate(self, formatter, kwargs, mi, locals, *args):
|
||||||
|
i = 0
|
||||||
|
while i < len(args):
|
||||||
|
if not args[i]:
|
||||||
|
return ''
|
||||||
|
i += 1
|
||||||
|
return '1'
|
||||||
|
|
||||||
|
class BuiltinOr(BuiltinFormatterFunction):
|
||||||
|
name = 'or'
|
||||||
|
arg_count = -1
|
||||||
|
doc = _('or(value, value, ...) -- '
|
||||||
|
'returns the string "1" if any value is not empty, otherwise '
|
||||||
|
'returns the empty string. This function works well with test or '
|
||||||
|
'first_non_empty. You can have as many values as you want.')
|
||||||
|
|
||||||
|
def evaluate(self, formatter, kwargs, mi, locals, *args):
|
||||||
|
i = 0
|
||||||
|
while i < len(args):
|
||||||
|
if args[i]:
|
||||||
|
return '1'
|
||||||
|
i += 1
|
||||||
|
return ''
|
||||||
|
|
||||||
|
class BuiltinNot(BuiltinFormatterFunction):
|
||||||
|
name = 'not'
|
||||||
|
arg_count = 1
|
||||||
|
doc = _('not(value) -- '
|
||||||
|
'returns the string "1" if the value is empty, otherwise '
|
||||||
|
'returns the empty string. This function works well with test or '
|
||||||
|
'first_non_empty. You can have as many values as you want.')
|
||||||
|
|
||||||
|
def evaluate(self, formatter, kwargs, mi, locals, *args):
|
||||||
|
i = 0
|
||||||
|
while i < len(args):
|
||||||
|
if args[i]:
|
||||||
|
return '1'
|
||||||
|
i += 1
|
||||||
|
return ''
|
||||||
|
|
||||||
builtin_add = BuiltinAdd()
|
builtin_add = BuiltinAdd()
|
||||||
|
builtin_and = BuiltinAnd()
|
||||||
builtin_assign = BuiltinAssign()
|
builtin_assign = BuiltinAssign()
|
||||||
builtin_booksize = BuiltinBooksize()
|
builtin_booksize = BuiltinBooksize()
|
||||||
builtin_capitalize = BuiltinCapitalize()
|
builtin_capitalize = BuiltinCapitalize()
|
||||||
@ -612,6 +661,8 @@ builtin_list_item = BuiltinListitem()
|
|||||||
builtin_lookup = BuiltinLookup()
|
builtin_lookup = BuiltinLookup()
|
||||||
builtin_lowercase = BuiltinLowercase()
|
builtin_lowercase = BuiltinLowercase()
|
||||||
builtin_multiply = BuiltinMultiply()
|
builtin_multiply = BuiltinMultiply()
|
||||||
|
builtin_not = BuiltinNot()
|
||||||
|
builtin_or = BuiltinOr()
|
||||||
builtin_print = BuiltinPrint()
|
builtin_print = BuiltinPrint()
|
||||||
builtin_raw_field = BuiltinRaw_field()
|
builtin_raw_field = BuiltinRaw_field()
|
||||||
builtin_re = BuiltinRe()
|
builtin_re = BuiltinRe()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user