This commit is contained in:
GRiker 2013-03-01 04:26:07 -07:00
commit 4fe4ab84ee
124 changed files with 32602 additions and 26505 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,182 @@
__license__ = 'GPL v3'
__copyright__ = '2013, Darko Miletic <darko.miletic at gmail.com>'
'''
http://www.ft.com/intl/us-edition
'''
import datetime
from calibre.ptempfile import PersistentTemporaryFile
from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe
class FinancialTimes(BasicNewsRecipe):
title = 'Financial Times (US) printed edition'
__author__ = 'Darko Miletic'
description = "The Financial Times (FT) is one of the world's leading business news and information organisations, recognised internationally for its authority, integrity and accuracy."
publisher = 'The Financial Times Ltd.'
category = 'news, finances, politics, UK, World'
oldest_article = 2
language = 'en'
max_articles_per_feed = 250
no_stylesheets = True
use_embedded_content = False
needs_subscription = True
encoding = 'utf8'
publication_type = 'newspaper'
articles_are_obfuscated = True
temp_files = []
masthead_url = 'http://im.media.ft.com/m/img/masthead_main.jpg'
LOGIN = 'https://registration.ft.com/registration/barrier/login'
LOGIN2 = 'http://media.ft.com/h/subs3.html'
INDEX = 'http://www.ft.com/intl/us-edition'
PREFIX = 'http://www.ft.com'
conversion_options = {
'comment' : description
, 'tags' : category
, 'publisher' : publisher
, 'language' : language
, 'linearize_tables' : True
}
def get_browser(self):
br = BasicNewsRecipe.get_browser(self)
br.open(self.INDEX)
if self.username is not None and self.password is not None:
br.open(self.LOGIN2)
br.select_form(name='loginForm')
br['username'] = self.username
br['password'] = self.password
br.submit()
return br
keep_only_tags = [
dict(name='div' , attrs={'class':['fullstory fullstoryHeader', 'ft-story-header']})
,dict(name='div' , attrs={'class':'standfirst'})
,dict(name='div' , attrs={'id' :'storyContent'})
,dict(name='div' , attrs={'class':['ft-story-body','index-detail']})
,dict(name='h2' , attrs={'class':'entry-title'} )
,dict(name='span', attrs={'class':lambda x: x and 'posted-on' in x.split()} )
,dict(name='span', attrs={'class':'author_byline'} )
,dict(name='div' , attrs={'class':'entry-content'} )
]
remove_tags = [
dict(name='div', attrs={'id':'floating-con'})
,dict(name=['meta','iframe','base','object','embed','link'])
,dict(attrs={'class':['storyTools','story-package','screen-copy','story-package separator','expandable-image']})
]
remove_attributes = ['width','height','lang']
extra_css = """
body{font-family: Georgia,Times,"Times New Roman",serif}
h2{font-size:large}
.ft-story-header{font-size: x-small}
.container{font-size:x-small;}
h3{font-size:x-small;color:#003399;}
.copyright{font-size: x-small}
img{margin-top: 0.8em; display: block}
.lastUpdated{font-family: Arial,Helvetica,sans-serif; font-size: x-small}
.byline,.ft-story-body,.ft-story-header{font-family: Arial,Helvetica,sans-serif}
"""
def get_artlinks(self, elem):
articles = []
count = 0
for item in elem.findAll('a',href=True):
count = count + 1
if self.test and count > 2:
return articles
rawlink = item['href']
url = rawlink
if not rawlink.startswith('http://'):
url = self.PREFIX + rawlink
try:
urlverified = self.browser.open_novisit(url).geturl() # resolve redirect.
except:
continue
title = self.tag_to_string(item)
date = strftime(self.timefmt)
articles.append({
'title' :title
,'date' :date
,'url' :urlverified
,'description':''
})
return articles
def parse_index(self):
feeds = []
soup = self.index_to_soup(self.INDEX)
dates= self.tag_to_string(soup.find('div', attrs={'class':'btm-links'}).find('div'))
self.timefmt = ' [%s]'%dates
wide = soup.find('div',attrs={'class':'wide'})
if not wide:
return feeds
allsections = wide.findAll(attrs={'class':lambda x: x and 'footwell' in x.split()})
if not allsections:
return feeds
count = 0
for item in allsections:
count = count + 1
if self.test and count > 2:
return feeds
fitem = item.h3
if not fitem:
fitem = item.h4
ftitle = self.tag_to_string(fitem)
self.report_progress(0, _('Fetching feed')+' %s...'%(ftitle))
feedarts = self.get_artlinks(item.ul)
feeds.append((ftitle,feedarts))
return feeds
def preprocess_html(self, soup):
items = ['promo-box','promo-title',
'promo-headline','promo-image',
'promo-intro','promo-link','subhead']
for item in items:
for it in soup.findAll(item):
it.name = 'div'
it.attrs = []
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:
item.name = 'div'
item.attrs = []
else:
str = self.tag_to_string(item)
item.replaceWith(str)
for item in soup.findAll('img'):
if not item.has_key('alt'):
item['alt'] = 'image'
return soup
def get_cover_url(self):
cdate = datetime.date.today()
if cdate.isoweekday() == 7:
cdate -= datetime.timedelta(days=1)
return cdate.strftime('http://specials.ft.com/vtf_pdf/%d%m%y_FRONT1_USA.pdf')
def get_obfuscated_article(self, url):
count = 0
while (count < 10):
try:
response = self.browser.open(url)
html = response.read()
count = 10
except:
print "Retrying download..."
count += 1
tfile = PersistentTemporaryFile('_fa.html')
tfile.write(html)
tfile.close()
self.temp_files.append(tfile)
return tfile.name
def cleanup(self):
self.browser.open('https://registration.ft.com/registration/login/logout?location=')

View File

@ -1,5 +1,4 @@
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
import re
class HNonlineRecipe(BasicNewsRecipe): class HNonlineRecipe(BasicNewsRecipe):
__license__ = 'GPL v3' __license__ = 'GPL v3'

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -5,7 +5,6 @@
http://www.unperiodico.unal.edu.co/ http://www.unperiodico.unal.edu.co/
''' '''
from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class UNPeriodico(BasicNewsRecipe): class UNPeriodico(BasicNewsRecipe):
@ -18,5 +17,5 @@ class UNPeriodico(BasicNewsRecipe):
max_articles_per_feed = 100 max_articles_per_feed = 100
publication_type = 'newspaper' publication_type = 'newspaper'
feeds = [ feeds = [
(u'UNPeriodico', u'http://www.unperiodico.unal.edu.co/rss/type/rss2/') (u'UNPeriodico', u'http://www.unperiodico.unal.edu.co/rss/type/rss2/')
] ]

Binary file not shown.

View File

@ -482,5 +482,10 @@ h2.library_name {
border: none border: none
} }
.details #random_button {
display:block
}
/* }}} */ /* }}} */

View File

@ -324,9 +324,15 @@ function show_details(a_dom) {
function book() { function book() {
hidesort(); hidesort();
$('.details .left img').load(function() { $('.details .left img').load(function() {
var rb = $('#random_button');
rb.button();
var img = $('.details .left img'); var img = $('.details .left img');
var height = $('#main').height(); var height = $('#main').height();
height = Math.max(height, img.height() + 100); var bh = 0;
if (rb.length > 0) {
bh = rb.height();
}
height = Math.max(height, img.height() + bh + 100);
$('#main').height(height); $('#main').height(height);
}); });
} }

View File

@ -1,6 +1,7 @@
<div id="details_{id}" class="details"> <div id="details_{id}" class="details">
<div class="left"> <div class="left">
<a href="{get_url}" title="Click to read {title} in the {fmt} format" class="details_thumb"><img alt="Cover of {title}" src="{prefix}/get/cover/{id}" /></a> <a href="{get_url}" title="Click to read {title} in the {fmt} format" class="details_thumb"><img alt="Cover of {title}" src="{prefix}/get/cover/{id}" /></a>
{random}
</div> </div>
<div class="right"> <div class="right">
<div class="field formats">{formats}</div> <div class="field formats">{formats}</div>

View File

@ -524,3 +524,10 @@ preselect_first_completion = False
# that starts with numbers and is a little slower. # that starts with numbers and is a little slower.
numeric_collation = False numeric_collation = False
#: Sort the list of libraries alphabetically
# The list of libraries in the Copy to Library and Quick Switch menus are
# normally sorted by most used. However, if there are more than a certain
# number of such libraries, the sorting becomes alphabetic. You can set that
# number here. The default is ten libraries.
many_libraries = 10

View File

@ -38,7 +38,7 @@ binary_includes = [
'/lib/libz.so.1', '/lib/libz.so.1',
'/usr/lib/libtiff.so.5', '/usr/lib/libtiff.so.5',
'/lib/libbz2.so.1', '/lib/libbz2.so.1',
'/usr/lib/libpoppler.so.27', '/usr/lib/libpoppler.so.28',
'/usr/lib/libxml2.so.2', '/usr/lib/libxml2.so.2',
'/usr/lib/libopenjpeg.so.2', '/usr/lib/libopenjpeg.so.2',
'/usr/lib/libxslt.so.1', '/usr/lib/libxslt.so.1',

View File

@ -9,14 +9,14 @@ msgstr ""
"Project-Id-Version: calibre\n" "Project-Id-Version: calibre\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2011-11-25 14:01+0000\n" "POT-Creation-Date: 2011-11-25 14:01+0000\n"
"PO-Revision-Date: 2013-01-12 08:34+0000\n" "PO-Revision-Date: 2013-02-26 12:21+0000\n"
"Last-Translator: Jellby <Unknown>\n" "Last-Translator: Miguel Angel del Olmo <silinio45@gmail.com>\n"
"Language-Team: Español; Castellano <>\n" "Language-Team: Español; Castellano <>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2013-01-13 04:37+0000\n" "X-Launchpad-Export-Date: 2013-02-27 04:37+0000\n"
"X-Generator: Launchpad (build 16420)\n" "X-Generator: Launchpad (build 16506)\n"
#. name for aaa #. name for aaa
msgid "Ghotuo" msgid "Ghotuo"
@ -9708,7 +9708,7 @@ msgstr ""
#. name for hto #. name for hto
msgid "Huitoto; Minica" msgid "Huitoto; Minica"
msgstr "" msgstr "Huitoto; Meneca"
#. name for hts #. name for hts
msgid "Hadza" msgid "Hadza"
@ -9736,7 +9736,7 @@ msgstr ""
#. name for hue #. name for hue
msgid "Huave; San Francisco Del Mar" msgid "Huave; San Francisco Del Mar"
msgstr "" msgstr "Huave; San Francisco Del Mar"
#. name for huf #. name for huf
msgid "Humene" msgid "Humene"
@ -9792,7 +9792,7 @@ msgstr ""
#. name for hus #. name for hus
msgid "Huastec" msgid "Huastec"
msgstr "" msgstr "Huasteco"
#. name for hut #. name for hut
msgid "Humla" msgid "Humla"
@ -9800,11 +9800,11 @@ msgstr ""
#. name for huu #. name for huu
msgid "Huitoto; Murui" msgid "Huitoto; Murui"
msgstr "" msgstr "Huitoto; Murui"
#. name for huv #. name for huv
msgid "Huave; San Mateo Del Mar" msgid "Huave; San Mateo Del Mar"
msgstr "" msgstr "Huave; San Mateo Del Mar"
#. name for huw #. name for huw
msgid "Hukumina" msgid "Hukumina"
@ -9812,7 +9812,7 @@ msgstr ""
#. name for hux #. name for hux
msgid "Huitoto; Nüpode" msgid "Huitoto; Nüpode"
msgstr "" msgstr "Huitoto; Nipode"
#. name for huy #. name for huy
msgid "Hulaulá" msgid "Hulaulá"
@ -9828,7 +9828,7 @@ msgstr ""
#. name for hve #. name for hve
msgid "Huave; San Dionisio Del Mar" msgid "Huave; San Dionisio Del Mar"
msgstr "" msgstr "Huave; San Dionisio Del Mar"
#. name for hvk #. name for hvk
msgid "Haveke" msgid "Haveke"
@ -9840,7 +9840,7 @@ msgstr ""
#. name for hvv #. name for hvv
msgid "Huave; Santa María Del Mar" msgid "Huave; Santa María Del Mar"
msgstr "" msgstr "Huave; Santa María Del Mar"
#. name for hwa #. name for hwa
msgid "Wané" msgid "Wané"
@ -9884,7 +9884,7 @@ msgstr "Iban"
#. name for ibb #. name for ibb
msgid "Ibibio" msgid "Ibibio"
msgstr "" msgstr "Ibibio"
#. name for ibd #. name for ibd
msgid "Iwaidja" msgid "Iwaidja"
@ -9964,7 +9964,7 @@ msgstr ""
#. name for ide #. name for ide
msgid "Idere" msgid "Idere"
msgstr "" msgstr "Idere"
#. name for idi #. name for idi
msgid "Idi" msgid "Idi"
@ -9976,7 +9976,7 @@ msgstr "Ido"
#. name for idr #. name for idr
msgid "Indri" msgid "Indri"
msgstr "" msgstr "Indri"
#. name for ids #. name for ids
msgid "Idesa" msgid "Idesa"
@ -9988,7 +9988,7 @@ msgstr ""
#. name for idu #. name for idu
msgid "Idoma" msgid "Idoma"
msgstr "" msgstr "Idoma"
#. name for ifa #. name for ifa
msgid "Ifugao; Amganad" msgid "Ifugao; Amganad"
@ -9996,7 +9996,7 @@ msgstr ""
#. name for ifb #. name for ifb
msgid "Ifugao; Batad" msgid "Ifugao; Batad"
msgstr "" msgstr "Ifugao; Batad"
#. name for ife #. name for ife
msgid "Ifè" msgid "Ifè"
@ -10004,7 +10004,7 @@ msgstr ""
#. name for iff #. name for iff
msgid "Ifo" msgid "Ifo"
msgstr "" msgstr "Ifo"
#. name for ifk #. name for ifk
msgid "Ifugao; Tuwali" msgid "Ifugao; Tuwali"
@ -10064,7 +10064,7 @@ msgstr ""
#. name for ihi #. name for ihi
msgid "Ihievbe" msgid "Ihievbe"
msgstr "" msgstr "Ihievbe"
#. name for ihp #. name for ihp
msgid "Iha" msgid "Iha"
@ -10288,15 +10288,15 @@ msgstr ""
#. name for iou #. name for iou
msgid "Tuma-Irumu" msgid "Tuma-Irumu"
msgstr "" msgstr "Tuma-Irumu"
#. name for iow #. name for iow
msgid "Iowa-Oto" msgid "Iowa-Oto"
msgstr "" msgstr "Iowa-Oto"
#. name for ipi #. name for ipi
msgid "Ipili" msgid "Ipili"
msgstr "" msgstr "Ipili"
#. name for ipk #. name for ipk
msgid "Inupiaq" msgid "Inupiaq"
@ -10304,7 +10304,7 @@ msgstr "Iñupiaq"
#. name for ipo #. name for ipo
msgid "Ipiko" msgid "Ipiko"
msgstr "" msgstr "Ipiko"
#. name for iqu #. name for iqu
msgid "Iquito" msgid "Iquito"
@ -30768,7 +30768,7 @@ msgstr ""
#. name for zts #. name for zts
msgid "Zapotec; Tilquiapan" msgid "Zapotec; Tilquiapan"
msgstr "" msgstr "Zapoteco; Tilquiapan"
#. name for ztt #. name for ztt
msgid "Zapotec; Tejalapan" msgid "Zapotec; Tejalapan"

View File

@ -13,14 +13,14 @@ msgstr ""
"Report-Msgid-Bugs-To: Debian iso-codes team <pkg-isocodes-" "Report-Msgid-Bugs-To: Debian iso-codes team <pkg-isocodes-"
"devel@lists.alioth.debian.org>\n" "devel@lists.alioth.debian.org>\n"
"POT-Creation-Date: 2011-11-25 14:01+0000\n" "POT-Creation-Date: 2011-11-25 14:01+0000\n"
"PO-Revision-Date: 2012-04-04 19:53+0000\n" "PO-Revision-Date: 2013-02-23 12:04+0000\n"
"Last-Translator: Antoni Kudelski <antekk@linux.pl>\n" "Last-Translator: Marcin Ostajewski (panszpik) <Unknown>\n"
"Language-Team: Polish <translation-team-pl@lists.sourceforge.net>\n" "Language-Team: Polish <translation-team-pl@lists.sourceforge.net>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2012-04-05 04:43+0000\n" "X-Launchpad-Export-Date: 2013-02-24 04:41+0000\n"
"X-Generator: Launchpad (build 15060)\n" "X-Generator: Launchpad (build 16506)\n"
"Language: pl\n" "Language: pl\n"
#. name for aaa #. name for aaa
@ -857,11 +857,11 @@ msgstr "Akurio"
#. name for akp #. name for akp
msgid "Siwu" msgid "Siwu"
msgstr "" msgstr "Siwu"
#. name for akq #. name for akq
msgid "Ak" msgid "Ak"
msgstr "" msgstr "Ak"
#. name for akr #. name for akr
msgid "Araki" msgid "Araki"
@ -973,7 +973,7 @@ msgstr "ałtajski południowy"
#. name for alu #. name for alu
msgid "'Are'are" msgid "'Are'are"
msgstr "" msgstr "'Are'are"
#. name for alw #. name for alw
msgid "Alaba-Kabeena" msgid "Alaba-Kabeena"
@ -1037,7 +1037,7 @@ msgstr "War-Jaintia"
#. name for amm #. name for amm
msgid "Ama (Papua New Guinea)" msgid "Ama (Papua New Guinea)"
msgstr "" msgstr "Ama (Papua New Guinea)"
#. name for amn #. name for amn
msgid "Amanab" msgid "Amanab"
@ -1061,7 +1061,7 @@ msgstr "Amarakaeri"
#. name for ams #. name for ams
msgid "Amami-Oshima; Southern" msgid "Amami-Oshima; Southern"
msgstr "" msgstr "Południowy amami-oshima"
#. name for amt #. name for amt
msgid "Amto" msgid "Amto"
@ -1069,7 +1069,7 @@ msgstr "Amto"
#. name for amu #. name for amu
msgid "Amuzgo; Guerrero" msgid "Amuzgo; Guerrero"
msgstr "" msgstr "Amuzgo; Guerrero"
#. name for amv #. name for amv
msgid "Ambelau" msgid "Ambelau"
@ -1249,7 +1249,7 @@ msgstr "Ömie"
#. name for aon #. name for aon
msgid "Arapesh; Bumbita" msgid "Arapesh; Bumbita"
msgstr "" msgstr "Arapesh; Bumbita"
#. name for aor #. name for aor
msgid "Aore" msgid "Aore"
@ -1289,7 +1289,7 @@ msgstr "Bukiyip"
#. name for apf #. name for apf
msgid "Agta; Pahanan" msgid "Agta; Pahanan"
msgstr "" msgstr "Agta; Pahanan"
#. name for apg #. name for apg
msgid "Ampanang" msgid "Ampanang"
@ -1305,19 +1305,19 @@ msgstr "Apiaká"
#. name for apj #. name for apj
msgid "Apache; Jicarilla" msgid "Apache; Jicarilla"
msgstr "" msgstr "Apache; Jicarilla"
#. name for apk #. name for apk
msgid "Apache; Kiowa" msgid "Apache; Kiowa"
msgstr "" msgstr "Apache; Kiowa"
#. name for apl #. name for apl
msgid "Apache; Lipan" msgid "Apache; Lipan"
msgstr "" msgstr "Apache; Lipan"
#. name for apm #. name for apm
msgid "Apache; Mescalero-Chiricahua" msgid "Apache; Mescalero-Chiricahua"
msgstr "" msgstr "Apache; Mescalero-Chiricahua"
#. name for apn #. name for apn
msgid "Apinayé" msgid "Apinayé"
@ -1337,11 +1337,11 @@ msgstr "a-pucikwar"
#. name for apr #. name for apr
msgid "Arop-Lokep" msgid "Arop-Lokep"
msgstr "" msgstr "Arop-Lokep"
#. name for aps #. name for aps
msgid "Arop-Sissano" msgid "Arop-Sissano"
msgstr "" msgstr "Arop-Sissano"
#. name for apt #. name for apt
msgid "Apatani" msgid "Apatani"
@ -1357,7 +1357,7 @@ msgstr "Alapmunte"
#. name for apw #. name for apw
msgid "Apache; Western" msgid "Apache; Western"
msgstr "" msgstr "Zachodni apache"
#. name for apx #. name for apx
msgid "Aputai" msgid "Aputai"
@ -1389,7 +1389,7 @@ msgstr "Atohwaim"
#. name for aqn #. name for aqn
msgid "Alta; Northern" msgid "Alta; Northern"
msgstr "" msgstr "Północny alta"
#. name for aqp #. name for aqp
msgid "Atakapa" msgid "Atakapa"
@ -1409,7 +1409,7 @@ msgstr "arabski"
#. name for arb #. name for arb
msgid "Arabic; Standard" msgid "Arabic; Standard"
msgstr "" msgstr "Standardowy arabski"
#. name for arc #. name for arc
msgid "Aramaic; Official (700-300 BCE)" msgid "Aramaic; Official (700-300 BCE)"
@ -1465,15 +1465,15 @@ msgstr "arabski algierski"
#. name for arr #. name for arr
msgid "Karo (Brazil)" msgid "Karo (Brazil)"
msgstr "" msgstr "Karo (Brazylia)"
#. name for ars #. name for ars
msgid "Arabic; Najdi" msgid "Arabic; Najdi"
msgstr "" msgstr "Arabski Najdi"
#. name for aru #. name for aru
msgid "Aruá (Amazonas State)" msgid "Aruá (Amazonas State)"
msgstr "" msgstr "Aruá (stan Amazonas)"
#. name for arv #. name for arv
msgid "Arbore" msgid "Arbore"
@ -1485,7 +1485,7 @@ msgstr "arawak"
#. name for arx #. name for arx
msgid "Aruá (Rodonia State)" msgid "Aruá (Rodonia State)"
msgstr "" msgstr "Aruá (stan Rodonia)"
#. name for ary #. name for ary
msgid "Arabic; Moroccan" msgid "Arabic; Moroccan"
@ -1529,11 +1529,11 @@ msgstr "Abishira"
#. name for asi #. name for asi
msgid "Buruwai" msgid "Buruwai"
msgstr "" msgstr "Buruwai"
#. name for asj #. name for asj
msgid "Nsari" msgid "Nsari"
msgstr "" msgstr "Nsari"
#. name for ask #. name for ask
msgid "Ashkun" msgid "Ashkun"
@ -1541,7 +1541,7 @@ msgstr "aszkun"
#. name for asl #. name for asl
msgid "Asilulu" msgid "Asilulu"
msgstr "" msgstr "Asilulu"
#. name for asm #. name for asm
msgid "Assamese" msgid "Assamese"
@ -1549,11 +1549,11 @@ msgstr "asamski"
#. name for asn #. name for asn
msgid "Asuriní; Xingú" msgid "Asuriní; Xingú"
msgstr "" msgstr "Asuriní; Xingú"
#. name for aso #. name for aso
msgid "Dano" msgid "Dano"
msgstr "" msgstr "Dano"
#. name for asp #. name for asp
msgid "Algerian Sign Language" msgid "Algerian Sign Language"
@ -1565,11 +1565,11 @@ msgstr "austriacki język migowy"
#. name for asr #. name for asr
msgid "Asuri" msgid "Asuri"
msgstr "" msgstr "Asuri"
#. name for ass #. name for ass
msgid "Ipulo" msgid "Ipulo"
msgstr "" msgstr "Ipulo"
#. name for ast #. name for ast
msgid "Asturian" msgid "Asturian"
@ -1577,11 +1577,11 @@ msgstr "asturyjski"
#. name for asu #. name for asu
msgid "Asurini; Tocantins" msgid "Asurini; Tocantins"
msgstr "" msgstr "Asurini; Tocantins"
#. name for asv #. name for asv
msgid "Asoa" msgid "Asoa"
msgstr "" msgstr "Asoa"
#. name for asw #. name for asw
msgid "Australian Aborigines Sign Language" msgid "Australian Aborigines Sign Language"
@ -1589,43 +1589,43 @@ msgstr "język migowy Aborygenów australijskich"
#. name for asx #. name for asx
msgid "Muratayak" msgid "Muratayak"
msgstr "" msgstr "Muratayak"
#. name for asy #. name for asy
msgid "Asmat; Yaosakor" msgid "Asmat; Yaosakor"
msgstr "" msgstr "Asmat; Yaosakor"
#. name for asz #. name for asz
msgid "As" msgid "As"
msgstr "" msgstr "As"
#. name for ata #. name for ata
msgid "Pele-Ata" msgid "Pele-Ata"
msgstr "" msgstr "Pele-Ata"
#. name for atb #. name for atb
msgid "Zaiwa" msgid "Zaiwa"
msgstr "" msgstr "Zaiwa"
#. name for atc #. name for atc
msgid "Atsahuaca" msgid "Atsahuaca"
msgstr "" msgstr "Atsahuaca"
#. name for atd #. name for atd
msgid "Manobo; Ata" msgid "Manobo; Ata"
msgstr "" msgstr "Manobo; Ata"
#. name for ate #. name for ate
msgid "Atemble" msgid "Atemble"
msgstr "" msgstr "Atemble"
#. name for atg #. name for atg
msgid "Ivbie North-Okpela-Arhe" msgid "Ivbie North-Okpela-Arhe"
msgstr "" msgstr "Ivbie North-Okpela-Arhe"
#. name for ati #. name for ati
msgid "Attié" msgid "Attié"
msgstr "" msgstr "Attié"
#. name for atj #. name for atj
msgid "Atikamekw" msgid "Atikamekw"
@ -1633,111 +1633,111 @@ msgstr "atikamekw"
#. name for atk #. name for atk
msgid "Ati" msgid "Ati"
msgstr "" msgstr "Ati"
#. name for atl #. name for atl
msgid "Agta; Mt. Iraya" msgid "Agta; Mt. Iraya"
msgstr "" msgstr "Agta; Mt. Iraya"
#. name for atm #. name for atm
msgid "Ata" msgid "Ata"
msgstr "" msgstr "Ata"
#. name for atn #. name for atn
msgid "Ashtiani" msgid "Ashtiani"
msgstr "" msgstr "Ashtiani"
#. name for ato #. name for ato
msgid "Atong" msgid "Atong"
msgstr "" msgstr "Atong"
#. name for atp #. name for atp
msgid "Atta; Pudtol" msgid "Atta; Pudtol"
msgstr "" msgstr "Atta; Pudtol"
#. name for atq #. name for atq
msgid "Aralle-Tabulahan" msgid "Aralle-Tabulahan"
msgstr "" msgstr "Aralle-Tabulahan"
#. name for atr #. name for atr
msgid "Waimiri-Atroari" msgid "Waimiri-Atroari"
msgstr "" msgstr "Waimiri-Atroari"
#. name for ats #. name for ats
msgid "Gros Ventre" msgid "Gros Ventre"
msgstr "" msgstr "Gros Ventre"
#. name for att #. name for att
msgid "Atta; Pamplona" msgid "Atta; Pamplona"
msgstr "" msgstr "Atta; Pamplona"
#. name for atu #. name for atu
msgid "Reel" msgid "Reel"
msgstr "" msgstr "Reel"
#. name for atv #. name for atv
msgid "Altai; Northern" msgid "Altai; Northern"
msgstr "" msgstr "Altai; Northern"
#. name for atw #. name for atw
msgid "Atsugewi" msgid "Atsugewi"
msgstr "" msgstr "Atsugewi"
#. name for atx #. name for atx
msgid "Arutani" msgid "Arutani"
msgstr "" msgstr "Arutani"
#. name for aty #. name for aty
msgid "Aneityum" msgid "Aneityum"
msgstr "" msgstr "Aneityum"
#. name for atz #. name for atz
msgid "Arta" msgid "Arta"
msgstr "" msgstr "Arta"
#. name for aua #. name for aua
msgid "Asumboa" msgid "Asumboa"
msgstr "" msgstr "Asumboa"
#. name for aub #. name for aub
msgid "Alugu" msgid "Alugu"
msgstr "" msgstr "Alugu"
#. name for auc #. name for auc
msgid "Waorani" msgid "Waorani"
msgstr "" msgstr "Waorani"
#. name for aud #. name for aud
msgid "Anuta" msgid "Anuta"
msgstr "" msgstr "Anuta"
#. name for aue #. name for aue
msgid "=/Kx'au//'ein" msgid "=/Kx'au//'ein"
msgstr "" msgstr "=/Kx'au//'ein"
#. name for aug #. name for aug
msgid "Aguna" msgid "Aguna"
msgstr "" msgstr "Aguna"
#. name for auh #. name for auh
msgid "Aushi" msgid "Aushi"
msgstr "" msgstr "Aushi"
#. name for aui #. name for aui
msgid "Anuki" msgid "Anuki"
msgstr "" msgstr "Anuki"
#. name for auj #. name for auj
msgid "Awjilah" msgid "Awjilah"
msgstr "" msgstr "Awjilah"
#. name for auk #. name for auk
msgid "Heyo" msgid "Heyo"
msgstr "" msgstr "Heyo"
#. name for aul #. name for aul
msgid "Aulua" msgid "Aulua"
msgstr "" msgstr "Aulua"
#. name for aum #. name for aum
msgid "Asu (Nigeria)" msgid "Asu (Nigeria)"
@ -1745,11 +1745,11 @@ msgstr "asu (Nigeria)"
#. name for aun #. name for aun
msgid "One; Molmo" msgid "One; Molmo"
msgstr "" msgstr "One; Molmo"
#. name for auo #. name for auo
msgid "Auyokawa" msgid "Auyokawa"
msgstr "" msgstr "Auyokawa"
#. name for aup #. name for aup
msgid "Makayam" msgid "Makayam"
@ -1757,19 +1757,19 @@ msgstr ""
#. name for auq #. name for auq
msgid "Anus" msgid "Anus"
msgstr "" msgstr "Anus"
#. name for aur #. name for aur
msgid "Aruek" msgid "Aruek"
msgstr "" msgstr "Aruek"
#. name for aut #. name for aut
msgid "Austral" msgid "Austral"
msgstr "" msgstr "Austral"
#. name for auu #. name for auu
msgid "Auye" msgid "Auye"
msgstr "" msgstr "Auye"
#. name for auw #. name for auw
msgid "Awyi" msgid "Awyi"
@ -1781,7 +1781,7 @@ msgstr ""
#. name for auy #. name for auy
msgid "Awiyaana" msgid "Awiyaana"
msgstr "" msgstr "Awiyaana"
#. name for auz #. name for auz
msgid "Arabic; Uzbeki" msgid "Arabic; Uzbeki"
@ -1793,11 +1793,11 @@ msgstr "awarski"
#. name for avb #. name for avb
msgid "Avau" msgid "Avau"
msgstr "" msgstr "Avau"
#. name for avd #. name for avd
msgid "Alviri-Vidari" msgid "Alviri-Vidari"
msgstr "" msgstr "Alviri-Vidari"
#. name for ave #. name for ave
msgid "Avestan" msgid "Avestan"
@ -1805,11 +1805,11 @@ msgstr "awestyjski"
#. name for avi #. name for avi
msgid "Avikam" msgid "Avikam"
msgstr "" msgstr "Avikam"
#. name for avk #. name for avk
msgid "Kotava" msgid "Kotava"
msgstr "" msgstr "Kotava"
#. name for avl #. name for avl
msgid "Arabic; Eastern Egyptian Bedawi" msgid "Arabic; Eastern Egyptian Bedawi"
@ -1817,23 +1817,23 @@ msgstr ""
#. name for avn #. name for avn
msgid "Avatime" msgid "Avatime"
msgstr "" msgstr "Avatime"
#. name for avo #. name for avo
msgid "Agavotaguerra" msgid "Agavotaguerra"
msgstr "" msgstr "Agavotaguerra"
#. name for avs #. name for avs
msgid "Aushiri" msgid "Aushiri"
msgstr "" msgstr "Aushiri"
#. name for avt #. name for avt
msgid "Au" msgid "Au"
msgstr "" msgstr "Au"
#. name for avu #. name for avu
msgid "Avokaya" msgid "Avokaya"
msgstr "" msgstr "Avokaya"
#. name for avv #. name for avv
msgid "Avá-Canoeiro" msgid "Avá-Canoeiro"
@ -1849,7 +1849,7 @@ msgstr "awa (Papua Nowa Gwinea)"
#. name for awc #. name for awc
msgid "Cicipu" msgid "Cicipu"
msgstr "" msgstr "Cicipu"
#. name for awe #. name for awe
msgid "Awetí" msgid "Awetí"
@ -1857,15 +1857,15 @@ msgstr ""
#. name for awh #. name for awh
msgid "Awbono" msgid "Awbono"
msgstr "" msgstr "Awbono"
#. name for awi #. name for awi
msgid "Aekyom" msgid "Aekyom"
msgstr "" msgstr "Aekyom"
#. name for awk #. name for awk
msgid "Awabakal" msgid "Awabakal"
msgstr "" msgstr "Awabakal"
#. name for awm #. name for awm
msgid "Arawum" msgid "Arawum"
@ -1873,31 +1873,31 @@ msgstr "arawum"
#. name for awn #. name for awn
msgid "Awngi" msgid "Awngi"
msgstr "" msgstr "Awngi"
#. name for awo #. name for awo
msgid "Awak" msgid "Awak"
msgstr "" msgstr "Awak"
#. name for awr #. name for awr
msgid "Awera" msgid "Awera"
msgstr "" msgstr "Awera"
#. name for aws #. name for aws
msgid "Awyu; South" msgid "Awyu; South"
msgstr "" msgstr "Południowy aywu"
#. name for awt #. name for awt
msgid "Araweté" msgid "Araweté"
msgstr "" msgstr "Araweté"
#. name for awu #. name for awu
msgid "Awyu; Central" msgid "Awyu; Central"
msgstr "" msgstr "Środkowy aywu"
#. name for awv #. name for awv
msgid "Awyu; Jair" msgid "Awyu; Jair"
msgstr "" msgstr "Awyu; Jair"
#. name for aww #. name for aww
msgid "Awun" msgid "Awun"
@ -1905,7 +1905,7 @@ msgstr "awun"
#. name for awx #. name for awx
msgid "Awara" msgid "Awara"
msgstr "" msgstr "Awara"
#. name for awy #. name for awy
msgid "Awyu; Edera" msgid "Awyu; Edera"
@ -1913,15 +1913,15 @@ msgstr "ederah"
#. name for axb #. name for axb
msgid "Abipon" msgid "Abipon"
msgstr "" msgstr "Abipon"
#. name for axg #. name for axg
msgid "Arára; Mato Grosso" msgid "Arára; Mato Grosso"
msgstr "" msgstr "Arára; Mato Grosso"
#. name for axk #. name for axk
msgid "Yaka (Central African Republic)" msgid "Yaka (Central African Republic)"
msgstr "" msgstr "Yaka (Central African Republic)"
#. name for axm #. name for axm
msgid "Armenian; Middle" msgid "Armenian; Middle"
@ -1929,7 +1929,7 @@ msgstr "średnioormiański"
#. name for axx #. name for axx
msgid "Xaragure" msgid "Xaragure"
msgstr "" msgstr "Xaragure"
#. name for aya #. name for aya
msgid "Awar" msgid "Awar"
@ -1937,7 +1937,7 @@ msgstr "awar"
#. name for ayb #. name for ayb
msgid "Gbe; Ayizo" msgid "Gbe; Ayizo"
msgstr "" msgstr "Gbe; Ayizo"
#. name for ayc #. name for ayc
msgid "Aymara; Southern" msgid "Aymara; Southern"
@ -1945,27 +1945,27 @@ msgstr "ajmara południowy"
#. name for ayd #. name for ayd
msgid "Ayabadhu" msgid "Ayabadhu"
msgstr "" msgstr "Ayabadhu"
#. name for aye #. name for aye
msgid "Ayere" msgid "Ayere"
msgstr "" msgstr "Ayere"
#. name for ayg #. name for ayg
msgid "Ginyanga" msgid "Ginyanga"
msgstr "" msgstr "Ginyanga"
#. name for ayh #. name for ayh
msgid "Arabic; Hadrami" msgid "Arabic; Hadrami"
msgstr "" msgstr "Arabski Hadrami"
#. name for ayi #. name for ayi
msgid "Leyigha" msgid "Leyigha"
msgstr "" msgstr "Leyigha"
#. name for ayk #. name for ayk
msgid "Akuku" msgid "Akuku"
msgstr "" msgstr "Akuku"
#. name for ayl #. name for ayl
msgid "Arabic; Libyan" msgid "Arabic; Libyan"
@ -1977,19 +1977,19 @@ msgstr "ajmara"
#. name for ayn #. name for ayn
msgid "Arabic; Sanaani" msgid "Arabic; Sanaani"
msgstr "" msgstr "Arabski Sanaani"
#. name for ayo #. name for ayo
msgid "Ayoreo" msgid "Ayoreo"
msgstr "" msgstr "Ayoreo"
#. name for ayp #. name for ayp
msgid "Arabic; North Mesopotamian" msgid "Arabic; North Mesopotamian"
msgstr "" msgstr "Arabski; Mezopotamia Północna"
#. name for ayq #. name for ayq
msgid "Ayi (Papua New Guinea)" msgid "Ayi (Papua New Guinea)"
msgstr "" msgstr "Ayi (Papua Nowa Gwinea)"
#. name for ayr #. name for ayr
msgid "Aymara; Central" msgid "Aymara; Central"
@ -1997,27 +1997,27 @@ msgstr "ajmara centralny"
#. name for ays #. name for ays
msgid "Ayta; Sorsogon" msgid "Ayta; Sorsogon"
msgstr "" msgstr "Ayta; Sorsogon"
#. name for ayt #. name for ayt
msgid "Ayta; Magbukun" msgid "Ayta; Magbukun"
msgstr "" msgstr "Ayta; Magbukun"
#. name for ayu #. name for ayu
msgid "Ayu" msgid "Ayu"
msgstr "" msgstr "Ayu"
#. name for ayy #. name for ayy
msgid "Ayta; Tayabas" msgid "Ayta; Tayabas"
msgstr "" msgstr "Ayta; Tayabas"
#. name for ayz #. name for ayz
msgid "Mai Brat" msgid "Mai Brat"
msgstr "" msgstr "Mai Brat"
#. name for aza #. name for aza
msgid "Azha" msgid "Azha"
msgstr "" msgstr "Azha"
#. name for azb #. name for azb
msgid "Azerbaijani; South" msgid "Azerbaijani; South"
@ -2029,7 +2029,7 @@ msgstr "azerski"
#. name for azg #. name for azg
msgid "Amuzgo; San Pedro Amuzgos" msgid "Amuzgo; San Pedro Amuzgos"
msgstr "" msgstr "Amuzgo; San Pedro Amuzgos"
#. name for azj #. name for azj
msgid "Azerbaijani; North" msgid "Azerbaijani; North"
@ -2037,35 +2037,35 @@ msgstr "północnoazerski"
#. name for azm #. name for azm
msgid "Amuzgo; Ipalapa" msgid "Amuzgo; Ipalapa"
msgstr "" msgstr "Amuzgo; Ipalapa"
#. name for azo #. name for azo
msgid "Awing" msgid "Awing"
msgstr "" msgstr "Awing"
#. name for azt #. name for azt
msgid "Atta; Faire" msgid "Atta; Faire"
msgstr "" msgstr "Atta; Faire"
#. name for azz #. name for azz
msgid "Nahuatl; Highland Puebla" msgid "Nahuatl; Highland Puebla"
msgstr "" msgstr "Nahuatl; Wyżyna Puebla"
#. name for baa #. name for baa
msgid "Babatana" msgid "Babatana"
msgstr "" msgstr "Babatana"
#. name for bab #. name for bab
msgid "Bainouk-Gunyuño" msgid "Bainouk-Gunyuño"
msgstr "" msgstr "Bainouk-Gunyuño"
#. name for bac #. name for bac
msgid "Badui" msgid "Badui"
msgstr "" msgstr "Badui"
#. name for bae #. name for bae
msgid "Baré" msgid "Baré"
msgstr "" msgstr "Baré"
#. name for baf #. name for baf
msgid "Nubaca" msgid "Nubaca"

File diff suppressed because it is too large Load Diff

View File

@ -13,14 +13,14 @@ msgstr ""
"Report-Msgid-Bugs-To: Debian iso-codes team <pkg-isocodes-" "Report-Msgid-Bugs-To: Debian iso-codes team <pkg-isocodes-"
"devel@lists.alioth.debian.org>\n" "devel@lists.alioth.debian.org>\n"
"POT-Creation-Date: 2011-11-25 14:01+0000\n" "POT-Creation-Date: 2011-11-25 14:01+0000\n"
"PO-Revision-Date: 2013-01-21 14:06+0000\n" "PO-Revision-Date: 2013-02-21 23:51+0000\n"
"Last-Translator: Don Miguel <bmv@mail.ru>\n" "Last-Translator: Глория Хрусталёва <gloriya@hushmail.com>\n"
"Language-Team: Russian <debian-l10n-russian@lists.debian.org>\n" "Language-Team: Russian <debian-l10n-russian@lists.debian.org>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2013-01-22 04:46+0000\n" "X-Launchpad-Export-Date: 2013-02-23 05:19+0000\n"
"X-Generator: Launchpad (build 16430)\n" "X-Generator: Launchpad (build 16506)\n"
"Language: ru\n" "Language: ru\n"
#. name for aaa #. name for aaa
@ -237,7 +237,7 @@ msgstr "Ачехский"
#. name for acf #. name for acf
msgid "Creole French; Saint Lucian" msgid "Creole French; Saint Lucian"
msgstr "" msgstr "Креольский французский; Сент-люсийский"
#. name for ach #. name for ach
msgid "Acoli" msgid "Acoli"
@ -257,7 +257,7 @@ msgstr ""
#. name for acm #. name for acm
msgid "Arabic; Mesopotamian" msgid "Arabic; Mesopotamian"
msgstr "" msgstr "Арабский; Месопатамский"
#. name for acn #. name for acn
msgid "Achang" msgid "Achang"
@ -273,7 +273,7 @@ msgstr ""
#. name for acr #. name for acr
msgid "Achi" msgid "Achi"
msgstr "" msgstr "Ачи"
#. name for acs #. name for acs
msgid "Acroá" msgid "Acroá"
@ -297,7 +297,7 @@ msgstr ""
#. name for acx #. name for acx
msgid "Arabic; Omani" msgid "Arabic; Omani"
msgstr "" msgstr "Арабский; Оманский"
#. name for acy #. name for acy
msgid "Arabic; Cypriot" msgid "Arabic; Cypriot"
@ -369,7 +369,7 @@ msgstr ""
#. name for ads #. name for ads
msgid "Adamorobe Sign Language" msgid "Adamorobe Sign Language"
msgstr "" msgstr "Знаковый язык Адаморобе"
#. name for adt #. name for adt
msgid "Adnyamathanha" msgid "Adnyamathanha"
@ -389,7 +389,7 @@ msgstr ""
#. name for ady #. name for ady
msgid "Adyghe" msgid "Adyghe"
msgstr "" msgstr "Адыгейский"
#. name for adz #. name for adz
msgid "Adzera" msgid "Adzera"
@ -401,7 +401,7 @@ msgstr ""
#. name for aeb #. name for aeb
msgid "Arabic; Tunisian" msgid "Arabic; Tunisian"
msgstr "" msgstr "Арабский; Тунисский"
#. name for aec #. name for aec
msgid "Arabic; Saidi" msgid "Arabic; Saidi"
@ -409,7 +409,7 @@ msgstr ""
#. name for aed #. name for aed
msgid "Argentine Sign Language" msgid "Argentine Sign Language"
msgstr "" msgstr "Аргентинский язык жестов"
#. name for aee #. name for aee
msgid "Pashayi; Northeast" msgid "Pashayi; Northeast"
@ -429,7 +429,7 @@ msgstr ""
#. name for aen #. name for aen
msgid "Armenian Sign Language" msgid "Armenian Sign Language"
msgstr "" msgstr "Армянский язык жестов"
#. name for aeq #. name for aeq
msgid "Aer" msgid "Aer"
@ -609,7 +609,7 @@ msgstr ""
#. name for agx #. name for agx
msgid "Aghul" msgid "Aghul"
msgstr "" msgstr "Агульский"
#. name for agy #. name for agy
msgid "Alta; Southern" msgid "Alta; Southern"
@ -665,7 +665,7 @@ msgstr ""
#. name for ahr #. name for ahr
msgid "Ahirani" msgid "Ahirani"
msgstr "" msgstr "Ахирани"
#. name for ahs #. name for ahs
msgid "Ashe" msgid "Ashe"
@ -701,7 +701,7 @@ msgstr ""
#. name for aig #. name for aig
msgid "Creole English; Antigua and Barbuda" msgid "Creole English; Antigua and Barbuda"
msgstr "" msgstr "Креольский английский; Антигуа и Барбуда"
#. name for aih #. name for aih
msgid "Ai-Cham" msgid "Ai-Cham"
@ -709,7 +709,7 @@ msgstr ""
#. name for aii #. name for aii
msgid "Neo-Aramaic; Assyrian" msgid "Neo-Aramaic; Assyrian"
msgstr "" msgstr "Новоарамейский; Ассирийский"
#. name for aij #. name for aij
msgid "Lishanid Noshan" msgid "Lishanid Noshan"
@ -825,7 +825,7 @@ msgstr ""
#. name for akg #. name for akg
msgid "Anakalangu" msgid "Anakalangu"
msgstr "" msgstr "Анакалангу"
#. name for akh #. name for akh
msgid "Angal Heneng" msgid "Angal Heneng"
@ -881,7 +881,7 @@ msgstr ""
#. name for akv #. name for akv
msgid "Akhvakh" msgid "Akhvakh"
msgstr "" msgstr "Ахвахский"
#. name for akw #. name for akw
msgid "Akwa" msgid "Akwa"
@ -897,7 +897,7 @@ msgstr ""
#. name for akz #. name for akz
msgid "Alabama" msgid "Alabama"
msgstr "" msgstr "Язык племени алабама"
#. name for ala #. name for ala
msgid "Alago" msgid "Alago"
@ -945,7 +945,7 @@ msgstr ""
#. name for aln #. name for aln
msgid "Albanian; Gheg" msgid "Albanian; Gheg"
msgstr "" msgstr "Албанский; Гегский"
#. name for alo #. name for alo
msgid "Larike-Wakasihu" msgid "Larike-Wakasihu"
@ -953,11 +953,11 @@ msgstr ""
#. name for alp #. name for alp
msgid "Alune" msgid "Alune"
msgstr "" msgstr "Алуне"
#. name for alq #. name for alq
msgid "Algonquin" msgid "Algonquin"
msgstr "" msgstr "Алгонкинский"
#. name for alr #. name for alr
msgid "Alutor" msgid "Alutor"
@ -965,7 +965,7 @@ msgstr ""
#. name for als #. name for als
msgid "Albanian; Tosk" msgid "Albanian; Tosk"
msgstr "" msgstr "Албанский; Тоскский"
#. name for alt #. name for alt
msgid "Altai; Southern" msgid "Altai; Southern"
@ -1037,7 +1037,7 @@ msgstr ""
#. name for amm #. name for amm
msgid "Ama (Papua New Guinea)" msgid "Ama (Papua New Guinea)"
msgstr "" msgstr "Ама (Папуа-Новая Гвинея)"
#. name for amn #. name for amn
msgid "Amanab" msgid "Amanab"
@ -1077,7 +1077,7 @@ msgstr ""
#. name for amw #. name for amw
msgid "Neo-Aramaic; Western" msgid "Neo-Aramaic; Western"
msgstr "" msgstr "Новоарамейский; Западный"
#. name for amx #. name for amx
msgid "Anmatyerre" msgid "Anmatyerre"
@ -1085,7 +1085,7 @@ msgstr ""
#. name for amy #. name for amy
msgid "Ami" msgid "Ami"
msgstr "" msgstr "Ами"
#. name for amz #. name for amz
msgid "Atampaya" msgid "Atampaya"
@ -1281,7 +1281,7 @@ msgstr ""
#. name for apd #. name for apd
msgid "Arabic; Sudanese" msgid "Arabic; Sudanese"
msgstr "" msgstr "Арабский; Суданский"
#. name for ape #. name for ape
msgid "Bukiyip" msgid "Bukiyip"
@ -1373,7 +1373,7 @@ msgstr ""
#. name for aqc #. name for aqc
msgid "Archi" msgid "Archi"
msgstr "" msgstr "Арчинский"
#. name for aqd #. name for aqd
msgid "Dogon; Ampari" msgid "Dogon; Ampari"
@ -1409,11 +1409,11 @@ msgstr "Арабский"
#. name for arb #. name for arb
msgid "Arabic; Standard" msgid "Arabic; Standard"
msgstr "" msgstr "Арабский; Стандартный"
#. name for arc #. name for arc
msgid "Aramaic; Official (700-300 BCE)" msgid "Aramaic; Official (700-300 BCE)"
msgstr "" msgstr "Арамейский; Официальный"
#. name for ard #. name for ard
msgid "Arabana" msgid "Arabana"
@ -1461,7 +1461,7 @@ msgstr "Арапахо"
#. name for arq #. name for arq
msgid "Arabic; Algerian" msgid "Arabic; Algerian"
msgstr "" msgstr "Арабский; Алжирский"
#. name for arr #. name for arr
msgid "Karo (Brazil)" msgid "Karo (Brazil)"
@ -1489,11 +1489,11 @@ msgstr ""
#. name for ary #. name for ary
msgid "Arabic; Moroccan" msgid "Arabic; Moroccan"
msgstr "" msgstr "Арабский; Марокканский"
#. name for arz #. name for arz
msgid "Arabic; Egyptian" msgid "Arabic; Egyptian"
msgstr "" msgstr "Арабский; Египетский"
#. name for asa #. name for asa
msgid "Asu (Tanzania)" msgid "Asu (Tanzania)"
@ -1537,7 +1537,7 @@ msgstr ""
#. name for ask #. name for ask
msgid "Ashkun" msgid "Ashkun"
msgstr "" msgstr "Ашкун"
#. name for asl #. name for asl
msgid "Asilulu" msgid "Asilulu"
@ -1573,7 +1573,7 @@ msgstr ""
#. name for ast #. name for ast
msgid "Asturian" msgid "Asturian"
msgstr "" msgstr "Астурийский"
#. name for asu #. name for asu
msgid "Asurini; Tocantins" msgid "Asurini; Tocantins"
@ -1693,7 +1693,7 @@ msgstr ""
#. name for atz #. name for atz
msgid "Arta" msgid "Arta"
msgstr "" msgstr "Арта"
#. name for aua #. name for aua
msgid "Asumboa" msgid "Asumboa"
@ -1969,7 +1969,7 @@ msgstr ""
#. name for ayl #. name for ayl
msgid "Arabic; Libyan" msgid "Arabic; Libyan"
msgstr "" msgstr "Арабский; Ливийский"
#. name for aym #. name for aym
msgid "Aymara" msgid "Aymara"
@ -1985,7 +1985,7 @@ msgstr ""
#. name for ayp #. name for ayp
msgid "Arabic; North Mesopotamian" msgid "Arabic; North Mesopotamian"
msgstr "" msgstr "Арабский; Северомесопатамский"
#. name for ayq #. name for ayq
msgid "Ayi (Papua New Guinea)" msgid "Ayi (Papua New Guinea)"
@ -2021,7 +2021,7 @@ msgstr ""
#. name for azb #. name for azb
msgid "Azerbaijani; South" msgid "Azerbaijani; South"
msgstr "" msgstr "Азербайджанский; Южный"
#. name for aze #. name for aze
msgid "Azerbaijani" msgid "Azerbaijani"
@ -2033,7 +2033,7 @@ msgstr ""
#. name for azj #. name for azj
msgid "Azerbaijani; North" msgid "Azerbaijani; North"
msgstr "" msgstr "Азербайджанский; Северный"
#. name for azm #. name for azm
msgid "Amuzgo; Ipalapa" msgid "Amuzgo; Ipalapa"
@ -2077,7 +2077,7 @@ msgstr ""
#. name for bah #. name for bah
msgid "Creole English; Bahamas" msgid "Creole English; Bahamas"
msgstr "" msgstr "Креольский английский; Багамский"
#. name for baj #. name for baj
msgid "Barakai" msgid "Barakai"
@ -2113,7 +2113,7 @@ msgstr ""
#. name for bas #. name for bas
msgid "Basa (Cameroon)" msgid "Basa (Cameroon)"
msgstr "" msgstr "Баса (Камерун)"
#. name for bau #. name for bau
msgid "Bada (Nigeria)" msgid "Bada (Nigeria)"
@ -2381,7 +2381,7 @@ msgstr ""
#. name for bdj #. name for bdj
msgid "Bai" msgid "Bai"
msgstr "" msgstr "Бай"
#. name for bdk #. name for bdk
msgid "Budukh" msgid "Budukh"
@ -2473,7 +2473,7 @@ msgstr ""
#. name for beg #. name for beg
msgid "Belait" msgid "Belait"
msgstr "" msgstr "Белайт"
#. name for beh #. name for beh
msgid "Biali" msgid "Biali"
@ -2497,7 +2497,7 @@ msgstr "Белорусский"
#. name for bem #. name for bem
msgid "Bemba (Zambia)" msgid "Bemba (Zambia)"
msgstr "" msgstr "Бемба (Замбия)"
#. name for ben #. name for ben
msgid "Bengali" msgid "Bengali"
@ -2641,7 +2641,7 @@ msgstr ""
#. name for bfy #. name for bfy
msgid "Bagheli" msgid "Bagheli"
msgstr "" msgstr "Багхели"
#. name for bfz #. name for bfz
msgid "Pahari; Mahasu" msgid "Pahari; Mahasu"
@ -2737,7 +2737,7 @@ msgstr ""
#. name for bgx #. name for bgx
msgid "Turkish; Balkan Gagauz" msgid "Turkish; Balkan Gagauz"
msgstr "" msgstr "Турецкий; Гагаузский"
#. name for bgy #. name for bgy
msgid "Benggoi" msgid "Benggoi"
@ -2753,7 +2753,7 @@ msgstr ""
#. name for bhb #. name for bhb
msgid "Bhili" msgid "Bhili"
msgstr "" msgstr "Бхили"
#. name for bhc #. name for bhc
msgid "Biga" msgid "Biga"
@ -3113,7 +3113,7 @@ msgstr ""
#. name for bku #. name for bku
msgid "Buhid" msgid "Buhid"
msgstr "" msgstr "Бухид"
#. name for bkv #. name for bkv
msgid "Bekwarra" msgid "Bekwarra"
@ -3333,7 +3333,7 @@ msgstr ""
#. name for bmy #. name for bmy
msgid "Bemba (Democratic Republic of Congo)" msgid "Bemba (Democratic Republic of Congo)"
msgstr "" msgstr "Бемба (Демократическая Республика Конго)"
#. name for bmz #. name for bmz
msgid "Baramu" msgid "Baramu"
@ -3409,7 +3409,7 @@ msgstr ""
#. name for bns #. name for bns
msgid "Bundeli" msgid "Bundeli"
msgstr "" msgstr "Бундели"
#. name for bnu #. name for bnu
msgid "Bentong" msgid "Bentong"
@ -3553,7 +3553,7 @@ msgstr ""
#. name for bph #. name for bph
msgid "Botlikh" msgid "Botlikh"
msgstr "" msgstr "Ботлихский"
#. name for bpi #. name for bpi
msgid "Bagupi" msgid "Bagupi"
@ -3613,7 +3613,7 @@ msgstr ""
#. name for bpw #. name for bpw
msgid "Bo (Papua New Guinea)" msgid "Bo (Papua New Guinea)"
msgstr "" msgstr "Бо (Папуа-Новая Гвинея)"
#. name for bpx #. name for bpx
msgid "Bareli; Palya" msgid "Bareli; Palya"
@ -3621,7 +3621,7 @@ msgstr ""
#. name for bpy #. name for bpy
msgid "Bishnupriya" msgid "Bishnupriya"
msgstr "" msgstr "Бишнуприя"
#. name for bpz #. name for bpz
msgid "Bilba" msgid "Bilba"
@ -3821,7 +3821,7 @@ msgstr ""
#. name for brx #. name for brx
msgid "Bodo (India)" msgid "Bodo (India)"
msgstr "" msgstr "Бодо (Индия)"
#. name for bry #. name for bry
msgid "Burui" msgid "Burui"
@ -3849,7 +3849,7 @@ msgstr ""
#. name for bsf #. name for bsf
msgid "Bauchi" msgid "Bauchi"
msgstr "" msgstr "Баучи"
#. name for bsg #. name for bsg
msgid "Bashkardi" msgid "Bashkardi"
@ -3857,7 +3857,7 @@ msgstr ""
#. name for bsh #. name for bsh
msgid "Kati" msgid "Kati"
msgstr "" msgstr "Кати"
#. name for bsi #. name for bsi
msgid "Bassossi" msgid "Bassossi"
@ -3869,7 +3869,7 @@ msgstr ""
#. name for bsk #. name for bsk
msgid "Burushaski" msgid "Burushaski"
msgstr "" msgstr "Бурушаски"
#. name for bsl #. name for bsl
msgid "Basa-Gumna" msgid "Basa-Gumna"
@ -4389,7 +4389,7 @@ msgstr ""
#. name for bxr #. name for bxr
msgid "Buriat; Russia" msgid "Buriat; Russia"
msgstr "" msgstr "Бурятский; Россия"
#. name for bxs #. name for bxs
msgid "Busam" msgid "Busam"
@ -4553,11 +4553,11 @@ msgstr ""
#. name for bzj #. name for bzj
msgid "Kriol English; Belize" msgid "Kriol English; Belize"
msgstr "" msgstr "Креольский английский; Белиз"
#. name for bzk #. name for bzk
msgid "Creole English; Nicaragua" msgid "Creole English; Nicaragua"
msgstr "" msgstr "Креольский английский; Никарагуа"
#. name for bzl #. name for bzl
msgid "Boano (Sulawesi)" msgid "Boano (Sulawesi)"
@ -5001,7 +5001,7 @@ msgstr ""
#. name for chm #. name for chm
msgid "Mari (Russia)" msgid "Mari (Russia)"
msgstr "" msgstr "Марийский (Россия)"
#. name for chn #. name for chn
msgid "Chinook jargon" msgid "Chinook jargon"
@ -5285,7 +5285,7 @@ msgstr ""
#. name for cmn #. name for cmn
msgid "Chinese; Mandarin" msgid "Chinese; Mandarin"
msgstr "" msgstr "Китайский; Мандарин"
#. name for cmo #. name for cmo
msgid "Mnong; Central" msgid "Mnong; Central"
@ -7581,7 +7581,7 @@ msgstr ""
#. name for fij #. name for fij
msgid "Fijian" msgid "Fijian"
msgstr "Фиджи" msgstr "Фиджийский"
#. name for fil #. name for fil
msgid "Filipino" msgid "Filipino"
@ -8037,11 +8037,11 @@ msgstr ""
#. name for gcf #. name for gcf
msgid "Creole French; Guadeloupean" msgid "Creole French; Guadeloupean"
msgstr "" msgstr "Креольский французский; Гваделупский"
#. name for gcl #. name for gcl
msgid "Creole English; Grenadian" msgid "Creole English; Grenadian"
msgstr "" msgstr "Креольский английский; Гренадский"
#. name for gcn #. name for gcn
msgid "Gaina" msgid "Gaina"
@ -8049,7 +8049,7 @@ msgstr ""
#. name for gcr #. name for gcr
msgid "Creole French; Guianese" msgid "Creole French; Guianese"
msgstr "" msgstr "Креольский французский; Гвианский"
#. name for gct #. name for gct
msgid "German; Colonia Tovar" msgid "German; Colonia Tovar"
@ -9089,7 +9089,7 @@ msgstr ""
#. name for gyn #. name for gyn
msgid "Creole English; Guyanese" msgid "Creole English; Guyanese"
msgstr "" msgstr "Креольский английский; Гайянский"
#. name for gyr #. name for gyr
msgid "Guarayu" msgid "Guarayu"
@ -9853,7 +9853,7 @@ msgstr ""
#. name for hwc #. name for hwc
msgid "Creole English; Hawai'i" msgid "Creole English; Hawai'i"
msgstr "" msgstr "Креольский английский; Гавайский"
#. name for hwo #. name for hwo
msgid "Hwana" msgid "Hwana"
@ -10577,7 +10577,7 @@ msgstr ""
#. name for jam #. name for jam
msgid "Creole English; Jamaican" msgid "Creole English; Jamaican"
msgstr "" msgstr "Креольский английский; Ямайский"
#. name for jao #. name for jao
msgid "Yanyuwa" msgid "Yanyuwa"
@ -14245,7 +14245,7 @@ msgstr ""
#. name for lir #. name for lir
msgid "English; Liberian" msgid "English; Liberian"
msgstr "" msgstr "Креольский английский; Либерийский"
#. name for lis #. name for lis
msgid "Lisu" msgid "Lisu"
@ -14661,7 +14661,7 @@ msgstr ""
#. name for lou #. name for lou
msgid "Creole French; Louisiana" msgid "Creole French; Louisiana"
msgstr "" msgstr "Креольский французский; Луизиана"
#. name for lov #. name for lov
msgid "Lopi" msgid "Lopi"
@ -15021,7 +15021,7 @@ msgstr ""
#. name for lzz #. name for lzz
msgid "Laz" msgid "Laz"
msgstr "" msgstr "Лазский"
#. name for maa #. name for maa
msgid "Mazatec; San Jerónimo Tecóatl" msgid "Mazatec; San Jerónimo Tecóatl"
@ -15337,7 +15337,7 @@ msgstr ""
#. name for mdf #. name for mdf
msgid "Moksha" msgid "Moksha"
msgstr "Мокша" msgstr "Мокшанский"
#. name for mdg #. name for mdg
msgid "Massalat" msgid "Massalat"
@ -19993,7 +19993,7 @@ msgstr ""
#. name for orv #. name for orv
msgid "Russian; Old" msgid "Russian; Old"
msgstr "" msgstr "Древнерусский"
#. name for orw #. name for orw
msgid "Oro Win" msgid "Oro Win"
@ -20109,7 +20109,7 @@ msgstr ""
#. name for oty #. name for oty
msgid "Tamil; Old" msgid "Tamil; Old"
msgstr "" msgstr "Древнетамильский"
#. name for otz #. name for otz
msgid "Otomi; Ixtenco" msgid "Otomi; Ixtenco"
@ -21897,7 +21897,7 @@ msgstr ""
#. name for rcf #. name for rcf
msgid "Creole French; Réunion" msgid "Creole French; Réunion"
msgstr "" msgstr "Креольский французский; Реюньон"
#. name for rdb #. name for rdb
msgid "Rudbari" msgid "Rudbari"
@ -23081,7 +23081,7 @@ msgstr ""
#. name for sin #. name for sin
msgid "Sinhala" msgid "Sinhala"
msgstr "" msgstr "Сингальский"
#. name for sip #. name for sip
msgid "Sikkimese" msgid "Sikkimese"
@ -24661,7 +24661,7 @@ msgstr ""
#. name for tch #. name for tch
msgid "Creole English; Turks And Caicos" msgid "Creole English; Turks And Caicos"
msgstr "" msgstr "Креольский английский; Тёркс и Кайкос"
#. name for tci #. name for tci
msgid "Wára" msgid "Wára"
@ -24957,7 +24957,7 @@ msgstr ""
#. name for tgh #. name for tgh
msgid "Creole English; Tobagonian" msgid "Creole English; Tobagonian"
msgstr "" msgstr "Креольский английский; Тобагский"
#. name for tgi #. name for tgi
msgid "Lawunuia" msgid "Lawunuia"
@ -25401,7 +25401,7 @@ msgstr ""
#. name for tly #. name for tly
msgid "Talysh" msgid "Talysh"
msgstr "" msgstr "Талышский"
#. name for tma #. name for tma
msgid "Tama (Chad)" msgid "Tama (Chad)"
@ -25845,7 +25845,7 @@ msgstr ""
#. name for trf #. name for trf
msgid "Creole English; Trinidadian" msgid "Creole English; Trinidadian"
msgstr "" msgstr "Креольский английский; Тринидадский"
#. name for trg #. name for trg
msgid "Lishán Didán" msgid "Lishán Didán"
@ -27121,7 +27121,7 @@ msgstr ""
#. name for vic #. name for vic
msgid "Creole English; Virgin Islands" msgid "Creole English; Virgin Islands"
msgstr "" msgstr "Креольский английский; Виргинские острова"
#. name for vid #. name for vid
msgid "Vidunda" msgid "Vidunda"
@ -28209,7 +28209,7 @@ msgstr ""
#. name for wyy #. name for wyy
msgid "Fijian; Western" msgid "Fijian; Western"
msgstr "" msgstr "Западнофиджийский"
#. name for xaa #. name for xaa
msgid "Arabic; Andalusian" msgid "Arabic; Andalusian"

View File

@ -4,7 +4,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
__appname__ = u'calibre' __appname__ = u'calibre'
numeric_version = (0, 9, 20) numeric_version = (0, 9, 21)
__version__ = u'.'.join(map(unicode, numeric_version)) __version__ = u'.'.join(map(unicode, numeric_version))
__author__ = u"Kovid Goyal <kovid@kovidgoyal.net>" __author__ = u"Kovid Goyal <kovid@kovidgoyal.net>"

View File

@ -19,6 +19,7 @@ from calibre.db.errors import NoSuchFormat
from calibre.db.fields import create_field from calibre.db.fields import create_field
from calibre.db.search import Search from calibre.db.search import Search
from calibre.db.tables import VirtualTable from calibre.db.tables import VirtualTable
from calibre.db.write import get_series_values
from calibre.db.lazy import FormatMetadata, FormatsList from calibre.db.lazy import FormatMetadata, FormatsList
from calibre.ebooks.metadata.book.base import Metadata from calibre.ebooks.metadata.book.base import Metadata
from calibre.ptempfile import (base_dir, PersistentTemporaryFile, from calibre.ptempfile import (base_dir, PersistentTemporaryFile,
@ -618,8 +619,31 @@ class Cache(object):
def set_field(self, name, book_id_to_val_map, allow_case_change=True): def set_field(self, name, book_id_to_val_map, allow_case_change=True):
# TODO: Specialize title/authors to also update path # TODO: Specialize title/authors to also update path
# TODO: Handle updating caches used by composite fields # TODO: Handle updating caches used by composite fields
dirtied = self.fields[name].writer.set_books( # TODO: Ensure the sort fields are updated for title/author/series?
f = self.fields[name]
is_series = f.metadata['datatype'] == 'series'
if is_series:
bimap, simap = {}, {}
for k, v in book_id_to_val_map.iteritems():
if isinstance(v, basestring):
v, sid = get_series_values(v)
else:
v = sid = None
if name.startswith('#') and sid is None:
sid = 1.0 # The value will be set to 1.0 in the db table
bimap[k] = v
if sid is not None:
simap[k] = sid
book_id_to_val_map = bimap
dirtied = f.writer.set_books(
book_id_to_val_map, self.backend, allow_case_change=allow_case_change) book_id_to_val_map, self.backend, allow_case_change=allow_case_change)
if is_series and simap:
sf = self.fields[f.name+'_index']
dirtied |= sf.writer.set_books(simap, self.backend, allow_case_change=False)
return dirtied return dirtied
# }}} # }}}

View File

@ -22,6 +22,7 @@ from calibre.utils.localization import calibre_langcode_to_name
class Field(object): class Field(object):
is_many = False is_many = False
is_many_many = False
def __init__(self, name, table): def __init__(self, name, table):
self.name, self.table = name, table self.name, self.table = name, table
@ -299,6 +300,7 @@ class ManyToOneField(Field):
class ManyToManyField(Field): class ManyToManyField(Field):
is_many = True is_many = True
is_many_many = True
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
Field.__init__(self, *args, **kwargs) Field.__init__(self, *args, **kwargs)

View File

@ -123,9 +123,8 @@ class ManyToOneTable(Table):
def read_id_maps(self, db): def read_id_maps(self, db):
for row in db.conn.execute('SELECT id, {0} FROM {1}'.format( for row in db.conn.execute('SELECT id, {0} FROM {1}'.format(
self.metadata['column'], self.metadata['table'])): self.metadata['column'], self.metadata['table'])):
if row[1]: self.id_map[row[0]] = self.unserialize(row[1])
self.id_map[row[0]] = self.unserialize(row[1])
def read_maps(self, db): def read_maps(self, db):
for row in db.conn.execute( for row in db.conn.execute(
@ -218,3 +217,4 @@ class LanguagesTable(ManyToManyTable):
ManyToManyTable.read_id_maps(self, db) ManyToManyTable.read_id_maps(self, db)
lm = lang_map() lm = lang_map()
self.lang_name_map = {x:lm.get(x, x) for x in self.id_map.itervalues()} self.lang_name_map = {x:lm.get(x, x) for x in self.id_map.itervalues()}

View File

@ -75,7 +75,7 @@ class WritingTest(BaseTest):
test.name, old_sqlite_res, sqlite_res)) test.name, old_sqlite_res, sqlite_res))
del db del db
def test_one_one(self): def test_one_one(self): # {{{
'Test setting of values in one-one fields' 'Test setting of values in one-one fields'
tests = [self.create_test('#yesno', (True, False, 'true', 'false', None))] tests = [self.create_test('#yesno', (True, False, 'true', 'false', None))]
for name, getter, setter in ( for name, getter, setter in (
@ -114,6 +114,96 @@ class WritingTest(BaseTest):
tests.append(self.create_test(name, tuple(vals), getter, setter)) tests.append(self.create_test(name, tuple(vals), getter, setter))
self.run_tests(tests) self.run_tests(tests)
# }}}
def test_many_one_basic(self): # {{{
'Test the different code paths for writing to a many-one field'
cl = self.cloned_library
cache = self.init_cache(cl)
f = cache.fields['publisher']
item_ids = {f.ids_for_book(1)[0], f.ids_for_book(2)[0]}
val = 'Changed'
self.assertEqual(cache.set_field('publisher', {1:val, 2:val}), {1, 2})
cache2 = self.init_cache(cl)
for book_id in (1, 2):
for c in (cache, cache2):
self.assertEqual(c.field_for('publisher', book_id), val)
self.assertFalse(item_ids.intersection(set(c.fields['publisher'].table.id_map)))
del cache2
self.assertFalse(cache.set_field('publisher', {1:val, 2:val}))
val = val.lower()
self.assertFalse(cache.set_field('publisher', {1:val, 2:val},
allow_case_change=False))
self.assertEqual(cache.set_field('publisher', {1:val, 2:val}), {1, 2})
cache2 = self.init_cache(cl)
for book_id in (1, 2):
for c in (cache, cache2):
self.assertEqual(c.field_for('publisher', book_id), val)
del cache2
self.assertEqual(cache.set_field('publisher', {1:'new', 2:'New'}), {1, 2})
self.assertEqual(cache.field_for('publisher', 1).lower(), 'new')
self.assertEqual(cache.field_for('publisher', 2).lower(), 'new')
self.assertEqual(cache.set_field('publisher', {1:None, 2:'NEW'}), {1, 2})
self.assertEqual(len(f.table.id_map), 1)
self.assertEqual(cache.set_field('publisher', {2:None}), {2})
self.assertEqual(len(f.table.id_map), 0)
cache2 = self.init_cache(cl)
self.assertEqual(len(cache2.fields['publisher'].table.id_map), 0)
del cache2
self.assertEqual(cache.set_field('publisher', {1:'one', 2:'two',
3:'three'}), {1, 2, 3})
self.assertEqual(cache.set_field('publisher', {1:''}), set([1]))
self.assertEqual(cache.set_field('publisher', {1:'two'}), set([1]))
self.assertEqual(tuple(map(f.for_book, (1,2,3))), ('two', 'two', 'three'))
self.assertEqual(cache.set_field('publisher', {1:'Two'}), {1, 2})
cache2 = self.init_cache(cl)
self.assertEqual(tuple(map(f.for_book, (1,2,3))), ('Two', 'Two', 'three'))
del cache2
# Enum
self.assertFalse(cache.set_field('#enum', {1:'Not allowed'}))
self.assertEqual(cache.set_field('#enum', {1:'One', 2:'One', 3:'Three'}), {1, 3})
self.assertEqual(cache.set_field('#enum', {1:None}), set([1]))
cache2 = self.init_cache(cl)
for c in (cache, cache2):
for i, val in {1:None, 2:'One', 3:'Three'}.iteritems():
self.assertEqual(c.field_for('#enum', i), val)
del cache2
# Rating
self.assertFalse(cache.set_field('rating', {1:6, 2:4}))
self.assertEqual(cache.set_field('rating', {1:0, 3:2}), {1, 3})
self.assertEqual(cache.set_field('#rating', {1:None, 2:4, 3:8}), {1, 2, 3})
cache2 = self.init_cache(cl)
for c in (cache, cache2):
for i, val in {1:None, 2:4, 3:2}.iteritems():
self.assertEqual(c.field_for('rating', i), val)
for i, val in {1:None, 2:4, 3:8}.iteritems():
self.assertEqual(c.field_for('#rating', i), val)
del cache2
# Series
self.assertFalse(cache.set_field('series',
{1:'a series one', 2:'a series one'}, allow_case_change=False))
self.assertEqual(cache.set_field('series', {3:'Series [3]'}), set([3]))
self.assertEqual(cache.set_field('#series', {1:'Series', 3:'Series'}),
{1, 3})
self.assertEqual(cache.set_field('#series', {2:'Series [0]'}), set([2]))
cache2 = self.init_cache(cl)
for c in (cache, cache2):
for i, val in {1:'A Series One', 2:'A Series One', 3:'Series'}.iteritems():
self.assertEqual(c.field_for('series', i), val)
for i in (1, 2, 3):
self.assertEqual(c.field_for('#series', i), 'Series')
for i, val in {1:2, 2:1, 3:3}.iteritems():
self.assertEqual(c.field_for('series_index', i), val)
for i, val in {1:1, 2:0, 3:1}.iteritems():
self.assertEqual(c.field_for('#series_index', i), val)
del cache2
# }}}
def tests(): def tests():
return unittest.TestLoader().loadTestsFromTestCase(WritingTest) return unittest.TestLoader().loadTestsFromTestCase(WritingTest)

View File

@ -7,6 +7,7 @@ __license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>' __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import re
from functools import partial from functools import partial
from datetime import datetime from datetime import datetime
@ -29,6 +30,21 @@ def single_text(x):
x = x.strip() x = x.strip()
return x if x else None return x if x else None
series_index_pat = re.compile(r'(.*)\s+\[([.0-9]+)\]$')
def get_series_values(val):
if not val:
return (val, None)
match = series_index_pat.match(val.strip())
if match is not None:
idx = match.group(2)
try:
idx = float(idx)
return (match.group(1).strip(), idx)
except:
pass
return (val, None)
def multiple_text(sep, x): def multiple_text(sep, x):
if x is None: if x is None:
return () return ()
@ -92,7 +108,7 @@ def get_adapter(name, metadata):
elif dt == 'comments': elif dt == 'comments':
ans = single_text ans = single_text
elif dt == 'rating': elif dt == 'rating':
ans = lambda x: x if x is None else min(10., max(0., adapt_number(float, x))), ans = lambda x: None if x in {None, 0} else min(10., max(0., adapt_number(float, x)))
elif dt == 'enumeration': elif dt == 'enumeration':
ans = single_text ans = single_text
elif dt == 'composite': elif dt == 'composite':
@ -128,8 +144,8 @@ def one_one_in_other(book_id_val_map, db, field, *args):
if deleted: if deleted:
db.conn.executemany('DELETE FROM %s WHERE book=?'%field.metadata['table'], db.conn.executemany('DELETE FROM %s WHERE book=?'%field.metadata['table'],
deleted) deleted)
for book_id in book_id_val_map: for book_id in deleted:
field.table.book_col_map.pop(book_id, None) field.table.book_col_map.pop(book_id[0], None)
updated = {k:v for k, v in book_id_val_map.iteritems() if v is not None} updated = {k:v for k, v in book_id_val_map.iteritems() if v is not None}
if updated: if updated:
db.conn.executemany('INSERT OR REPLACE INTO %s(book,%s) VALUES (?,?)'%( db.conn.executemany('INSERT OR REPLACE INTO %s(book,%s) VALUES (?,?)'%(
@ -151,7 +167,131 @@ def custom_series_index(book_id_val_map, db, field, *args):
if sequence: if sequence:
db.conn.executemany('UPDATE %s SET %s=? WHERE book=? AND value=?'%( db.conn.executemany('UPDATE %s SET %s=? WHERE book=? AND value=?'%(
field.metadata['table'], field.metadata['column']), sequence) field.metadata['table'], field.metadata['column']), sequence)
return {s[0] for s in sequence} return {s[1] for s in sequence}
# }}}
# Many-One fields {{{
def safe_lower(x):
try:
return icu_lower(x)
except (TypeError, ValueError, KeyError, AttributeError):
return x
def many_one(book_id_val_map, db, field, allow_case_change, *args):
dirtied = set()
m = field.metadata
table = field.table
dt = m['datatype']
is_custom_series = dt == 'series' and table.name.startswith('#')
# Map values to their canonical form for later comparison
kmap = safe_lower if dt in {'text', 'series'} else lambda x:x
# Ignore those items whose value is the same as the current value
no_changes = {k:nval for k, nval in book_id_val_map.iteritems() if
kmap(nval) == kmap(field.for_book(k, default_value=None))}
for book_id in no_changes:
del book_id_val_map[book_id]
# If we are allowed case changes check that none of the ignored items are
# case changes. If they are, update the item's case in the db.
if allow_case_change:
for book_id, nval in no_changes.iteritems():
if nval is not None and nval != field.for_book(
book_id, default_value=None):
# Change of case
item_id = table.book_col_map[book_id]
db.conn.execute('UPDATE %s SET %s=? WHERE id=?'%(
m['table'], m['column']), (nval, item_id))
table.id_map[item_id] = nval
dirtied |= table.col_book_map[item_id]
deleted = {k:v for k, v in book_id_val_map.iteritems() if v is None}
updated = {k:v for k, v in book_id_val_map.iteritems() if v is not None}
link_table = table.link_table
if deleted:
db.conn.executemany('DELETE FROM %s WHERE book=?'%link_table,
tuple((book_id,) for book_id in deleted))
for book_id in deleted:
item_id = table.book_col_map.pop(book_id, None)
if item_id is not None:
table.col_book_map[item_id].discard(book_id)
dirtied |= set(deleted)
if updated:
rid_map = {kmap(v):k for k, v in table.id_map.iteritems()}
book_id_item_id_map = {k:rid_map.get(kmap(v), None) for k, v in
book_id_val_map.iteritems()}
# items that dont yet exist
new_items = {k:v for k, v in updated.iteritems() if
book_id_item_id_map[k] is None}
# items that already exist
changed_items = {k:book_id_item_id_map[k] for k in updated if
book_id_item_id_map[k] is not None}
def sql_update(imap):
sql = (
'DELETE FROM {0} WHERE book=?; INSERT INTO {0}(book,{1},extra) VALUES(?, ?, 1.0)'
if is_custom_series else
'DELETE FROM {0} WHERE book=?; INSERT INTO {0}(book,{1}) VALUES(?, ?)'
)
db.conn.executemany(sql.format(link_table, m['link_column']),
tuple((book_id, book_id, item_id) for book_id, item_id in
imap.iteritems()))
if new_items:
item_ids = {}
val_map = {}
for val in set(new_items.itervalues()):
lval = kmap(val)
if lval in val_map:
item_id = val_map[lval]
else:
db.conn.execute('INSERT INTO %s(%s) VALUES (?)'%(
m['table'], m['column']), (val,))
item_id = val_map[lval] = db.conn.last_insert_rowid()
item_ids[val] = item_id
table.id_map[item_id] = val
imap = {}
for book_id, val in new_items.iteritems():
item_id = item_ids[val]
old_item_id = table.book_col_map.get(book_id, None)
if old_item_id is not None:
table.col_book_map[old_item_id].discard(book_id)
if item_id not in table.col_book_map:
table.col_book_map[item_id] = set()
table.col_book_map[item_id].add(book_id)
table.book_col_map[book_id] = imap[book_id] = item_id
sql_update(imap)
dirtied |= set(imap)
if changed_items:
imap = {}
sql_update(changed_items)
for book_id, item_id in changed_items.iteritems():
old_item_id = table.book_col_map.get(book_id, None)
if old_item_id != item_id:
table.book_col_map[book_id] = item_id
table.col_book_map[item_id].add(book_id)
if old_item_id is not None:
table.col_book_map[old_item_id].discard(book_id)
imap[book_id] = item_id
sql_update(imap)
dirtied |= set(imap)
# Remove no longer used items
remove = {item_id for item_id in table.id_map if not
table.col_book_map.get(item_id, False)}
if remove:
db.conn.executemany('DELETE FROM %s WHERE id=?'%m['table'],
tuple((item_id,) for item_id in remove))
for item_id in remove:
del table.id_map[item_id]
table.col_book_map.pop(item_id, None)
return dirtied
# }}} # }}}
def dummy(book_id_val_map, *args): def dummy(book_id_val_map, *args):
@ -170,10 +310,13 @@ class Writer(object):
self.set_books_func = dummy self.set_books_func = dummy
elif self.name[0] == '#' and self.name.endswith('_index'): elif self.name[0] == '#' and self.name.endswith('_index'):
self.set_books_func = custom_series_index self.set_books_func = custom_series_index
elif field.is_many: elif field.is_many_many:
# TODO: Implement this # TODO: Implement this
pass pass
# TODO: Remember to change commas to | when writing authors to sqlite # TODO: Remember to change commas to | when writing authors to sqlite
elif field.is_many:
self.set_books_func = (self.set_books_for_enum if dt ==
'enumeration' else many_one)
else: else:
self.set_books_func = (one_one_in_books if field.metadata['table'] self.set_books_func = (one_one_in_books if field.metadata['table']
== 'books' else one_one_in_other) == 'books' else one_one_in_other)
@ -185,6 +328,17 @@ class Writer(object):
book_id_val_map.iteritems() if self.accept_vals(v)} book_id_val_map.iteritems() if self.accept_vals(v)}
if not book_id_val_map: if not book_id_val_map:
return set() return set()
dirtied = self.set_books_func(book_id_val_map, db, self.field) dirtied = self.set_books_func(book_id_val_map, db, self.field,
allow_case_change)
return dirtied return dirtied
def set_books_for_enum(self, book_id_val_map, db, field,
allow_case_change):
allowed = set(field.metadata['display']['enum_values'])
book_id_val_map = {k:v for k, v in book_id_val_map.iteritems() if v is
None or v in allowed}
if not book_id_val_map:
return set()
return many_one(book_id_val_map, db, field, False)

View File

@ -23,12 +23,11 @@ It also contains interfaces to various bits of calibre that do not have
dedicated command line tools, such as font subsetting, tweaking ebooks and so dedicated command line tools, such as font subsetting, tweaking ebooks and so
on. on.
''') ''')
parser.add_option('-c', '--command', help='Run python code.', default=None) parser.add_option('-c', '--command', help='Run python code.')
parser.add_option('-e', '--exec-file', default=None, help='Run the python code in file.') parser.add_option('-e', '--exec-file', help='Run the python code in file.')
parser.add_option('-f', '--subset-font', default=False, parser.add_option('-f', '--subset-font', help='Subset the specified font')
action='store_true', help='Subset the specified font')
parser.add_option('-d', '--debug-device-driver', default=False, action='store_true', parser.add_option('-d', '--debug-device-driver', default=False, action='store_true',
help='Debug the specified device driver.') help='Debug device detection')
parser.add_option('-g', '--gui', default=False, action='store_true', parser.add_option('-g', '--gui', default=False, action='store_true',
help='Run the GUI with debugging enabled. Debug output is ' help='Run the GUI with debugging enabled. Debug output is '
'printed to stdout and stderr.') 'printed to stdout and stderr.')
@ -59,7 +58,7 @@ on.
parser.add_option('-m', '--inspect-mobi', action='store_true', parser.add_option('-m', '--inspect-mobi', action='store_true',
default=False, default=False,
help='Inspect the MOBI file(s) at the specified path(s)') help='Inspect the MOBI file(s) at the specified path(s)')
parser.add_option('--tweak-book', default=None, parser.add_option('-t', '--tweak-book', default=None,
help='Tweak the book (exports the book as a collection of HTML ' help='Tweak the book (exports the book as a collection of HTML '
'files and metadata, which you can edit using standard HTML ' 'files and metadata, which you can edit using standard HTML '
'editing tools, and then rebuilds the file from the edited HTML. ' 'editing tools, and then rebuilds the file from the edited HTML. '
@ -174,30 +173,24 @@ def run_debug_gui(logpath):
from calibre.gui2.main import main from calibre.gui2.main import main
main(['__CALIBRE_GUI_DEBUG__', logpath]) main(['__CALIBRE_GUI_DEBUG__', logpath])
def run_script(path, args):
# Load all user defined plugins so the script can import from the
# calibre_plugins namespace
import calibre.customize.ui as dummy
dummy
sys.argv = [path] + args
ef = os.path.abspath(path)
base = os.path.dirname(ef)
sys.path.insert(0, base)
g = globals()
g['__name__'] = '__main__'
g['__file__'] = ef
execfile(ef, g)
def main(args=sys.argv): def main(args=sys.argv):
from calibre.constants import debug from calibre.constants import debug
debug() debug()
if len(args) > 2 and args[1] in ('-e', '--exec-file'):
# Load all plugins user defined plugins so the script can import from the
# calibre_plugins namespace
import calibre.customize.ui as dummy
dummy
sys.argv = [args[2]] + args[3:]
ef = os.path.abspath(args[2])
base = os.path.dirname(ef)
sys.path.insert(0, base)
g = globals()
g['__name__'] = '__main__'
g['__file__'] = ef
execfile(ef, g)
return
if len(args) > 1 and args[1] in ('-f', '--subset-font'):
from calibre.utils.fonts.sfnt.subset import main
main(['subset-font']+args[2:])
return
opts, args = option_parser().parse_args(args) opts, args = option_parser().parse_args(args)
if opts.gui: if opts.gui:
@ -258,6 +251,13 @@ def main(args=sys.argv):
elif opts.shutdown_running_calibre: elif opts.shutdown_running_calibre:
from calibre.gui2.main import shutdown_other from calibre.gui2.main import shutdown_other
shutdown_other() shutdown_other()
elif opts.subset_font:
from calibre.utils.fonts.sfnt.subset import main
main(['subset-font']+[opts.subset_font]+args[1:])
elif opts.exec_file:
run_script(opts.exec_file, args[1:])
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}:
run_script(args[1], args[2:])
else: else:
from calibre import ipython from calibre import ipython
ipython() ipython()

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai # vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import division
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2010-2012, Timothy Legge <timlegge@gmail.com>, Kovid Goyal <kovid@kovidgoyal.net> and David Forrester <davidfor@internode.on.net>' __copyright__ = '2010-2012, Timothy Legge <timlegge@gmail.com>, Kovid Goyal <kovid@kovidgoyal.net> and David Forrester <davidfor@internode.on.net>'
@ -13,6 +14,7 @@ Extended to support Touch firmware 2.0.0 and later and newer devices by David Fo
''' '''
import os, time import os, time
from contextlib import closing from contextlib import closing
from calibre.devices.usbms.books import BookList from calibre.devices.usbms.books import BookList
from calibre.devices.usbms.books import CollectionsBookList from calibre.devices.usbms.books import CollectionsBookList
@ -33,7 +35,7 @@ class KOBO(USBMS):
gui_name = 'Kobo Reader' gui_name = 'Kobo Reader'
description = _('Communicate with the Kobo Reader') description = _('Communicate with the Kobo Reader')
author = 'Timothy Legge and David Forrester' author = 'Timothy Legge and David Forrester'
version = (2, 0, 5) version = (2, 0, 6)
dbversion = 0 dbversion = 0
fwversion = 0 fwversion = 0
@ -1196,10 +1198,11 @@ class KOBO(USBMS):
class KOBOTOUCH(KOBO): class KOBOTOUCH(KOBO):
name = 'KoboTouch' name = 'KoboTouch'
gui_name = 'Kobo Touch' gui_name = 'Kobo Touch'
author = 'David Forrester' author = 'David Forrester'
description = 'Communicate with the Kobo Touch, Glo and Mini firmware. Based on the existing Kobo driver by %s.' % (KOBO.author) description = 'Communicate with the Kobo Touch, Glo and Mini firmware. Based on the existing Kobo driver by %s.' % (KOBO.author)
# icon = I('devices/kobotouch.jpg')
supported_dbversion = 75 supported_dbversion = 75
min_supported_dbversion = 53 min_supported_dbversion = 53
@ -1219,14 +1222,11 @@ class KOBOTOUCH(KOBO):
_('Delete Empty Bookshelves') + _('Delete Empty Bookshelves') +
':::'+_('Delete any empty bookshelves from the Kobo Touch when syncing is finished. This is only for firmware V2.0.0 or later.'), ':::'+_('Delete any empty bookshelves from the Kobo Touch when syncing is finished. This is only for firmware V2.0.0 or later.'),
_('Upload covers for books') + _('Upload covers for books') +
':::'+_('Normally, the KOBO readers get the cover image from the' ':::'+_('Upload cover images from the calibre library when sending books to the device.'),
' ebook file itself. With this option, calibre will send a '
'separate cover image to the reader, useful if you '
'have modified the cover.'),
_('Upload Black and White Covers'), _('Upload Black and White Covers'),
_('Always upload covers') + _('Keep cover aspect ratio') +
':::'+_('If the Upload covers option is selected, the driver will only replace covers already on the device.' ':::'+_('When uploading covers, do not change the aspect ratio when resizing for the device.'
' Select this option if you want covers uploaded the first time you send the book to the device.'), ' This is for firmware versions 2.3.1 and later.'),
_('Show expired books') + _('Show expired books') +
':::'+_('A bug in an earlier version left non kepubs book records' ':::'+_('A bug in an earlier version left non kepubs book records'
' in the database. With this option Calibre will show the ' ' in the database. With this option Calibre will show the '
@ -1278,7 +1278,7 @@ class KOBOTOUCH(KOBO):
OPT_DELETE_BOOKSHELVES = 2 OPT_DELETE_BOOKSHELVES = 2
OPT_UPLOAD_COVERS = 3 OPT_UPLOAD_COVERS = 3
OPT_UPLOAD_GRAYSCALE_COVERS = 4 OPT_UPLOAD_GRAYSCALE_COVERS = 4
OPT_ALWAYS_UPLOAD_COVERS = 5 OPT_KEEP_COVER_ASPECT_RATIO = 5
OPT_SHOW_EXPIRED_BOOK_RECORDS = 6 OPT_SHOW_EXPIRED_BOOK_RECORDS = 6
OPT_SHOW_PREVIEWS = 7 OPT_SHOW_PREVIEWS = 7
OPT_SHOW_RECOMMENDATIONS = 8 OPT_SHOW_RECOMMENDATIONS = 8
@ -1290,16 +1290,27 @@ class KOBOTOUCH(KOBO):
TIMESTAMP_STRING = "%Y-%m-%dT%H:%M:%SZ" TIMESTAMP_STRING = "%Y-%m-%dT%H:%M:%SZ"
PRODUCT_ID = [0x4163, 0x4173, 0x4183] GLO_PRODUCT_ID = [0x4173]
BCD = [0x0110, 0x0326] MINI_PRODUCT_ID = [0x4183]
TOUCH_PRODUCT_ID = [0x4163]
PRODUCT_ID = GLO_PRODUCT_ID + MINI_PRODUCT_ID + TOUCH_PRODUCT_ID
BCD = [0x0110, 0x0326]
# Image file name endings. Made up of: image size, min_dbversion, max_dbversion, # Image file name endings. Made up of: image size, min_dbversion, max_dbversion,
COVER_FILE_ENDINGS = { COVER_FILE_ENDINGS = {
' - N3_LIBRARY_FULL.parsed':[(355,473),0, 99,], # Used for Details screen ' - N3_FULL.parsed':[(600,800),0, 99,True,], # Used for screensaver, home screen
' - N3_LIBRARY_GRID.parsed':[(149,198),0, 99,], # Used for library lists ' - N3_LIBRARY_FULL.parsed':[(355,473),0, 99,False,], # Used for Details screen
' - N3_LIBRARY_LIST.parsed':[(60,90),0, 53,], ' - N3_LIBRARY_GRID.parsed':[(149,198),0, 99,False,], # Used for library lists
' - N3_LIBRARY_LIST.parsed':[(60,90),0, 53,False,],
# ' - N3_LIBRARY_SHELF.parsed': [(40,60),0, 52,],
}
GLO_COVER_FILE_ENDINGS = {
' - N3_FULL.parsed':[(758,1024),0, 99,True,], # Used for screensaver, home screen
' - N3_LIBRARY_FULL.parsed':[(355,479),0, 99,False,], # Used for Details screen
' - N3_LIBRARY_GRID.parsed':[(149,201),0, 99,False,], # Used for library lists
# ' - N3_LIBRARY_LIST.parsed':[(60,90),0, 53,],
# ' - N3_LIBRARY_SHELF.parsed': [(40,60),0, 52,], # ' - N3_LIBRARY_SHELF.parsed': [(40,60),0, 52,],
' - N3_FULL.parsed':[(600,800),0, 99,], # Used for screensaver, home screen
} }
#Following are the sizes used with pre2.1.4 firmware #Following are the sizes used with pre2.1.4 firmware
# COVER_FILE_ENDINGS = { # COVER_FILE_ENDINGS = {
@ -1311,6 +1322,7 @@ class KOBOTOUCH(KOBO):
# ' - N3_FULL.parsed':[(600,800),0, 99,], # Used for screensaver if "Full screen" is checked. # ' - N3_FULL.parsed':[(600,800),0, 99,], # Used for screensaver if "Full screen" is checked.
# } # }
def initialize(self): def initialize(self):
super(KOBOTOUCH, self).initialize() super(KOBOTOUCH, self).initialize()
self.bookshelvelist = [] self.bookshelvelist = []
@ -1691,7 +1703,7 @@ class KOBOTOUCH(KOBO):
def imagefilename_from_imageID(self, ImageID): def imagefilename_from_imageID(self, ImageID):
show_debug = self.is_debugging_title(ImageID) show_debug = self.is_debugging_title(ImageID)
for ending, cover_options in self.COVER_FILE_ENDINGS.items(): for ending, cover_options in self.cover_file_endings().items():
fpath = self._main_prefix + '.kobo/images/' + ImageID + ending fpath = self._main_prefix + '.kobo/images/' + ImageID + ending
fpath = self.normalize_path(fpath.replace('/', os.sep)) fpath = self.normalize_path(fpath.replace('/', os.sep))
if os.path.exists(fpath): if os.path.exists(fpath):
@ -1733,12 +1745,16 @@ class KOBOTOUCH(KOBO):
self.set_filesize_in_device_database(connection, contentID, fname) self.set_filesize_in_device_database(connection, contentID, fname)
if not self.copying_covers():
imageID = self.imageid_from_contentid(contentID)
self.delete_images(imageID)
connection.commit() connection.commit()
cursor.close() cursor.close()
except Exception as e: except Exception as e:
debug_print('KoboTouch:upload_books - Exception: %s'%str(e)) debug_print('KoboTouch:upload_books - Exception: %s'%str(e))
return result return result
@ -1794,7 +1810,7 @@ class KOBOTOUCH(KOBO):
path_prefix = '.kobo/images/' path_prefix = '.kobo/images/'
path = self._main_prefix + path_prefix + ImageID path = self._main_prefix + path_prefix + ImageID
for ending in self.COVER_FILE_ENDINGS.keys(): for ending in self.cover_file_endings().keys():
fpath = path + ending fpath = path + ending
fpath = self.normalize_path(fpath) fpath = self.normalize_path(fpath)
@ -2049,23 +2065,23 @@ class KOBOTOUCH(KOBO):
# debug_print("KoboTouch:upload_cover - path='%s' filename='%s'"%(path, filename)) # debug_print("KoboTouch:upload_cover - path='%s' filename='%s'"%(path, filename))
opts = self.settings() opts = self.settings()
if not opts.extra_customization[self.OPT_UPLOAD_COVERS]: if not self.copying_covers():
# Building thumbnails disabled # Building thumbnails disabled
# debug_print('KoboTouch: not uploading cover') # debug_print('KoboTouch: not uploading cover')
return return
# Don't upload covers if book is on the SD card
if self._card_a_prefix and path.startswith(self._card_a_prefix):
return
if not opts.extra_customization[self.OPT_UPLOAD_GRAYSCALE_COVERS]: if not opts.extra_customization[self.OPT_UPLOAD_GRAYSCALE_COVERS]:
uploadgrayscale = False uploadgrayscale = False
else: else:
uploadgrayscale = True uploadgrayscale = True
if not opts.extra_customization[self.OPT_ALWAYS_UPLOAD_COVERS]:
always_upload_covers = False
else:
always_upload_covers = True
# debug_print('KoboTouch: uploading cover') # debug_print('KoboTouch: uploading cover')
try: try:
self._upload_cover(path, filename, metadata, filepath, uploadgrayscale, always_upload_covers) self._upload_cover(path, filename, metadata, filepath, uploadgrayscale, self.keep_cover_aspect())
except Exception as e: except Exception as e:
debug_print('KoboTouch: FAILED to upload cover=%s Exception=%s'%(filepath, str(e))) debug_print('KoboTouch: FAILED to upload cover=%s Exception=%s'%(filepath, str(e)))
@ -2077,9 +2093,9 @@ class KOBOTOUCH(KOBO):
ImageID = ImageID.replace('.', '_') ImageID = ImageID.replace('.', '_')
return ImageID return ImageID
def _upload_cover(self, path, filename, metadata, filepath, uploadgrayscale, always_upload_covers=False): def _upload_cover(self, path, filename, metadata, filepath, uploadgrayscale, keep_cover_aspect=False):
from calibre.utils.magick.draw import save_cover_data_to from calibre.utils.magick.draw import save_cover_data_to, identify_data
debug_print("KoboTouch:_upload_cover - filename='%s' uploadgrayscale='%s' always_upload_covers='%s'"%(filename, uploadgrayscale, always_upload_covers)) debug_print("KoboTouch:_upload_cover - filename='%s' uploadgrayscale='%s' "%(filename, uploadgrayscale))
if metadata.cover: if metadata.cover:
show_debug = self.is_debugging_title(filename) show_debug = self.is_debugging_title(filename)
@ -2122,8 +2138,8 @@ class KOBOTOUCH(KOBO):
if show_debug: if show_debug:
debug_print("KoboTouch:_upload_cover - About to loop over cover endings") debug_print("KoboTouch:_upload_cover - About to loop over cover endings")
for ending, cover_options in self.COVER_FILE_ENDINGS.items(): for ending, cover_options in self.cover_file_endings().items():
resize, min_dbversion, max_dbversion = cover_options resize, min_dbversion, max_dbversion, isFullsize = cover_options
if show_debug: if show_debug:
debug_print("KoboTouch:_upload_cover - resize=%s min_dbversion=%d max_dbversion=%d" % (resize, min_dbversion, max_dbversion)) debug_print("KoboTouch:_upload_cover - resize=%s min_dbversion=%d max_dbversion=%d" % (resize, min_dbversion, max_dbversion))
if self.dbversion >= min_dbversion and self.dbversion <= max_dbversion: if self.dbversion >= min_dbversion and self.dbversion <= max_dbversion:
@ -2132,19 +2148,28 @@ class KOBOTOUCH(KOBO):
fpath = path + ending fpath = path + ending
fpath = self.normalize_path(fpath.replace('/', os.sep)) fpath = self.normalize_path(fpath.replace('/', os.sep))
if os.path.exists(fpath) or always_upload_covers: with open(cover, 'rb') as f:
debug_print("KoboTouch:_upload_cover - path exists or always_upload_covers%s"% always_upload_covers) data = f.read()
with open(cover, 'rb') as f:
data = f.read()
# Return the data resized and in Grayscale if if keep_cover_aspect:
# required if isFullsize:
data = save_cover_data_to(data, 'dummy.jpg', resize = None
grayscale=uploadgrayscale, else:
resize_to=resize, return_data=True) width, height, fmt = identify_data(data)
cover_aspect = width / height
if cover_aspect > 1:
resize = (resize[0], int(resize[0] / cover_aspect ))
elif cover_aspect < 1:
resize = (int(cover_aspect * resize[1]), resize[1] )
with open(fpath, 'wb') as f: # Return the data resized and in Grayscale if
f.write(data) # required
data = save_cover_data_to(data, 'dummy.jpg',
grayscale=uploadgrayscale,
resize_to=resize, return_data=True)
with open(fpath, 'wb') as f:
f.write(data)
except Exception as e: except Exception as e:
err = str(e) err = str(e)
debug_print("KoboTouch:_upload_cover - Exception string: %s"%err) debug_print("KoboTouch:_upload_cover - Exception string: %s"%err)
@ -2453,21 +2478,30 @@ class KOBOTOUCH(KOBO):
return opts return opts
def isGlo(self):
return self.detected_device.idProduct in self.GLO_PRODUCT_ID
def isMini(self):
return self.detected_device.idProduct in self.MINI_PRODUCT_ID
def isTouch(self):
return self.detected_device.idProduct in self.TOUCH_PRODUCT_ID
def cover_file_endings(self):
return self.GLO_COVER_FILE_ENDINGS if self.isGlo() else self.COVER_FILE_ENDINGS
def copying_covers(self):
opts = self.settings()
return opts.extra_customization[self.OPT_UPLOAD_COVERS] or opts.extra_customization[self.OPT_KEEP_COVER_ASPECT_RATIO]
def keep_cover_aspect(self):
opts = self.settings()
return opts.extra_customization[self.OPT_KEEP_COVER_ASPECT_RATIO]
def supports_bookshelves(self): def supports_bookshelves(self):
return self.dbversion >= self.min_supported_dbversion return self.dbversion >= self.min_supported_dbversion
def supports_series(self): def supports_series(self):
return self.dbversion >= self.min_dbversion_series return self.dbversion >= self.min_dbversion_series
# def is_debugging_title(self, title):
## debug_print("KoboTouch:is_debugging - title=", title)
# is_debugging = False
# opts = self.settings()
# if opts.extra_customization:
# debugging_title = opts.extra_customization[self.OPT_DEBUGGING_TITLE]
# is_debugging = len(debugging_title) > 0 and title.find(debugging_title) >= 0 or len(title) == 0
#
# return is_debugging
@classmethod @classmethod
def is_debugging_title(cls, title): def is_debugging_title(cls, title):

View File

@ -100,6 +100,9 @@ def option_recommendation_to_cli_option(add_option, rec):
switches = ['--disable-'+opt.long_switch] switches = ['--disable-'+opt.long_switch]
add_option(Option(*switches, **attrs)) add_option(Option(*switches, **attrs))
def group_titles():
return _('INPUT OPTIONS'), _('OUTPUT OPTIONS')
def add_input_output_options(parser, plumber): def add_input_output_options(parser, plumber):
input_options, output_options = \ input_options, output_options = \
plumber.input_options, plumber.output_options plumber.input_options, plumber.output_options
@ -109,14 +112,14 @@ def add_input_output_options(parser, plumber):
option_recommendation_to_cli_option(group, opt) option_recommendation_to_cli_option(group, opt)
if input_options: if input_options:
title = _('INPUT OPTIONS') title = group_titles()[0]
io = OptionGroup(parser, title, _('Options to control the processing' io = OptionGroup(parser, title, _('Options to control the processing'
' of the input %s file')%plumber.input_fmt) ' of the input %s file')%plumber.input_fmt)
add_options(io.add_option, input_options) add_options(io.add_option, input_options)
parser.add_option_group(io) parser.add_option_group(io)
if output_options: if output_options:
title = _('OUTPUT OPTIONS') title = group_titles()[1]
oo = OptionGroup(parser, title, _('Options to control the processing' oo = OptionGroup(parser, title, _('Options to control the processing'
' of the output %s')%plumber.output_fmt) ' of the output %s')%plumber.output_fmt)
add_options(oo.add_option, output_options) add_options(oo.add_option, output_options)

View File

@ -81,6 +81,11 @@ class BookIndexing
if elem == null if elem == null
pos = [body.scrollWidth+1000, body.scrollHeight+1000] pos = [body.scrollWidth+1000, body.scrollHeight+1000]
else else
# Because of a bug in WebKit's getBoundingClientRect() in
# column mode, this position can be inaccurate,
# see https://bugs.launchpad.net/calibre/+bug/1132641 for a
# test case. The usual symptom of the inaccuracy is br.top is
# highly negative.
br = elem.getBoundingClientRect() br = elem.getBoundingClientRect()
pos = viewport_to_document(br.left, br.top, elem.ownerDocument) pos = viewport_to_document(br.left, br.top, elem.ownerDocument)

View File

@ -410,7 +410,22 @@ class PagedDisplay
elem.scrollIntoView() elem.scrollIntoView()
if this.in_paged_mode if this.in_paged_mode
# Ensure we are scrolled to the column containing elem # Ensure we are scrolled to the column containing elem
this.scroll_to_xpos(calibre_utils.absleft(elem) + 5)
# Because of a bug in WebKit's getBoundingClientRect() in column
# mode, this position can be inaccurate, see
# https://bugs.launchpad.net/calibre/+bug/1132641 for a test case.
# The usual symptom of the inaccuracy is br.top is highly negative.
br = elem.getBoundingClientRect()
if br.top < -1000
# This only works because of the preceding call to
# elem.scrollIntoView(). However, in some cases it gives
# inaccurate results, so we prefer the bounding client rect,
# when possible.
left = elem.scrollLeft
else
left = br.left
this.scroll_to_xpos(calibre_utils.viewport_to_document(
left+this.margin_side, elem.scrollTop, elem.ownerDocument)[0])
snap_to_selection: () -> snap_to_selection: () ->
# Ensure that the viewport is positioned at the start of the column # Ensure that the viewport is positioned at the start of the column

View File

@ -86,7 +86,9 @@ class CalibreUtils
absleft: (elem) -> # {{{ absleft: (elem) -> # {{{
# The left edge of elem in document co-ords. Works in all # The left edge of elem in document co-ords. Works in all
# circumstances, including column layout. Note that this will cause # circumstances, including column layout. Note that this will cause
# a relayout if the render tree is dirty. # a relayout if the render tree is dirty. Also, because of a bug in the
# version of WebKit bundled with Qt 4.8, this does not always work, see
# https://bugs.launchpad.net/bugs/1132641 for a test case.
r = elem.getBoundingClientRect() r = elem.getBoundingClientRect()
return this.viewport_to_document(r.left, 0, elem.ownerDocument)[0] return this.viewport_to_document(r.left, 0, elem.ownerDocument)[0]
# }}} # }}}

View File

@ -15,7 +15,8 @@ from PyQt4.Qt import (QMenu, Qt, QInputDialog, QToolButton, QDialog,
from calibre import isbytestring, sanitize_file_name_unicode from calibre import isbytestring, sanitize_file_name_unicode
from calibre.constants import (filesystem_encoding, iswindows, from calibre.constants import (filesystem_encoding, iswindows,
get_portable_base) get_portable_base)
from calibre.utils.config import prefs from calibre.utils.config import prefs, tweaks
from calibre.utils.icu import sort_key
from calibre.gui2 import (gprefs, warning_dialog, Dispatcher, error_dialog, from calibre.gui2 import (gprefs, warning_dialog, Dispatcher, error_dialog,
question_dialog, info_dialog, open_local_file, choose_dir) question_dialog, info_dialog, open_local_file, choose_dir)
from calibre.library.database2 import LibraryDatabase2 from calibre.library.database2 import LibraryDatabase2
@ -46,7 +47,7 @@ class LibraryUsageStats(object): # {{{
locs = list(self.stats.keys()) locs = list(self.stats.keys())
locs.sort(cmp=lambda x, y: cmp(self.stats[x], self.stats[y]), locs.sort(cmp=lambda x, y: cmp(self.stats[x], self.stats[y]),
reverse=True) reverse=True)
for key in locs[25:]: for key in locs[500:]:
self.stats.pop(key) self.stats.pop(key)
gprefs.set('library_usage_stats', self.stats) gprefs.set('library_usage_stats', self.stats)
@ -72,8 +73,9 @@ class LibraryUsageStats(object): # {{{
locs = list(self.stats.keys()) locs = list(self.stats.keys())
if lpath in locs: if lpath in locs:
locs.remove(lpath) locs.remove(lpath)
locs.sort(cmp=lambda x, y: cmp(self.stats[x], self.stats[y]), limit = tweaks['many_libraries']
reverse=True) key = sort_key if len(locs) > limit else lambda x:self.stats[x]
locs.sort(key=key, reverse=len(locs)<=limit)
for loc in locs: for loc in locs:
yield self.pretty(loc), loc yield self.pretty(loc), loc

View File

@ -7,6 +7,7 @@ __license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>' __copyright__ = '2011, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import re
from contextlib import closing from contextlib import closing
from lxml import html from lxml import html
@ -49,7 +50,7 @@ class AmazonEUBase(StorePlugin):
asin_xpath = '@name' asin_xpath = '@name'
cover_xpath = './/img[@class="productImage"]/@src' cover_xpath = './/img[@class="productImage"]/@src'
title_xpath = './/h3[@class="newaps"]/a//text()' title_xpath = './/h3[@class="newaps"]/a//text()'
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()' author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]//text()'
price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()' price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()'
for data in doc.xpath(data_xpath): for data in doc.xpath(data_xpath):
@ -57,7 +58,7 @@ class AmazonEUBase(StorePlugin):
break break
# Even though we are searching digital-text only Amazon will still # Even though we are searching digital-text only Amazon will still
# put in results for non Kindle books (author pages). Se we need # put in results for non Kindle books (authors pages). Se we need
# to explicitly check if the item is a Kindle book and ignore it # to explicitly check if the item is a Kindle book and ignore it
# if it isn't. # if it isn't.
format_ = ''.join(data.xpath(format_xpath)) format_ = ''.join(data.xpath(format_xpath))
@ -75,12 +76,13 @@ class AmazonEUBase(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath)) cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath(title_xpath)) title = ''.join(data.xpath(title_xpath))
author = ''.join(data.xpath(author_xpath))
try: authors = ''.join(data.xpath(author_xpath))
if self.author_article: authors = re.sub('^' + self.author_article, '', authors)
author = author.split(self.author_article, 1)[1].split(" (")[0] authors = re.sub(self.and_word, ' & ', authors)
except: mo = re.match(r'(.*)(\(\d.*)$', authors)
pass if mo:
authors = mo.group(1).strip()
price = ''.join(data.xpath(price_xpath)) price = ''.join(data.xpath(price_xpath))
@ -89,7 +91,7 @@ class AmazonEUBase(StorePlugin):
s = SearchResult() s = SearchResult()
s.cover_url = cover_url.strip() s.cover_url = cover_url.strip()
s.title = title.strip() s.title = title.strip()
s.author = author.strip() s.author = authors.strip()
s.price = price.strip() s.price = price.strip()
s.detail_item = asin.strip() s.detail_item = asin.strip()
s.drm = SearchResult.DRM_UNKNOWN s.drm = SearchResult.DRM_UNKNOWN
@ -115,3 +117,5 @@ class AmazonDEKindleStore(AmazonEUBase):
search_url = 'http://www.amazon.de/s/?url=search-alias%3Ddigital-text&field-keywords=' search_url = 'http://www.amazon.de/s/?url=search-alias%3Ddigital-text&field-keywords='
author_article = 'von ' author_article = 'von '
and_word = ' und '

View File

@ -7,6 +7,7 @@ __license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>' __copyright__ = '2011, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import re
from contextlib import closing from contextlib import closing
from lxml import html from lxml import html
@ -48,7 +49,7 @@ class AmazonEUBase(StorePlugin):
asin_xpath = '@name' asin_xpath = '@name'
cover_xpath = './/img[@class="productImage"]/@src' cover_xpath = './/img[@class="productImage"]/@src'
title_xpath = './/h3[@class="newaps"]/a//text()' title_xpath = './/h3[@class="newaps"]/a//text()'
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()' author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]//text()'
price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()' price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()'
for data in doc.xpath(data_xpath): for data in doc.xpath(data_xpath):
@ -56,7 +57,7 @@ class AmazonEUBase(StorePlugin):
break break
# Even though we are searching digital-text only Amazon will still # Even though we are searching digital-text only Amazon will still
# put in results for non Kindle books (author pages). Se we need # put in results for non Kindle books (authors pages). Se we need
# to explicitly check if the item is a Kindle book and ignore it # to explicitly check if the item is a Kindle book and ignore it
# if it isn't. # if it isn't.
format_ = ''.join(data.xpath(format_xpath)) format_ = ''.join(data.xpath(format_xpath))
@ -74,12 +75,13 @@ class AmazonEUBase(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath)) cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath(title_xpath)) title = ''.join(data.xpath(title_xpath))
author = ''.join(data.xpath(author_xpath))
try: authors = ''.join(data.xpath(author_xpath))
if self.author_article: authors = re.sub('^' + self.author_article, '', authors)
author = author.split(self.author_article, 1)[1].split(" (")[0] authors = re.sub(self.and_word, ' & ', authors)
except: mo = re.match(r'(.*)(\(\d.*)$', authors)
pass if mo:
authors = mo.group(1).strip()
price = ''.join(data.xpath(price_xpath)) price = ''.join(data.xpath(price_xpath))
@ -88,7 +90,7 @@ class AmazonEUBase(StorePlugin):
s = SearchResult() s = SearchResult()
s.cover_url = cover_url.strip() s.cover_url = cover_url.strip()
s.title = title.strip() s.title = title.strip()
s.author = author.strip() s.author = authors.strip()
s.price = price.strip() s.price = price.strip()
s.detail_item = asin.strip() s.detail_item = asin.strip()
s.drm = SearchResult.DRM_UNKNOWN s.drm = SearchResult.DRM_UNKNOWN
@ -113,3 +115,5 @@ class AmazonESKindleStore(AmazonEUBase):
search_url = 'http://www.amazon.es/s/?url=search-alias%3Ddigital-text&field-keywords=' search_url = 'http://www.amazon.es/s/?url=search-alias%3Ddigital-text&field-keywords='
author_article = 'de ' author_article = 'de '
and_word = ' y '

View File

@ -7,7 +7,7 @@ __license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>' __copyright__ = '2011, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import re
from contextlib import closing from contextlib import closing
from lxml import html from lxml import html
@ -50,7 +50,7 @@ class AmazonEUBase(StorePlugin):
asin_xpath = '@name' asin_xpath = '@name'
cover_xpath = './/img[@class="productImage"]/@src' cover_xpath = './/img[@class="productImage"]/@src'
title_xpath = './/h3[@class="newaps"]/a//text()' title_xpath = './/h3[@class="newaps"]/a//text()'
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()' author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]//text()'
price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()' price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()'
for data in doc.xpath(data_xpath): for data in doc.xpath(data_xpath):
@ -58,7 +58,7 @@ class AmazonEUBase(StorePlugin):
break break
# Even though we are searching digital-text only Amazon will still # Even though we are searching digital-text only Amazon will still
# put in results for non Kindle books (author pages). Se we need # put in results for non Kindle books (authors pages). Se we need
# to explicitly check if the item is a Kindle book and ignore it # to explicitly check if the item is a Kindle book and ignore it
# if it isn't. # if it isn't.
format_ = ''.join(data.xpath(format_xpath)) format_ = ''.join(data.xpath(format_xpath))
@ -76,12 +76,13 @@ class AmazonEUBase(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath)) cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath(title_xpath)) title = ''.join(data.xpath(title_xpath))
author = ''.join(data.xpath(author_xpath))
try: authors = ''.join(data.xpath(author_xpath))
if self.author_article: authors = re.sub('^' + self.author_article, '', authors)
author = author.split(self.author_article, 1)[1].split(" (")[0] authors = re.sub(self.and_word, ' & ', authors)
except: mo = re.match(r'(.*)(\(\d.*)$', authors)
pass if mo:
authors = mo.group(1).strip()
price = ''.join(data.xpath(price_xpath)) price = ''.join(data.xpath(price_xpath))
@ -90,7 +91,7 @@ class AmazonEUBase(StorePlugin):
s = SearchResult() s = SearchResult()
s.cover_url = cover_url.strip() s.cover_url = cover_url.strip()
s.title = title.strip() s.title = title.strip()
s.author = author.strip() s.author = authors.strip()
s.price = price.strip() s.price = price.strip()
s.detail_item = asin.strip() s.detail_item = asin.strip()
s.drm = SearchResult.DRM_UNKNOWN s.drm = SearchResult.DRM_UNKNOWN
@ -112,3 +113,5 @@ class AmazonFRKindleStore(AmazonEUBase):
search_url = 'http://www.amazon.fr/s/?url=search-alias%3Ddigital-text&field-keywords=' search_url = 'http://www.amazon.fr/s/?url=search-alias%3Ddigital-text&field-keywords='
author_article = 'de ' author_article = 'de '
and_word = ' et '

View File

@ -7,6 +7,7 @@ __license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>' __copyright__ = '2011, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import re
from contextlib import closing from contextlib import closing
from lxml import html from lxml import html
@ -48,7 +49,7 @@ class AmazonEUBase(StorePlugin):
asin_xpath = '@name' asin_xpath = '@name'
cover_xpath = './/img[@class="productImage"]/@src' cover_xpath = './/img[@class="productImage"]/@src'
title_xpath = './/h3[@class="newaps"]/a//text()' title_xpath = './/h3[@class="newaps"]/a//text()'
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()' author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]//text()'
price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()' price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()'
for data in doc.xpath(data_xpath): for data in doc.xpath(data_xpath):
@ -56,7 +57,7 @@ class AmazonEUBase(StorePlugin):
break break
# Even though we are searching digital-text only Amazon will still # Even though we are searching digital-text only Amazon will still
# put in results for non Kindle books (author pages). Se we need # put in results for non Kindle books (authors pages). Se we need
# to explicitly check if the item is a Kindle book and ignore it # to explicitly check if the item is a Kindle book and ignore it
# if it isn't. # if it isn't.
format_ = ''.join(data.xpath(format_xpath)) format_ = ''.join(data.xpath(format_xpath))
@ -74,12 +75,13 @@ class AmazonEUBase(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath)) cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath(title_xpath)) title = ''.join(data.xpath(title_xpath))
author = ''.join(data.xpath(author_xpath))
try: authors = ''.join(data.xpath(author_xpath))
if self.author_article: authors = re.sub('^' + self.author_article, '', authors)
author = author.split(self.author_article, 1)[1].split(" (")[0] authors = re.sub(self.and_word, ' & ', authors)
except: mo = re.match(r'(.*)(\(\d.*)$', authors)
pass if mo:
authors = mo.group(1).strip()
price = ''.join(data.xpath(price_xpath)) price = ''.join(data.xpath(price_xpath))
@ -88,7 +90,7 @@ class AmazonEUBase(StorePlugin):
s = SearchResult() s = SearchResult()
s.cover_url = cover_url.strip() s.cover_url = cover_url.strip()
s.title = title.strip() s.title = title.strip()
s.author = author.strip() s.author = authors.strip()
s.price = price.strip() s.price = price.strip()
s.detail_item = asin.strip() s.detail_item = asin.strip()
s.drm = SearchResult.DRM_UNKNOWN s.drm = SearchResult.DRM_UNKNOWN
@ -99,7 +101,6 @@ class AmazonEUBase(StorePlugin):
def get_details(self, search_result, timeout): def get_details(self, search_result, timeout):
pass pass
class AmazonITKindleStore(AmazonEUBase): class AmazonITKindleStore(AmazonEUBase):
''' '''
For comments on the implementation, please see amazon_plugin.py For comments on the implementation, please see amazon_plugin.py
@ -114,3 +115,5 @@ class AmazonITKindleStore(AmazonEUBase):
search_url = 'http://www.amazon.it/s/?url=search-alias%3Ddigital-text&field-keywords=' search_url = 'http://www.amazon.it/s/?url=search-alias%3Ddigital-text&field-keywords='
author_article = 'di ' author_article = 'di '
and_word = ' e '

View File

@ -133,7 +133,7 @@ class AmazonKindleStore(StorePlugin):
asin_xpath = '@name' asin_xpath = '@name'
cover_xpath = './/img[@class="productImage"]/@src' cover_xpath = './/img[@class="productImage"]/@src'
title_xpath = './/h3[@class="newaps"]/a//text()' title_xpath = './/h3[@class="newaps"]/a//text()'
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()' author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]//text()'
price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()' price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()'
for data in doc.xpath(data_xpath): for data in doc.xpath(data_xpath):

View File

@ -7,6 +7,7 @@ __license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>' __copyright__ = '2011, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import re
from contextlib import closing from contextlib import closing
from lxml import html from lxml import html
@ -48,7 +49,7 @@ class AmazonEUBase(StorePlugin):
asin_xpath = '@name' asin_xpath = '@name'
cover_xpath = './/img[@class="productImage"]/@src' cover_xpath = './/img[@class="productImage"]/@src'
title_xpath = './/h3[@class="newaps"]/a//text()' title_xpath = './/h3[@class="newaps"]/a//text()'
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()' author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]//text()'
price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()' price_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and contains(@class, "bld")]/text()'
for data in doc.xpath(data_xpath): for data in doc.xpath(data_xpath):
@ -56,7 +57,7 @@ class AmazonEUBase(StorePlugin):
break break
# Even though we are searching digital-text only Amazon will still # Even though we are searching digital-text only Amazon will still
# put in results for non Kindle books (author pages). Se we need # put in results for non Kindle books (authors pages). Se we need
# to explicitly check if the item is a Kindle book and ignore it # to explicitly check if the item is a Kindle book and ignore it
# if it isn't. # if it isn't.
format_ = ''.join(data.xpath(format_xpath)) format_ = ''.join(data.xpath(format_xpath))
@ -74,12 +75,13 @@ class AmazonEUBase(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath)) cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath(title_xpath)) title = ''.join(data.xpath(title_xpath))
author = ''.join(data.xpath(author_xpath))
try: authors = ''.join(data.xpath(author_xpath))
if self.author_article: authors = re.sub('^' + self.author_article, '', authors)
author = author.split(self.author_article, 1)[1].split(" (")[0] authors = re.sub(self.and_word, ' & ', authors)
except: mo = re.match(r'(.*)(\(\d.*)$', authors)
pass if mo:
authors = mo.group(1).strip()
price = ''.join(data.xpath(price_xpath)) price = ''.join(data.xpath(price_xpath))
@ -88,7 +90,7 @@ class AmazonEUBase(StorePlugin):
s = SearchResult() s = SearchResult()
s.cover_url = cover_url.strip() s.cover_url = cover_url.strip()
s.title = title.strip() s.title = title.strip()
s.author = author.strip() s.author = authors.strip()
s.price = price.strip() s.price = price.strip()
s.detail_item = asin.strip() s.detail_item = asin.strip()
s.drm = SearchResult.DRM_UNKNOWN s.drm = SearchResult.DRM_UNKNOWN
@ -112,3 +114,5 @@ class AmazonUKKindleStore(AmazonEUBase):
author_article = 'by ' author_article = 'by '
and_word = ' and '

View File

@ -41,7 +41,7 @@ class FoylesUKStore(BasicStoreConfig, StorePlugin):
d.exec_() d.exec_()
def search(self, query, max_results=10, timeout=60): def search(self, query, max_results=10, timeout=60):
url = 'http://ebooks.foyles.co.uk/search_for-' + urllib2.quote(query) url = 'http://ebooks.foyles.co.uk/catalog/search/?query=' + urllib2.quote(query)
br = browser() br = browser()
@ -58,7 +58,7 @@ class FoylesUKStore(BasicStoreConfig, StorePlugin):
cover_url = ''.join(data.xpath('.//p[@class="doc-cover"]/a/img/@src')) cover_url = ''.join(data.xpath('.//p[@class="doc-cover"]/a/img/@src'))
title = ''.join(data.xpath('.//span[@class="title"]/a/text()')) title = ''.join(data.xpath('.//span[@class="title"]/a/text()'))
author = ', '.join(data.xpath('.//span[@class="author"]/span[@class="author"]/text()')) author = ', '.join(data.xpath('.//span[@class="author"]/span[@class="author"]/text()'))
price = ''.join(data.xpath('.//span[@class="price"]/text()')) price = ''.join(data.xpath('.//span[@itemprop="price"]/text()'))
format_ = ''.join(data.xpath('.//p[@class="doc-meta-format"]/span[last()]/text()')) format_ = ''.join(data.xpath('.//p[@class="doc-meta-format"]/span[last()]/text()'))
format_, ign, drm = format_.partition(' ') format_, ign, drm = format_.partition(' ')
drm = SearchResult.DRM_LOCKED if 'DRM' in drm else SearchResult.DRM_UNLOCKED drm = SearchResult.DRM_LOCKED if 'DRM' in drm else SearchResult.DRM_UNLOCKED

View File

@ -357,8 +357,9 @@ def do_add_empty(db, title, authors, isbn, tags, series, series_index, cover):
mi.series, mi.series_index = series, series_index mi.series, mi.series_index = series, series_index
if cover: if cover:
mi.cover = cover mi.cover = cover
db.import_book(mi, []) book_id = db.import_book(mi, [])
write_dirtied(db) write_dirtied(db)
prints(_('Added book ids: %s')%book_id)
send_message() send_message()
def command_add(args, dbpath): def command_add(args, dbpath):

View File

@ -2272,7 +2272,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
# force_changes has no effect on cover manipulation # force_changes has no effect on cover manipulation
if mi.cover_data[1] is not None: if mi.cover_data[1] is not None:
doit(self.set_cover, id, mi.cover_data[1], commit=False) doit(self.set_cover, id, mi.cover_data[1], commit=False)
elif mi.cover is not None: elif isinstance(mi.cover, basestring) and mi.cover:
if os.access(mi.cover, os.R_OK): if os.access(mi.cover, os.R_OK):
with lopen(mi.cover, 'rb') as f: with lopen(mi.cover, 'rb') as f:
raw = f.read() raw = f.read()

View File

@ -5,7 +5,7 @@ __license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import operator, os, json, re import operator, os, json, re, time
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from collections import OrderedDict from collections import OrderedDict
@ -819,7 +819,7 @@ class BrowseServer(object):
raw = json.dumps('\n'.join(summs), ensure_ascii=True) raw = json.dumps('\n'.join(summs), ensure_ascii=True)
return raw return raw
def browse_render_details(self, id_): def browse_render_details(self, id_, add_random_button=False):
try: try:
mi = self.db.get_metadata(id_, index_is_id=True) mi = self.db.get_metadata(id_, index_is_id=True)
except: except:
@ -886,11 +886,18 @@ class BrowseServer(object):
u'<div class="comment">%s</div></div>') % (xml(c[0]), u'<div class="comment">%s</div></div>') % (xml(c[0]),
c[1]) for c in comments] c[1]) for c in comments]
comments = u'<div class="comments">%s</div>'%('\n\n'.join(comments)) comments = u'<div class="comments">%s</div>'%('\n\n'.join(comments))
random = ''
if add_random_button:
href = '%s/browse/random?v=%s'%(
self.opts.url_prefix, time.time())
random = '<a href="%s" id="random_button" title="%s">%s</a>' % (
xml(href, True), xml(_('Choose another random book'), True),
xml(_('Another random book')))
return self.browse_details_template.format( return self.browse_details_template.format(
id=id_, title=xml(mi.title, True), fields=fields, id=id_, title=xml(mi.title, True), fields=fields,
get_url=args['get_url'], fmt=args['fmt'], get_url=args['get_url'], fmt=args['fmt'],
formats=args['formats'], comments=comments) formats=args['formats'], comments=comments, random=random)
@Endpoint(mimetype='application/json; charset=utf-8') @Endpoint(mimetype='application/json; charset=utf-8')
def browse_details(self, id=None): def browse_details(self, id=None):
@ -908,7 +915,7 @@ class BrowseServer(object):
import random import random
book_id = random.choice(self.db.search_getting_ids( book_id = random.choice(self.db.search_getting_ids(
'', self.search_restriction)) '', self.search_restriction))
ans = self.browse_render_details(book_id) ans = self.browse_render_details(book_id, add_random_button=True)
return self.browse_template('').format( return self.browse_template('').format(
title='', script='book();', main=ans) title='', script='book();', main=ans)

View File

@ -123,6 +123,274 @@ os.remove(os.path.abspath(__file__))
# }}} # }}}
class ZshCompleter(object): # {{{
def __init__(self, opts):
self.opts = opts
self.dest = None
base = os.path.dirname(self.opts.staging_sharedir)
self.detect_zsh(base)
if not self.dest and base == '/usr/share':
# Ubuntu puts site-functions in /usr/local/share
self.detect_zsh('/usr/local/share')
self.commands = {}
def detect_zsh(self, base):
for x in ('vendor-completions', 'vendor-functions', 'site-functions'):
c = os.path.join(base, 'zsh', x)
if os.path.isdir(c) and os.access(c, os.W_OK):
self.dest = os.path.join(c, '_calibre')
break
def get_options(self, parser, cover_opts=('--cover',), opf_opts=('--opf',),
file_map={}):
if hasattr(parser, 'option_list'):
options = parser.option_list
for group in parser.option_groups:
options += group.option_list
else:
options = parser
for opt in options:
lo, so = opt._long_opts, opt._short_opts
if opt.takes_value():
lo = [x+'=' for x in lo]
so = [x+'+' for x in so]
ostrings = lo + so
if len(ostrings) > 1:
ostrings = u'{%s}'%','.join(ostrings)
else:
ostrings = ostrings[0]
exclude = u''
if opt.dest is None:
exclude = u"'(- *)'"
h = opt.help or ''
h = h.replace('"', "'").replace('[', '(').replace(
']', ')').replace('\n', ' ').replace(':', '\\:')
h = h.replace('%default', type(u'')(opt.default))
arg = ''
if opt.takes_value():
arg = ':"%s":'%h
if opt.dest in {'debug_pipeline', 'to_dir', 'outbox', 'with_library', 'library_path'}:
arg += "'_path_files -/'"
elif opt.choices:
arg += "(%s)"%'|'.join(opt.choices)
elif set(file_map).intersection(set(opt._long_opts)):
k = set(file_map).intersection(set(opt._long_opts))
exts = file_map[tuple(k)[0]]
if exts:
arg += "'_files -g \"%s\"'"%(' '.join('*.%s'%x for x in
tuple(exts) + tuple(x.upper() for x in exts)))
else:
arg += "_files"
elif (opt.dest in {'pidfile', 'attachment'}):
arg += "_files"
elif set(opf_opts).intersection(set(opt._long_opts)):
arg += "'_files -g \"*.opf\"'"
elif set(cover_opts).intersection(set(opt._long_opts)):
arg += "'_files -g \"%s\"'"%(' '.join('*.%s'%x for x in
tuple(pics) + tuple(x.upper() for x in pics)))
help_txt = u'"[%s]"'%h
yield u'%s%s%s%s '%(exclude, ostrings, help_txt, arg)
def opts_and_exts(self, name, op, exts, cover_opts=('--cover',),
opf_opts=('--opf',), file_map={}):
if not self.dest: return
exts = set(exts).union(x.upper() for x in exts)
pats = ('*.%s'%x for x in exts)
extra = ("'*:filename:_files -g \"%s\"' "%' '.join(pats),)
opts = '\\\n '.join(tuple(self.get_options(
op(), cover_opts=cover_opts, opf_opts=opf_opts, file_map=file_map)) + extra)
txt = '_arguments -s \\\n ' + opts
self.commands[name] = txt
def opts_and_words(self, name, op, words, takes_files=False):
if not self.dest: return
extra = ("'*:filename:_files' ",) if takes_files else ()
opts = '\\\n '.join(tuple(self.get_options(op())) + extra)
txt = '_arguments -s \\\n ' + opts
self.commands[name] = txt
def do_ebook_convert(self, f):
from calibre.ebooks.conversion.plumber import supported_input_formats
from calibre.web.feeds.recipes.collection import get_builtin_recipe_titles
from calibre.customize.ui import available_output_formats
from calibre.ebooks.conversion.cli import create_option_parser, group_titles
from calibre.utils.logging import DevNull
input_fmts = set(supported_input_formats())
output_fmts = set(available_output_formats())
iexts = {x.upper() for x in input_fmts}.union(input_fmts)
oexts = {x.upper() for x in output_fmts}.union(output_fmts)
w = lambda x: f.write(x if isinstance(x, bytes) else x.encode('utf-8'))
# Arg 1
w('\n_ebc_input_args() {')
w('\n local extras; extras=(')
w('\n {-h,--help}":Show Help"')
w('\n "--version:Show program version"')
w('\n "--list-recipes:List builtin recipe names"')
for recipe in sorted(set(get_builtin_recipe_titles())):
recipe = recipe.replace(':', '\\:').replace('"', '\\"')
w(u'\n "%s.recipe"'%(recipe))
w('\n ); _describe -t recipes "ebook-convert builtin recipes" extras')
w('\n _files -g "%s"'%' '.join(('*.%s'%x for x in iexts)))
w('\n}\n')
# Arg 2
w('\n_ebc_output_args() {')
w('\n local extras; extras=(')
for x in output_fmts:
w('\n ".{0}:Convert to a .{0} file with the same name as the input file"'.format(x))
w('\n ); _describe -t output "ebook-convert output" extras')
w('\n _files -g "%s"'%' '.join(('*.%s'%x for x in oexts)))
w('\n _path_files -/')
w('\n}\n')
log = DevNull()
def get_parser(input_fmt='epub', output_fmt=None):
of = ('dummy2.'+output_fmt) if output_fmt else 'dummy'
return create_option_parser(('ec', 'dummy1.'+input_fmt, of, '-h'), log)[0]
# Common options
input_group, output_group = group_titles()
p = get_parser()
opts = p.option_list
for group in p.option_groups:
if group.title not in {input_group, output_group}:
opts += group.option_list
opts.append(p.get_option('--pretty-print'))
opts.append(p.get_option('--input-encoding'))
opts = '\\\n '.join(tuple(
self.get_options(opts, file_map={'--search-replace':()})))
w('\n_ebc_common_opts() {')
w('\n _arguments -s \\\n ' + opts)
w('\n}\n')
# Input/Output format options
for fmts, group_title, func in (
(input_fmts, input_group, '_ebc_input_opts_%s'),
(output_fmts, output_group, '_ebc_output_opts_%s'),
):
for fmt in fmts:
is_input = group_title == input_group
if is_input and fmt in {'rar', 'zip', 'oebzip'}: continue
p = (get_parser(input_fmt=fmt) if is_input
else get_parser(output_fmt=fmt))
opts = None
for group in p.option_groups:
if group.title == group_title:
opts = [o for o in group.option_list if
'--pretty-print' not in o._long_opts and
'--input-encoding' not in o._long_opts]
if not opts: continue
opts = '\\\n '.join(tuple(self.get_options(opts)))
w('\n%s() {'%(func%fmt))
w('\n _arguments -s \\\n ' + opts)
w('\n}\n')
w('\n_ebook_convert() {')
w('\n local iarg oarg context state_descr state line\n typeset -A opt_args\n local ret=1')
w("\n _arguments '1: :_ebc_input_args' '*::ebook-convert output:->args' && ret=0")
w("\n case $state in \n (args)")
w('\n iarg=${line[1]##*.}; ')
w("\n _arguments '1: :_ebc_output_args' '*::ebook-convert options:->args' && ret=0")
w("\n case $state in \n (args)")
w('\n oarg=${line[1]##*.}')
w('\n iarg="_ebc_input_opts_${(L)iarg}"; oarg="_ebc_output_opts_${(L)oarg}"')
w('\n _call_function - $iarg; _call_function - $oarg; _ebc_common_opts; ret=0')
w('\n ;;\n esac')
w("\n ;;\n esac\n return ret")
w('\n}\n')
def do_calibredb(self, f):
import calibre.library.cli as cli
from calibre.customize.ui import available_catalog_formats
parsers, descs = {}, {}
for command in cli.COMMANDS:
op = getattr(cli, '%s_option_parser'%command)
args = [['t.epub']] if command == 'catalog' else []
p = op(*args)
if isinstance(p, tuple):
p = p[0]
parsers[command] = p
lines = [x.strip().partition('.')[0] for x in p.usage.splitlines() if x.strip() and
not x.strip().startswith('%prog')]
descs[command] = lines[0]
f.write('\n_calibredb_cmds() {\n local commands; commands=(\n')
f.write(' {-h,--help}":Show help"\n')
f.write(' "--version:Show version"\n')
for command, desc in descs.iteritems():
f.write(' "%s:%s"\n'%(
command, desc.replace(':', '\\:').replace('"', '\'')))
f.write(' )\n _describe -t commands "calibredb command" commands \n}\n')
subcommands = []
for command, parser in parsers.iteritems():
exts = []
if command == 'catalog':
exts = [x.lower() for x in available_catalog_formats()]
elif command == 'set_metadata':
exts = ['opf']
exts = set(exts).union(x.upper() for x in exts)
pats = ('*.%s'%x for x in exts)
extra = ("'*:filename:_files -g \"%s\"' "%' '.join(pats),) if exts else ()
if command in {'add', 'add_format'}:
extra = ("'*:filename:_files' ",)
opts = '\\\n '.join(tuple(self.get_options(
parser)) + extra)
txt = ' _arguments -s \\\n ' + opts
subcommands.append('(%s)'%command)
subcommands.append(txt)
subcommands.append(';;')
f.write('\n_calibredb() {')
f.write(
r'''
local state line state_descr context
typeset -A opt_args
local ret=1
_arguments \
'1: :_calibredb_cmds' \
'*::calibredb subcommand options:->args' \
&& ret=0
case $state in
(args)
case $line[1] in
(-h|--help|--version)
_message 'no more arguments' && ret=0
;;
%s
esac
;;
esac
return ret
'''%'\n '.join(subcommands))
f.write('\n}\n\n')
def write(self):
if self.dest:
self.commands['calibredb'] = ' _calibredb "$@"'
self.commands['ebook-convert'] = ' _ebook_convert "$@"'
with open(self.dest, 'wb') as f:
f.write('#compdef ' + ' '.join(self.commands)+'\n')
self.do_ebook_convert(f)
self.do_calibredb(f)
f.write('case $service in\n')
for c, txt in self.commands.iteritems():
if isinstance(txt, type(u'')):
txt = txt.encode('utf-8')
if isinstance(c, type(u'')):
c = c.encode('utf-8')
f.write(b'%s)\n%s\n;;\n'%(c, txt))
f.write('esac\n')
# }}}
class PostInstall: class PostInstall:
def task_failed(self, msg): def task_failed(self, msg):
@ -217,7 +485,7 @@ class PostInstall:
def setup_completion(self): # {{{ def setup_completion(self): # {{{
try: try:
self.info('Setting up bash completion...') self.info('Setting up command-line completion...')
from calibre.ebooks.metadata.cli import option_parser as metaop, filetypes as meta_filetypes from calibre.ebooks.metadata.cli import option_parser as metaop, filetypes as meta_filetypes
from calibre.ebooks.lrf.lrfparser import option_parser as lrf2lrsop from calibre.ebooks.lrf.lrfparser import option_parser as lrf2lrsop
from calibre.gui2.lrf_renderer.main import option_parser as lrfviewerop from calibre.gui2.lrf_renderer.main import option_parser as lrfviewerop
@ -227,8 +495,11 @@ class PostInstall:
from calibre.utils.smtp import option_parser as smtp_op from calibre.utils.smtp import option_parser as smtp_op
from calibre.library.server.main import option_parser as serv_op from calibre.library.server.main import option_parser as serv_op
from calibre.ebooks.oeb.polish.main import option_parser as polish_op, SUPPORTED from calibre.ebooks.oeb.polish.main import option_parser as polish_op, SUPPORTED
from calibre.debug import option_parser as debug_op
from calibre.ebooks import BOOK_EXTENSIONS from calibre.ebooks import BOOK_EXTENSIONS
from calibre.customize.ui import available_input_formats
input_formats = sorted(all_input_formats()) input_formats = sorted(all_input_formats())
zsh = ZshCompleter(self.opts)
bc = os.path.join(os.path.dirname(self.opts.staging_sharedir), bc = os.path.join(os.path.dirname(self.opts.staging_sharedir),
'bash-completion') 'bash-completion')
if os.path.exists(bc): if os.path.exists(bc):
@ -240,6 +511,9 @@ class PostInstall:
f = os.path.join(self.opts.staging_etc, 'bash_completion.d/calibre') f = os.path.join(self.opts.staging_etc, 'bash_completion.d/calibre')
if not os.path.exists(os.path.dirname(f)): if not os.path.exists(os.path.dirname(f)):
os.makedirs(os.path.dirname(f)) os.makedirs(os.path.dirname(f))
if zsh.dest:
self.info('Installing zsh completion to:', zsh.dest)
self.manifest.append(zsh.dest)
self.manifest.append(f) self.manifest.append(f)
complete = 'calibre-complete' complete = 'calibre-complete'
if getattr(sys, 'frozen_path', None): if getattr(sys, 'frozen_path', None):
@ -247,20 +521,35 @@ class PostInstall:
self.info('Installing bash completion to', f) self.info('Installing bash completion to', f)
with open(f, 'wb') as f: with open(f, 'wb') as f:
def o_and_e(*args, **kwargs):
f.write(opts_and_exts(*args, **kwargs))
zsh.opts_and_exts(*args, **kwargs)
def o_and_w(*args, **kwargs):
f.write(opts_and_words(*args, **kwargs))
zsh.opts_and_words(*args, **kwargs)
f.write('# calibre Bash Shell Completion\n') f.write('# calibre Bash Shell Completion\n')
f.write(opts_and_exts('calibre', guiop, BOOK_EXTENSIONS)) o_and_e('calibre', guiop, BOOK_EXTENSIONS)
f.write(opts_and_exts('lrf2lrs', lrf2lrsop, ['lrf'])) o_and_e('lrf2lrs', lrf2lrsop, ['lrf'], file_map={'--output':['lrs']})
f.write(opts_and_exts('ebook-meta', metaop, o_and_e('ebook-meta', metaop,
list(meta_filetypes()), cover_opts=['--cover', '-c'], list(meta_filetypes()), cover_opts=['--cover', '-c'],
opf_opts=['--to-opf', '--from-opf'])) opf_opts=['--to-opf', '--from-opf'])
f.write(opts_and_exts('ebook-polish', polish_op, o_and_e('ebook-polish', polish_op,
[x.lower() for x in SUPPORTED], cover_opts=['--cover', '-c'], [x.lower() for x in SUPPORTED], cover_opts=['--cover', '-c'],
opf_opts=['--opf', '-o'])) opf_opts=['--opf', '-o'])
f.write(opts_and_exts('lrfviewer', lrfviewerop, ['lrf'])) o_and_e('lrfviewer', lrfviewerop, ['lrf'])
f.write(opts_and_exts('ebook-viewer', viewer_op, input_formats)) o_and_e('ebook-viewer', viewer_op, input_formats)
f.write(opts_and_words('fetch-ebook-metadata', fem_op, [])) o_and_w('fetch-ebook-metadata', fem_op, [])
f.write(opts_and_words('calibre-smtp', smtp_op, [])) o_and_w('calibre-smtp', smtp_op, [])
f.write(opts_and_words('calibre-server', serv_op, [])) o_and_w('calibre-server', serv_op, [])
o_and_e('calibre-debug', debug_op, ['py', 'recipe'], file_map={
'--tweak-book':['epub', 'azw3', 'mobi'],
'--subset-font':['ttf', 'otf'],
'--exec-file':['py', 'recipe'],
'--add-simple-plugin':['py'],
'--inspect-mobi':['mobi', 'azw', 'azw3'],
'--viewer':list(available_input_formats()),
})
f.write(textwrap.dedent(''' f.write(textwrap.dedent('''
_ebook_device_ls() _ebook_device_ls()
{ {
@ -335,6 +624,7 @@ class PostInstall:
complete -o nospace -C %s ebook-convert complete -o nospace -C %s ebook-convert
''')%complete) ''')%complete)
zsh.write()
except TypeError as err: except TypeError as err:
if 'resolve_entities' in str(err): if 'resolve_entities' in str(err):
print 'You need python-lxml >= 2.0.5 for calibre' print 'You need python-lxml >= 2.0.5 for calibre'
@ -451,7 +741,7 @@ def options(option_parser):
opts.extend(opt._long_opts) opts.extend(opt._long_opts)
return opts return opts
def opts_and_words(name, op, words): def opts_and_words(name, op, words, takes_files=False):
opts = '|'.join(options(op)) opts = '|'.join(options(op))
words = '|'.join([w.replace("'", "\\'") for w in words]) words = '|'.join([w.replace("'", "\\'") for w in words])
fname = name.replace('-', '_') fname = name.replace('-', '_')
@ -481,12 +771,15 @@ def opts_and_words(name, op, words):
} }
complete -F _'''%(opts, words) + fname + ' ' + name +"\n\n").encode('utf-8') complete -F _'''%(opts, words) + fname + ' ' + name +"\n\n").encode('utf-8')
pics = {'jpg', 'jpeg', 'gif', 'png', 'bmp'}
def opts_and_exts(name, op, exts, cover_opts=('--cover',), opf_opts=()): def opts_and_exts(name, op, exts, cover_opts=('--cover',), opf_opts=(),
file_map={}):
opts = ' '.join(options(op)) opts = ' '.join(options(op))
exts.extend([i.upper() for i in exts]) exts.extend([i.upper() for i in exts])
exts='|'.join(exts) exts='|'.join(exts)
fname = name.replace('-', '_') fname = name.replace('-', '_')
spics = '|'.join(tuple(pics) + tuple(x.upper() for x in pics))
special_exts_template = '''\ special_exts_template = '''\
%s ) %s )
_filedir %s _filedir %s
@ -507,7 +800,7 @@ def opts_and_exts(name, op, exts, cover_opts=('--cover',), opf_opts=()):
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="%(opts)s" opts="%(opts)s"
pics="@(jpg|jpeg|png|gif|bmp|JPG|JPEG|PNG|GIF|BMP)" pics="@(%(pics)s)"
case "${prev}" in case "${prev}" in
%(extras)s %(extras)s
@ -526,7 +819,7 @@ def opts_and_exts(name, op, exts, cover_opts=('--cover',), opf_opts=()):
esac esac
} }
complete -o filenames -F _'''%dict( complete -o filenames -F _'''%dict(pics=spics,
opts=opts, extras=extras, exts=exts) + fname + ' ' + name +"\n\n" opts=opts, extras=extras, exts=exts) + fname + ' ' + name +"\n\n"
@ -627,6 +920,5 @@ def main():
PostInstall(opts) PostInstall(opts)
return 0 return 0
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())

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

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