pull/94/head
eric 2019-03-27 21:46:25 -04:00
parent c142533898
commit 14346ed868
3 changed files with 20 additions and 38 deletions

View File

@ -18,12 +18,12 @@ from django.core.files.base import ContentFile
from django.core.files.storage import default_storage
from django.db import IntegrityError
from django.forms import ValidationError
from django.utils.timezone import now
from django_comments.models import Comment
from github3 import (login, GitHub)
from github3.repos.release import Release
from django.utils.timezone import now
from gitenberg.metadata.pandata import Pandata
# regluit imports
@ -207,7 +207,7 @@ def update_edition(edition):
# attach edition to the
if edition.work.language != language:
logger.info(u"reconnecting %s since it is %s instead of %s",
googlebooks_id, language, edition.work.language)
googlebooks_id, language, edition.work.language)
old_work = edition.work
new_work = models.Work(title=title, language=language)
@ -251,9 +251,6 @@ def get_isbn_item(items, isbn):
for ident in industryIdentifiers:
if ident['identifier'] == isbn:
return item
else:
return None # no items
return item
def add_by_isbn_from_google(isbn, work=None):
"""add a book to the UnglueIt database from google based on ISBN. The work parameter
@ -970,7 +967,7 @@ class BasePandataLoader(object):
for yaml_subject in metadata.subjects: #always add yaml subjects (don't clear)
if isinstance(yaml_subject, tuple):
(authority, heading) = yaml_subject
elif isinstance(yaml_subject, str) or isinstance(yaml_subject, unicode) :
elif isinstance(yaml_subject, str) or isinstance(yaml_subject, unicode):
(authority, heading) = ('', yaml_subject)
else:
continue

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python
# encoding: utf-8
import datetime
import json
import logging
import re
@ -19,7 +18,6 @@ from oaipmh.metadata import MetadataRegistry, oai_dc_reader
from regluit.core import bookloader, cc
from regluit.core import models, tasks
from regluit.core.bookloader import merge_works
from regluit.core.isbn import ISBN
from regluit.core.loaders.utils import type_for_url
from regluit.core.validation import identifier_cleaner, valid_subject
@ -67,7 +65,7 @@ def store_doab_cover(doab_id, redo=False):
cover_file = ContentFile(r.content)
content_type = r.headers.get('content-type', '')
if u'text/html' in content_type:
logger.warning('Cover return html for doab_id={}: {}'.format(doab_id, e))
logger.warning('Cover return html for doab_id={}'.format(doab_id))
return (None, False)
cover_file.content_type = content_type
@ -408,20 +406,6 @@ def add_by_doab(doab_id, record=None):
url_to_provider(dl_url) if dl_url else None,
**metadata
)
else:
if 'format' in metadata:
del metadata['format']
edition = load_doab_edition(
title,
doab_id,
'',
'',
license,
language,
isbns,
None,
**metadata
)
return edition
except IdDoesNotExistError:
return None

View File

@ -1,7 +1,7 @@
import re
from django.conf.global_settings import LANGUAGES
lang2code = dict([ (lang[1].lower(), lang[0]) for lang in LANGUAGES ])
lang2code = dict([(lang[1].lower(), lang[0]) for lang in LANGUAGES])
code2lang = dict(LANGUAGES)
iso639 = re.compile(r'^[a-z][a-z][a-z]?$')
@ -24,7 +24,7 @@ def get_language_code(language):
# accept 2 and 3 letter codes
if iso639.match(language):
return language
return language
return ''
# let's do a mapping of the DOAB languages into the language codes used
@ -78,3 +78,4 @@ def lang_to_language_code(lang):
if code:
return code
return ''