Пример #1
0
    LOAD_FORMATTER_PLUGINS = bool(
        conf.get('SYS', 'LOAD_FORMATTER_PLUGINS') == 'True')
    config.set_option('LOAD_FORMATTER_PLUGINS', LOAD_FORMATTER_PLUGINS)

# only now we can import registry!
# pylint: disable=wrong-import-position
from isbnlib import registry

if conf.has_section('SERVICES'):
    for o, v in conf.items('SERVICES'):
        if o.upper() == 'DEFAULT_SERVICE':
            registry.setdefaultservice(v)
            continue
        if 'api_key' in o:  # pragma: no cover
            name = o[:-8]
            config.add_apikey(name, v)
        else:
            config.set_option(o.upper(), v)

if conf.has_section('MISC'):  # pragma: no cover
    for o, v in conf.items('MISC'):
        config.set_option(o.upper(), v)

if conf.has_section('MODULES'):  # pragma: no cover
    for o, v in conf.items('MODULES'):
        config.set_option(o.upper(), v)

# set CONF_PATH
if not CONF_PATH:
    if VIRTUAL:
        CONF_PATH = os.path.join(sys.prefix, 'isbntools')
Пример #2
0
import os
import isbnlib
import string
import comFuncs
from comFuncs import *
from isbnlib.config import add_apikey
APIKEY="2E7FE5A4"
import os
import string
SERVICE = 'isbndb'
#register your key
add_apikey(SERVICE, APIKEY)
print "api initialised"
def getISBNmeta(title,author):
    #isbn=isbnlib.isbn_from_words(title+" by " +author)
    try:
        return isbnlib.goom(title+" " +author)
    except:
        return
        #print "service unavailable"
def getFileIsbnMeta(f,smscr):
    print "start"
    fp,ff= os.path.split(f)
    fn, fext = os.path.splitext(ff)
    seri=''
    sm=0
    mtd=None
    sp=fn.split()
    if len(sp)>4:
        auth=sp[-2:]
        tit=sp[:-2]
Пример #3
0
import os, openpyxl, json
from isbnlib import isbn_from_words, meta, config
from isbntools.app import config, ISBNToolsException
ROOT = os.path.abspath(os.getcwd()) + "/2BA/Informatic/res/"
FILE = "Michel's Library.xlsx"
SHEET = 'Books'

config.add_apikey('goob', 'AIzaSyBGHXp1MEELSeTW7YfuzE_lyilgEWg6tkc>')
book = openpyxl.load_workbook(ROOT + FILE)
sheet = book.get_sheet_by_name(SHEET)
max_row = sheet.max_row
data = []
for i in range(2, max_row + 1):
    title = sheet.cell(row=i, column=1).value
    authors = sheet.cell(row=i, column=2).value
    data.append([title.replace(" ", "+"), authors.replace(" ", "+")])

isbn_list = []
a = len(data)
errors = [41, 225, 226, 227, 228, 296, 353, 354]

for i in range(a):
    query = data[i][0] + "+" + data[i][1]
    if i not in errors:
        try:
            isbn = isbn_from_words(query)
            res = [
                i + 2, isbn, data[i][0].replace("+", " "),
                data[i][1].replace("+", " ")
            ]
        except UnboundLocalError:
Пример #4
0
from isbnlib import meta, cover
from isbnlib.config import add_apikey

import os

try:
    proxy = 'http://172.16.2.30:8080'
    os.environ['http_proxy'] = proxy
    os.environ['HTTP_PROXY'] = proxy
    os.environ['https_proxy'] = proxy
    os.environ['HTTPS_PROXY'] = proxy
    os.environ['NO_PROXY'] = 'localhost,127.0.0.1/*,127.0.0.1'
except:
    print("proxy error")

SERVICE = 'isbndb'
APIKEY = 'temp475675837'  # <-- replace with YOUR key
# register your key
add_apikey(SERVICE, APIKEY)

isbn = '9780141199610'
book = meta(isbn)
print(book)
print(cover(isbn))
Пример #5
0
def mybooks(request):
    user = request.user

    if request.POST.get("changeavailable"):
        availability=request.POST.get("available")
        isbn = request.POST.get('isbn')
        bool=execute_only_raw_sql("UPDATE my_books SET Availability="+str(availability)+" where User_ID='"+str(user)+"' and ISBN='"+str(isbn)+"'")
        print(bool)
        messages.success(request,"Availability Changed Successfully !!!")

    if request.POST.get("delete"):
        delete_isbn=request.POST.get('isbn')
        flag=execute_only_raw_sql("delete from my_books as MB where MB.User_ID='"+str(user)+"' and MB.ISBN='"+str(delete_isbn)+"'")
        if flag==False:
            print('Error in delete : ',delete_isbn)
        else:
            print('Deleted isbn: ', delete_isbn, ' from user:'******'isbn')
        availability=request.POST.get('availability')
        repaypol=request.POST.get('repaymentpolicy')
        otherspec=request.POST.get('otherspecifications')
        securitymoney=request.POST.get('securitymoneyofbook')

        SERVICE = 'isbndb'
        APIKEY = 'temp475675837'  # <-- replace with YOUR key
        # register your key
        add_apikey(SERVICE, APIKEY)

        try:
            book=meta(isbn)
            print(book)
            if book == None:
                messages.error(request,"Book not available in ISBN database.")
            else:
                try:
                    auth=""
                    for a in book['Authors']:
                        auth=auth+','+a
                    auth=auth[1:]
                    try:
                        year=int(book['Year'])
                    except:
                        year=None

                    if book['Language'] == "":
                        lang=None
                    else:
                        lang=book['Language']

                    Book.objects.create(isbn=isbn, book_name=book['Title'],author=auth,language= lang,year=year )
                    print("new book added")

                except Exception as e:
                    print(e)
                    print("book already exists")

                try:
                    MyBooks.objects.create(repayment_policy=repaypol, availability=int(availability),
                                           other_specifications=otherspec,
                                           security_money_of_book=int(securitymoney), user=User.objects.get(user_id=user),
                                           isbn=Book.objects.get(isbn=isbn))
                    messages.success(request, "Book Added Successfully !!!")
                    print("new book added to user : "******"Book already exists !")
                    print("Error in adding Book")
        except Exception as e:
            print(e)
            messages.ERROR(request,"Wrong ISBN Entered !!!")


    if request.POST.get("editbook"):
        isbn = request.POST.get('isbn')
        availability = request.POST.get('availability')
        repaypol = request.POST.get('repaymentpolicy')
        otherspec = request.POST.get('otherspecification')
        securitymoney = request.POST.get('securitymoneyofbook')

        try:
            mb = MyBooks.objects.get(isbn=isbn, user=User.objects.get(user_id=user))
            mb.repayment_policy = repaypol
            mb.availability = int(availability)
            mb.other_specifications = otherspec
            mb.security_money_of_book = int(securitymoney)
            mb.save()
            print("book updated")
        except Exception as e:
            print(e)
            print("book update error")


    books = perform_raw_sql("select * from user as U, my_books as MB, book as B where U.User_ID='"+str(user)+"' and U.User_ID=MB.User_ID and MB.ISBN=B.ISBN")
    print(books)
    if len(books)!=0:
        return render(request, 'mybooks.html', {'user': user, 'books': books})
    else:
        messages.info(request,"No Book Added !")
        books={}
        return render(request, 'mybooks.html', {'user': user, 'books': books})
Пример #6
0

# set options
if conf.has_section('SYS'):
    # get user defined values for timeouts
    SOCKETS_TIMEOUT = float(conf.get('SYS', 'SOCKETS_TIMEOUT'))
    THREADS_TIMEOUT = float(conf.get('SYS', 'THREADS_TIMEOUT'))

if conf.has_section('SERVICES'):
    for o, v in conf.items('SERVICES'):
        if o.upper() == 'DEFAULT_SERVICE':
            registry.setdefaultservice(v)
            continue
        if 'api_key' in o:       # pragma: no cover
            name = o[:-8]
            config.add_apikey(name, v)
        else:
            config.set_option(o.upper(), v)

if conf.has_section('MISC'):     # pragma: no cover
    for o, v in conf.items('MISC'):
        config.set_option(o.upper(), v)

if conf.has_section('MODULES'):  # pragma: no cover
    for o, v in conf.items('MODULES'):
        config.set_option(o.upper(), v)

if conf.has_section('PLUGINS'):  # pragma: no cover
    for o, v in conf.items('PLUGINS'):
        path = v if '/' in v or '\\' in v else plugins_path
        try: