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
e534a1e527
16
recipes/warentest.recipe
Normal file
16
recipes/warentest.recipe
Normal file
@ -0,0 +1,16 @@
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class Warentest(BasicNewsRecipe):
|
||||
title = u'Warentest'
|
||||
language = 'de'
|
||||
description = 'Stiftung Warentest is a German consumer organisation and foundation involved in investigating and comparing goods and services in an unbiased way'
|
||||
__author__ = 'asdfdsfksd'
|
||||
needs_subscription = False
|
||||
max_articles_per_feed = 100
|
||||
auto_cleanup = True
|
||||
|
||||
feeds = [(u'Test', u'http://www.test.de/rss/alles/')]
|
||||
|
||||
def get_cover_url(self):
|
||||
return 'http://www.test.de/img/pp/logo.png'
|
||||
|
@ -7,6 +7,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from functools import partial
|
||||
import textwrap
|
||||
from collections import OrderedDict
|
||||
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, AbortCommit
|
||||
from calibre.gui2.preferences.tweaks_ui import Ui_Form
|
||||
@ -47,12 +48,12 @@ class Tweak(object): # {{{
|
||||
if self.doc:
|
||||
self.doc = translate(self.doc)
|
||||
self.var_names = var_names
|
||||
if len(self.var_names) > 0:
|
||||
self.doc = "%s: %s\n\n%s"%(_('ID'), self.var_names[-1], self.doc)
|
||||
self.default_values = {}
|
||||
if self.var_names:
|
||||
self.doc = u"%s: %s\n\n%s"%(_('ID'), self.var_names[0], self.doc)
|
||||
self.default_values = OrderedDict()
|
||||
for x in var_names:
|
||||
self.default_values[x] = defaults[x]
|
||||
self.custom_values = {}
|
||||
self.custom_values = OrderedDict()
|
||||
for x in var_names:
|
||||
if x in custom:
|
||||
self.custom_values[x] = custom[x]
|
||||
@ -95,12 +96,6 @@ class Tweak(object): # {{{
|
||||
def update(self, varmap):
|
||||
self.custom_values.update(varmap)
|
||||
|
||||
@property
|
||||
def name_with_first_var(self):
|
||||
if len(self.var_names) > 0:
|
||||
return "%s (%s:%s)"%(self.name, _('ID'), self.var_names[-1])
|
||||
return self.name
|
||||
|
||||
# }}}
|
||||
|
||||
class Tweaks(QAbstractListModel, SearchQueryParser): # {{{
|
||||
@ -122,7 +117,7 @@ class Tweaks(QAbstractListModel, SearchQueryParser): # {{{
|
||||
except:
|
||||
return NONE
|
||||
if role == Qt.DisplayRole:
|
||||
return textwrap.fill(tweak.name_with_first_var, 40)
|
||||
return textwrap.fill(tweak.name, 40)
|
||||
if role == Qt.FontRole and tweak.is_customized:
|
||||
ans = QFont()
|
||||
ans.setBold(True)
|
||||
@ -348,7 +343,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
self.context_menu.addAction(self.copy_icon,
|
||||
_('Copy to clipboard'),
|
||||
partial(self.copy_item_to_clipboard,
|
||||
val=tweak.name_with_first_var))
|
||||
val=tweak.name))
|
||||
self.context_menu.popup(self.mapToGlobal(point))
|
||||
return True
|
||||
|
||||
@ -471,7 +466,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from PyQt4.Qt import QApplication
|
||||
app = QApplication([])
|
||||
#Tweaks()
|
||||
#test_widget
|
||||
|
@ -22,7 +22,6 @@ from calibre.library.field_metadata import TagsIcons, category_icon_map
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.utils.formatter import EvalFormatter
|
||||
from calibre.utils.search_query_parser import saved_searches
|
||||
from calibre.utils.localization import get_lang
|
||||
|
||||
TAG_SEARCH_STATES = {'clear': 0, 'mark_plus': 1, 'mark_plusplus': 2,
|
||||
'mark_minus': 3, 'mark_minusminus': 4}
|
||||
@ -364,8 +363,6 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
self.category_nodes.append(node)
|
||||
self._create_node_tree(data, state_map)
|
||||
|
||||
langs_no_span_contractions = frozenset(['en', 'it', 'ru', 'nl', 'de', 'fr', 'es'])
|
||||
|
||||
def _create_node_tree(self, data, state_map):
|
||||
sort_by = config['sort_tags_by']
|
||||
|
||||
|
@ -272,42 +272,6 @@ icu_Collator_contractions(icu_Collator *self, PyObject *args, PyObject *kwargs)
|
||||
return Py_BuildValue("O", ans);
|
||||
} // }}}
|
||||
|
||||
// Collator.span_contractions {{{
|
||||
#ifndef __APPLE__
|
||||
// uset_span is not available in the version of ICU on Apple's idiotic OS
|
||||
static PyObject *
|
||||
icu_Collator_span_contractions(icu_Collator *self, PyObject *args, PyObject *kwargs) {
|
||||
int span_type;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
PyObject *str;
|
||||
size_t slen = 0;
|
||||
wchar_t *buf;
|
||||
UChar *s;
|
||||
int32_t ret;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Ui", &str, &span_type)) return NULL;
|
||||
|
||||
if (self->contractions == NULL) {
|
||||
self->contractions = uset_open(1, 0);
|
||||
if (self->contractions == NULL) return PyErr_NoMemory();
|
||||
self->contractions = ucol_getTailoredSet(self->collator, &status);
|
||||
}
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
slen = PyUnicode_GetSize(str);
|
||||
buf = (wchar_t*)calloc(slen*4 + 2, sizeof(wchar_t));
|
||||
s = (UChar*)calloc(slen*4 + 2, sizeof(UChar));
|
||||
if (buf == NULL || s == NULL) return PyErr_NoMemory();
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)str, buf, slen);
|
||||
u_strFromWCS(s, slen*4+1, NULL, buf, slen, &status);
|
||||
|
||||
ret = uset_span(self->contractions, s, slen, span_type);
|
||||
free(s); free(buf);
|
||||
return Py_BuildValue("i", ret);
|
||||
}
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
static PyObject*
|
||||
icu_Collator_clone(icu_Collator *self, PyObject *args, PyObject *kwargs);
|
||||
|
||||
@ -328,12 +292,6 @@ static PyMethodDef icu_Collator_methods[] = {
|
||||
"contractions() -> returns the contractions defined for this collator."
|
||||
},
|
||||
|
||||
#ifndef __APPLE__
|
||||
{"span_contractions", (PyCFunction)icu_Collator_span_contractions, METH_VARARGS,
|
||||
"span_contractions(src, span_condition) -> returns the length of the initial substring according to span_condition in the set of contractions for this collator. Returns 0 if src does not fit the span_condition. The span_condition can be one of USET_SPAN_NOT_CONTAINED, USET_SPAN_CONTAINED, USET_SPAN_SIMPLE."
|
||||
},
|
||||
#endif
|
||||
|
||||
{"clone", (PyCFunction)icu_Collator_clone, METH_VARARGS,
|
||||
"clone() -> returns a clone of this collator."
|
||||
},
|
||||
|
@ -110,20 +110,6 @@ def icu_contractions(collator):
|
||||
_cmap[collator] = ans
|
||||
return ans
|
||||
|
||||
def py_span_contractions(*args, **kwargs):
|
||||
return 0
|
||||
|
||||
def icu_span_contractions(src, span_type=None, collator=None):
|
||||
global _collator
|
||||
if collator is None:
|
||||
collator = _collator
|
||||
if span_type is None:
|
||||
span_type = _icu.USET_SPAN_SIMPLE
|
||||
try:
|
||||
return collator.span_contractions(src, span_type)
|
||||
except TypeError:
|
||||
return collator.span_contractions(unicode(src), span_type)
|
||||
|
||||
load_icu()
|
||||
load_collator()
|
||||
_icu_not_ok = _icu is None or _collator is None
|
||||
@ -164,9 +150,6 @@ find = (py_find if _icu_not_ok else partial(icu_find, _collator))
|
||||
contractions = ((lambda : {}) if _icu_not_ok else (partial(icu_contractions,
|
||||
_collator)))
|
||||
|
||||
span_contractions = (py_span_contractions if _icu_not_ok else
|
||||
icu_span_contractions)
|
||||
|
||||
def primary_strcmp(a, b):
|
||||
'strcmp that ignores case and accents on letters'
|
||||
if _icu_not_ok:
|
||||
|
Loading…
x
Reference in New Issue
Block a user