Ugly encoding hacks.
This commit is contained in:
parent
3c911d3131
commit
9e84d0cfcd
|
@ -15,6 +15,8 @@ exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q']
|
||||||
|
|
||||||
comments = ""
|
comments = ""
|
||||||
|
|
||||||
|
encoding = 'utf8'
|
||||||
|
|
||||||
# midlertidig
|
# midlertidig
|
||||||
connection = pgdb.connect(database='oysteini_pbb2',
|
connection = pgdb.connect(database='oysteini_pbb2',
|
||||||
user='oysteini_pbb',
|
user='oysteini_pbb',
|
||||||
|
@ -114,18 +116,18 @@ def build_book(entry, authors, indata=False):
|
||||||
comment("No ISBN found.")
|
comment("No ISBN found.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
book['title'] = unicode(entry.dc_title[0].text)
|
book['title'] = unicode(entry.dc_title[0].text, encoding)
|
||||||
|
|
||||||
set_value(book, dic, 'category')
|
set_value(book, dic, 'category')
|
||||||
|
|
||||||
if len(entry.dc_title) > 0:
|
if len(entry.dc_title) > 0:
|
||||||
book['subtitle'] = unicode(''.join(map(lambda x: x.text, entry.dc_title[1:])))
|
book['subtitle'] = unicode(''.join(map(lambda x: x.text, entry.dc_title[1:])), encoding)
|
||||||
|
|
||||||
book['persons'] = {}
|
book['persons'] = {}
|
||||||
book['persons']['author'] = [author['id'] for author in authors]
|
book['persons']['author'] = [author['id'] for author in authors]
|
||||||
|
|
||||||
if 'publishers' in dic:
|
if 'publishers' in dic:
|
||||||
book['publisher'] = unicode(','.join(dic['publishers']))
|
book['publisher'] = unicode(','.join(dic['publishers']), encoding)
|
||||||
|
|
||||||
if 'date' in dic:
|
if 'date' in dic:
|
||||||
book['published_year'] = int(dic['date'][:4])
|
book['published_year'] = int(dic['date'][:4])
|
||||||
|
@ -136,10 +138,10 @@ def build_book(entry, authors, indata=False):
|
||||||
|
|
||||||
set_value(book, dic, 'series')
|
set_value(book, dic, 'series')
|
||||||
|
|
||||||
book['description'] = unicode(find_description(dic))
|
book['description'] = unicode(find_description(dic), encoding)
|
||||||
|
|
||||||
book['references'] = {}
|
book['references'] = {}
|
||||||
book['references']['google-books'] = [unicode(dic['preview'])]
|
book['references']['google-books'] = [unicode(dic['preview'], encoding)]
|
||||||
|
|
||||||
return book
|
return book
|
||||||
|
|
||||||
|
@ -149,7 +151,7 @@ def comment(comm):
|
||||||
|
|
||||||
def set_value(book, dic, key):
|
def set_value(book, dic, key):
|
||||||
if key in dic:
|
if key in dic:
|
||||||
book[key] = unicode(dic[key])
|
book[key] = unicode(dic[key], encoding)
|
||||||
else:
|
else:
|
||||||
book[key] = None
|
book[key] = None
|
||||||
|
|
||||||
|
|
Reference in New Issue