Exemple #1
0
def main():
    while 1:
        line = sys.stdin.readline().strip()
        try:
            book(line)
        except Exception as e:
            print e
Exemple #2
0
def testBooks():
    book1 = book("1", "12", "date", "10", "12")
    book2 = book("2", "31", "date1", "11", "13")
    book3 = book("3", "32", "date2", "14", "14")
    book4 = book("4", "41", "date3", "100", "15")

    assert book1.returnBookId() == "1"
    assert book2.returnBookId() == "2"
    assert book3.returnBookId() == "3"
    assert book4.returnBookId() == "4"

    assert book1.returnBookTitle() == "12"
    assert book2.returnBookTitle() == "31"
    assert book3.returnBookTitle() == "32"
    assert book4.returnBookTitle() == "41"

    assert book1.returnBookDesc() == "date"
    assert book2.returnBookDesc() == "date1"
    assert book3.returnBookDesc() == "date2"
    assert book4.returnBookDesc() == "date3"

    assert book1.returnBookAuthor() == "10"
    assert book2.returnBookAuthor() == "11"
    assert book3.returnBookAuthor() == "14"
    assert book4.returnBookAuthor() == "100"

    assert book1.returnBookPrice() == "12"
    assert book2.returnBookPrice() == "13"
    assert book3.returnBookPrice() == "14"
    assert book4.returnBookPrice() == "15"
 def loadReqs(self,fileName,settingType):
     #Load Requests from a file.
     #Set requests to Book object
     reqs = []
     try:
         f = open(fileName,"r+")
         #Readable
         for i in re.findall(r'\$.+\n!.+\n!.+\n!.+\n\$.+',f.read(),re.M|re.I):
             bk = []
             i = ''.join([i,'\n'])
             ops = re.findall(r'.*\n',i,re.M|re.I)
             for r in ops:
                 ress = re.search(r'\[.*\]',r) 
                 #  bk = [res.group().replace("[","").replace("]","") if res.group()!= '[]' else '' for res in [re.search(r'\[.*\]',r) for r in ops]]
                 if(ress.group() != '[]'):
                     bk += [ress.group().replace("[","").replace("]","")]
             if len(bk)>0:
                 if settingType is 'book':
                     reqs += [book(bk[0],bk[1],bk[2],int(bk[3]),int(bk[4]))]
                 elif settingType is 'email':
                     reqs += [mail(bk[0],bk[1],bk[2],bk[3],bk[4])]            
                 else:
                     print("")
         f.close()
     except:
         print("ERROR: Setting file can not open")
     return reqs
Exemple #4
0
    def search(self,keyWord,atype,start,count):
        print "search key :%s " % keyWord
        print "atype :%d:" % atype
        if(atype==0):
            stype='q'
        elif(atype==1):
            stype='tag'
        else:
            print "atype error"
            return  []
        params=urllib.urlencode({stype:keyWord.encode('utf-8'),'start':start,'count':count})
        conn=httplib.HTTPConnection("api.douban.com")
        print params
        conn.request("GET","/v2/book/search?%s" % params)
        r1=conn.getresponse()
        print r1.status
        data=r1.read()
        f=open("data.txt","w")
        f.write(data)
        js=json.loads(data)
        jsbooks=js['books']

        books={}
        books['count']=js['count']
        books['start']=js['start']
        books['total']=js['total']
        books['Shuxin']=[];
        for item in jsbooks:
            mbook=book()
            mbook.load(item)
            books['Shuxin'].append(mbook)
        return books
Exemple #5
0
 def insertBook(self, author, title, publicationYear):
     """Inserts book into database"""
     newBook = book.book(author, title, publicationYear, self.currentId)
     self.books.append(newBook.__dict__)
     self.currentId += 1
     f = open("bookDatabase.pickle", "wb")
     pickle.dump(self.__dict__, f)
     f.close()
Exemple #6
0
def book_input():
    name = input('请输入书籍名称')
    type = input('请输入书籍类型')
    difficult = input('请输入书籍难度')
    language = input('请输入书籍语言')
    status = input('请输入购买状态')
    newbook = book(name, type, difficult, language, status)
    return newbook
Exemple #7
0
 def arrangeAZ(self):
     bookInfo = []
     for (index, row) in self.dfBook.iterrows():
         bookName = row[0].split('(')[0].split('(')[0]
         bookInfo.append(book.book(bookName, row[1].replace('•', '')).getBookInfo())
     # print(bookInfo)
     coloums = ['name', 'author', 'tags', 'rating', 'bookUrl', 'summary']
     df = DataFrame(bookInfo, columns=coloums)
     df.to_excel(self.toPath)
def generate_sentence():
    my_text = book("words.txt")
    histo = histogram(my_text.split("\n"))
    sentence = ""
    num_words = 12
    
    for i in range(num_words):
        word = sample_dict(histo)
        sentence += " " + word
    return sentence
Exemple #9
0
  def __init__(self):
    self.borrowers = 0
    builder = gtk.Builder()
    self.gladefile = os.path.join(os.path.dirname(__file__),"ui/edit_book.glade")
    builder.add_from_file(self.gladefile)
    builder.connect_signals(self)
    self.window = builder.get_object("window_edit")
    self.isbn =  builder.get_object("entry1")
    self.author =  builder.get_object("entry2")
    self.title =  builder.get_object("entry3")
    self.publisher =  builder.get_object("entry4")
    self.year =  builder.get_object("entry5")
    self.city =  builder.get_object("entry6")
    scrolled_window =  builder.get_object("scrolledwindow1")
    #logging.debug(scrolled_window)
    self.abstract =  builder.get_object("textview_abtract") 
    #logging.debug(self.abstract)
    self.mtype =  builder.get_object("entry8")
    self.copies = builder.get_object("entry9")
    self.lent = builder.get_object("checkbutton1")
    self.lentlist = builder.get_object("liststore1")
    self.lent_select = builder.get_object("comboboxentry1")
    self.book_owner = builder.get_object("entry_owner")
    self.add_button = builder.get_object("button_new_user") # Add a new user or edit
    self.rating_select = builder.get_object("combobox_rating")
    self.rating_liststore = builder.get_object("liststore_rating")
    self.rating_select.set_model(self.rating_liststore)
    self.where = ""
    self.add_date = False # builder.get_object("comboboxentry1") #To be added to GUI
    self.mybook = book.book()
    self.orig_book = book.book()
    self.status = builder.get_object("label_status")
    self.lent_date = builder.get_object("b_date")
    self.location_dropdown = builder.get_object("combobox_location")
    self.location_liststore = builder.get_object("liststore_locations")
    self.location_dropdown.set_model(self.location_liststore)
    self.location_dropdown.set_text_column(1)

    self.lent_select.set_model( self.lentlist)
    self.lent_select.set_text_column(1)

    self.o_date = ''
Exemple #10
0
    def __init__(self):
        self.librarian_list = []
        self.book_list = []
        self.student_list = []
        self.issued_books_list = []
        self.admin = admin()

        self.librarian_list.append(
            librarian("Omar", "Shahen77", "*****@*****.**", "Moustafa Kamel",
                      "Alexandria", "01065630331"))
        self.librarian_list.append(
            librarian("Ahmed", "Ahmed77", "*****@*****.**", "Smouha",
                      "Alexandria", "01006615471"))
        self.librarian_list.append(
            librarian("Youssef", "Youssef77", "*****@*****.**", "Abo 2ER",
                      "Cairo", "01111185001"))

        self.book_list.append(book("The 10X Rule", "Grant Cardone", "VIP", 7))
        self.book_list.append(book("The 5 AM Club", "Robin Sharma", "VIP", 5))
        self.book_list.append(book("Power of habbit", "Reda", "VIP", 1))
Exemple #11
0
 def addBook(self, author, title, year):
     print("1")
     b_id = len(self.bib)
     print("2")
     self.bib[b_id] = book.book(author, title, year, b_id)
     print("3")
     f = open('bd_dump' + self.name, 'wb')
     print("4")
     pickle.dump(self.bib, f)
     print("5")
     f.close()
     print("6")
     return b_id
def main():

    user_id = user_data_gathering()  # gather user input

    data = book(
        8, user_id
    )  # start data processing, specify the minimal score of the recommended books

    # retrive pretrained model
    with open("BX-CSV-Dump/explicit_rec.pkl", "rb") as fid:
        pretrain_model = pickle.load(fid)

    # create recommendation for the current user
    get_recommendations(pretrain_model, data['matrix'], user_id,
                        data['books_id'])
Exemple #13
0
 def on_button_clear_clicked(self, widget):
   ''' Clear all the edit boxes so A new book can be entered.
   '''
   self.isbn.set_text('')
   self.author.set_text('')
   self.title.set_text('')
   self.abstract.set_text('')
   self.publisher.set_text('')
   self.city.set_text('')
   self.year.set_text('')
   self.copies.set_text('')
   # Create a new empty book
   import book
   self.orig_book = book.book()
   self.mybook = copy.copy(self.orig_book)
   self.populate_borrowers()
   self.populate_locations()
   self.status.set_text(_("Everything cleared.  Enter new book's details."))
Exemple #14
0
 def __init__(self):
   self.abook = book.book()
   qr_img = ""
   #vid_dev = "/dev/video0" # Need to scan for this and make it work in windows?
   builder = gtk.Builder()
   self.gladefile = os.path.join(os.path.dirname(__file__),"ui/gui.glade")
   builder.add_from_file(self.gladefile)
   self.window = builder.get_object("window1")
   builder.connect_signals(self)
   self.text_view = builder.get_object("textview1")
   self.qr_img = builder.get_object("image1")
   self.cur = None
   try:
     self.db = MySQLdb.connect(host=db_host, db=db_base,  passwd = db_pass);
   except:
     print (_("No database connection.  Check config file"))
     self.db = False
   if self.db:
     self.cur = self.db.cursor()
Exemple #15
0
    def arrangeBook233(self, fixPath):
        # todo 现只用书名查找,书名+作者查找
        # 原因:原始书名经过格式化处理,没办法对应原作者
        # 对策:建立一个dataframe 存储格式化后的书名与作者
        originBook = pd.read_excel(self.originPath)
        resultBook = pd.read_excel(self.toPath)
        originName = set(originBook['name'].values)
        originNameFixed = []
        for name in originName:
            nameFixed = name.split('(')[0].split('(')[0]
            #bookName = name.split('\\')[-1].split('.')[0]
            #nameFixed = bookName.split('(')[0].split('(')[0]
            originNameFixed.append(nameFixed)
        toFindBook = (set(originNameFixed) - set(resultBook['name'].values))

        bookInfo = []
        for bookname in toFindBook:
            bookInfo.append(book.book(bookname).getBookInfo())
        #print(bookInfo)
        coloums = ['name', 'author', 'tags', 'rating', 'bookUrl', 'summary']
        df = DataFrame(bookInfo, columns=coloums)
        df.to_excel(fixPath)
Exemple #16
0
 def on_button_clear_clicked(self, widget):
   ''' Clear all the edit boxes so A new book can be entered.
   '''
   self.isbn.set_text('')
   self.author.set_text('')
   self.title.set_text('')
   textbuffer = self.abstract.get_buffer()
   textbuffer.set_text('') 
   self.publisher.set_text('')
   self.city.set_text('')
   self.year.set_text('')
   self.copies.set_text('')
   self.lent_select.set_active(0)
   #DEBUG(getpass.getuser())
   self.book_owner.set_text(str(getpass.getuser())) # Assume the user is the book owner.
 
   # Create a new empty book
   import book
   self.orig_book = book.book()
   self.mybook = copy.copy(self.orig_book)
   self.populate_borrowers()
   self.populate_locations()
   self.status.set_text(_("Everything cleared.  Enter new book's details."))
Exemple #17
0
def addBook():
    error = None
    if request.method == 'POST':
        global b
        global writer
        b = book.book(request.form['ISBN'], request.form['title'],
                      request.form['yearPublished'])
        writer = author.author(request.form['firstName'],
                               request.form['lastName'],
                               request.form['country'])
        if (db.bookExist(b) == False):
            try:
                db.addBook(b)
            except:
                error = 'Invalid Data. Please try again.'
            if (db.authorExist(writer) == False):
                try:
                    db.addAuthor(writer)
                except:
                    error = 'Invalid Data. Please try again.'
        try:
            db.authorId(writer)
        except:
            error = 'Author Not Correct For Book. Please try again.'
        if (db.readsExist(person, b) == False):
            try:
                db.addReads(person, b, request.form['rate'])
            except:
                error = 'Error. Please try again.'
        if (db.writesExist(writer, b) == False):
            try:
                db.addWrites(b, writer)
            except:
                error = 'Error HERE. Please try again.'

    return render_template('addBook.html', error=error)
Exemple #18
0
 def search(self, key_word, atype, start, count):
     print "search key :%s " % key_word
     print "atype :%d:" % atype
     if (atype == 0):
         stype = 'q'
     elif (atype == 1):
         stype = 'tag'
     else:
         print "atype error"
         return []
     params = urllib.urlencode({
         stype: key_word.encode('utf-8'),
         'start': start,
         'count': count
     })
     conn = httplib.HTTPConnection("api.douban.com")
     print params
     conn.request("GET", "/v2/book/search?%s" % params)
     r1 = conn.getresponse()
     print r1.status
     data = r1.read()
     #f=open("data.txt","w")
     #f.write(data)
     js = json.loads(data)
     jsbooks = js['books']
     #book array
     books = {}
     books['count'] = js['count']
     books['start'] = js['start']
     books['total'] = js['total']
     books['book_arr'] = []
     for item in jsbooks:
         mbook = book()
         mbook.load(item)
         books['book_arr'].append(mbook)
     return books
            with open('CorrectionRules.txt', 'r', encoding='utf-8') as myfile:
                fixes = myfile.read()
                lst = fixes.split('\n')

                for item in lst:
                    x = item.split()
                    d[x[0]] = x[1]

            fix = data.split(" ")
            for x, word in enumerate(fix):
                if word in d:
                    count += 1
                    fix[x] = d[word]
            fixed = ' '.join(fix)
            data = ''.join(c if c in whiteList else " " for c in fixed)

            currentBook = book(title, date, city, language, csvCode, lat, long,
                               oclc, country, data)
            bookList.append(currentBook)
            currentBook.printMe()
            print(count)

    #convert bookList to dict
    for book in bookList:
        bookDict[book.code] = book

    print(noCodeCount
          )  #creates new pickle file and saves bookDict for future use
    with open("booksFinal.txt", "wb") as fp:  #Pickling
        pickle.dump(bookDict, fp)
Exemple #20
0
from book import book

book = book('page', 'title')
book.page()
book.title()
Exemple #21
0
def book_r(book_id):
    return book.book(request.method, book_id, request.get_json())
Exemple #22
0
#                                                         :::      ::::::::    #
#    test.py                                            :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: lucdubos <*****@*****.**>                    +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2020/01/14 10:22:17 by lucdubos          #+#    #+#              #
#    Updated: 2020/01/14 14:41:33 by lucdubos         ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

from book import book
from recipe import Recipe

tarte = Recipe("tourte", 1, 15, ['lait', 'chocolat', 'pinguin'], 'lunch',
               'description de la tarte')

print(type(tarte))

to_print = str(tarte)
print(to_print)

livre = book("titre du livre", tarte)
print("BOOK :")

print(livre.recipes_list['lunch'][0].name)

#livre = book("nom du livre")
#print(livre.last_update)

#dict = {'starter':
    second=0,
    microsecond=0)

last_refresh = datetime.datetime.now(pytz.timezone('Hongkong'))

while not booked:

    # get the curent time
    time_now = datetime.datetime.now(pytz.timezone('Hongkong'))
    # get the time different from now to execution time
    time_diff = divmod((time_now - last_refresh).total_seconds(), 60)[0]

    # if current time is later then execution time, then book
    if time_now > booking_time:
        for i in range(duration_to_book):
            Book.book(login_detail[i], date_to_book,
                      xpath_elements[i]).execute()
        booked = True

    # if time difference between current time and last refresh time is more than 10 mins, refresh the page to prevent auto logout
    elif time_diff >= 10:
        for i in range(duration_to_book):
            login_detail[i][0].driver.refresh()
        last_refresh = time_now
        print('refreshed')

print(
    'Your booking request is successful... Please check your email for the confirmation.\n'
)
print('Until next time, bye~')
 def book(self):
     import book
     self.f.destroy()
     book.book(self.master)
Exemple #25
0
directions_cache = {}
stretch_cache = {}
starter = Root_Node()
for row in range(0, 6):
    for column in range(0, 7):
        directions_cache[(row, column)] = [x for x in dmap if 0 <= starter.traverse_step((row, column), x)[0] < 6
                                           and 0 <= starter.traverse_step((row, column), x)[1] < 7]
        for direction in dmap:
            current = 0
            path = starter.traverse((row, column), direction)
            while on_board(next(path)):
                current += 1
                stretch_cache[((row, column), direction)] = current
            

myBook = book()

if __name__ == "__main_1_" :
    connectfour = Search(Root_Node())
    connectfour.settings['current_time'] = 10000
    connectfour.settings['timebank'] = 10000
    connectfour.settings['time_per_move'] = 500
    connectfour.settings['round'] = 1   
    while True:
        read_line = stdin.readline()
        if len(read_line) == 0:
            break
        line = read_line.strip()
        if len(line) == 0:
            continue
        processed = line.split(" ")
Exemple #26
0
 def addBook(self, newBook):
     self._bookRepo.append(
         book(newBook[0], newBook[1], newBook[2], newBook[3], newBook[4]))
Exemple #27
0
def fetch_book(url, page):
    start_url, product_id, author = get_anchor(url)
    soup = BeautifulSoup(page, "lxml")
    i = 10
    try:
        details = soup.find("div", class_="product-details line")
        title = details.find("h1", class_="title").getText()
        avg_rating = soup.find_all("div", class_="fk-stars")['title']
    except:
        title = "None"
        avg_rating = "None"
    if title == "None":
        title = get_title(url)
    urls = generate_all_url(start_url)
    for url in urls:
        j = 0
        print url
        try:
            book_page = requests.get(url).text  
            j += 1
        except requests.exceptions.Timeout:
            # Maybe set up for a retry, or continue in a retry loop
            i = 0
        except requests.exceptions.TooManyRedirects:
            # Tell the user their URL was bad and try a different one
            i = 0
        except requests.exceptions.RequestException as e:
            # catastrophic error. bail.
            print e
            i = 0
            sys.exit(1)
        
        if i != 0:
            i, books = fetch_reviews(book_page)
            if len(books) != 0:
                for b in books:
                    new_book = book(title, author, product_id, avg_rating, b['review_id'], b['reviewed_by'], b['rating'], b['date'], b['heading'], b['review'])
                    if new_book.save_to_db():
                        print new_book.get_data()
                        gc.disable()   
                        del new_book # nothing gets deleted here
                        print "after"
                        gc.collect()
                        print gc.garbage # The GC knows the two Foos are garbage, but won't delete
                        # them because they have a __del__ method
                        print "after gc" 
            else:
                new_book = book(title, author, product_id, avg_rating, "None", "None", "None", "None", "None", "None")
                if new_book.save_to_db():
                    print new_book.get_data()
                    gc.disable()   
                    del new_book # nothing gets deleted here
                    print "after"
                    gc.collect()
                    print gc.garbage # The GC knows the two Foos are garbage, but won't delete
                    # them because they have a __del__ method
                    print "after gc" 
        elif i == 0:
            print "No more remains."
            break  
    return True
Exemple #28
0
from recipe import recipe
from book import book

tourte = recipe('tourte', 5, 6, ['a', 'b'], 'lunch', 'une tourte')
vomit = recipe('vomit', 4, 6, ['C', 'D'], 'anytime', 'always unexpected')
cookbook = book('cookbook')

cookbook.add_recipe(tourte)
cookbook.get_recipe_by_name('tourte')
cookbook.get_recipe_by_type('lunch')
cookbook.get_recipe_by_type(6)
cookbook.add_recipe(vomit)
cookbook.get_recipe_by_name('vomit')
 def add_book(self, author, title, year):
     b_id = len(self.bib)
     self.bib[b_id] = book.book(author, title, year, b_id)
     f = open('bd_dump'+self.name, 'wb')
     pickle.dump(self.bib, f)
     f.close()
Exemple #30
0
def parse_input(filename):

    f = open(filename)

    # Get parameters
    list_books = []
    list_libraries = []
    flag = 0

    for (counter, line) in enumerate(f):
        line_splitted = line.split()

        if len(line_splitted) == 0:
            break
        else:
            if counter == 0:
                nb_books = int(line_splitted[0])  # to check parsing is correct
                nb_libraries = int(
                    line_splitted[1])  # to check parsing is correct
                nb_days = int(line_splitted[2])

            elif counter == 1:
                for book_id, book_score in enumerate(line_splitted):
                    book_item = book(id=book_id, score=book_score)
                    list_books.append(book_item)
                    del book_item
                assert (len(list_books) == nb_books)

            else:

                if flag == 0:
                    library_item = library(sign_in_duration=line_splitted[1],
                                           max_number_books=line_splitted[2])

                    library_item.id = int(counter / 2)

                    nb_books_in_lib = int(
                        line_splitted[0])  # to check parsing is correct
                    flag += 1

                elif flag == 1:
                    library_item.books = []

                    for book_id_str in line_splitted:
                        book_id = int(book_id_str)
                        library_item.books.append(list_books[book_id])

                    assert (len(library_item.books) == nb_books_in_lib)
                    flag = 0

                    list_libraries.append(library_item)
                    del library_item

                else:
                    raise Exception("Parsing error: Flag greater than 1 ")

    f.close()
    print(
        f'File description: Days {nb_days} - nb_libraries {nb_libraries} - nb_books {nb_books} '
    )
    assert (len(list_libraries) == nb_libraries)
    return nb_days, list_libraries, list_books
Exemple #31
0
    def loadfile(self):
        ##	add check if file open, then close it
        self.bookobject = book.book()

        success = self.bookobject.openpdf(self.filepath)

        if success == None:  ##	no problems

            #if self.bookobject.filelist:

            #	self.out.removeAll()
            #	self.out.add(self.outlist)

            self.picked.setText(self.filename)

            pagesize = self.bookobject.currentdoc.getBoxSize(1, 'crop')

            if pagesize:
                print "crop pagesize", pagesize
                print "media pagesize", self.bookobject.currentdoc.getBoxSize(
                    1, 'media')

            if not pagesize:
                pagesize = self.bookobject.currentdoc.getBoxSize(1, 'media')

            pagex, pagey = self.bookobject.getpagesize(str(pagesize))

            x = self.points2units(pagex)
            y = self.points2units(pagey)
            ratio = x / y
            ratstring = str(ratio)

            self.psize.setText(self.psizetext +
                               str(int(self.points2units(x))) + ' x ' +
                               str(int(self.points2units(y))))
            self.npages.setText(
                self.npagestext +
                str(self.bookobject.currentdoc.getNumberOfPages()))
            self.proportion.setText(self.proportiontext +
                                    ratstring[:4])  #"%f" % ratio)#str(ratio))#

            self.setparameters(None)
            self.xpoints = x
            self.ypoints = y
            #print type(x) #it's a float

            self.repaint()

        else:  ##	we have an error

            errorid = self.errorstring(success)
            print 'errorid', success
            print 'errorid', errorid

            if errorid == 'Bad user Password':

                self.dialogbox = JDialog(self, ' Password required', 0)
                self.dia.setSize(200, 100)
                x = self.getWidth()
                y = self.getHeight()

                xoff = (x / 2) - 100
                yoff = (y / 2) - 50
                self.dia.setLocation(xoff, yoff)

                label = JLabel('Enter User Password', 0)
                self.passfield = JPasswordField(30,
                                                actionPerformed=self.passinput)

                panel = JPanel(GridLayout(0, 1))
                panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5))
                panel.add(label)
                panel.add(self.passfield)
                self.dia.setContentPane(panel)

                self.dia.setVisible(1)

            elif errorid == 'PDF header signature not found.':

                self.infodialog('Error loading PDF',
                                "This file isn't a valid PDF")

            else:

                self.infodialog('Error loading PDF',
                                "Undefined error ??" + errorid)
Exemple #32
0
 def add_book(self):
     bk = book()
     bk.input()
     self.container.append(bk)
import random 
import sys
from histogram import histogram
from book import book


def sample_dict(hist):
    random_index = random.randint(0, sum(hist.values()))
    total = 0
    for word,count in hist.items():
        total += count
        if total >= random_index:
            return word


if __name__ == "__main__":
    text = book("words.txt")
    hist = histogram(text)
    args = sys.argv[:1]
    print(sample_dict(hist))
from book import book
from library import library
from library_log import library_log

ll = library()
ll.sign_in_duration = 10

print(ll.id, ll.sign_in_duration)

b = book()
library.books = [b]

print(library.books)

log = library_log()
log.library = ll
log.start_day = 1

print(log.getEndDaySignIn())
 def addBook(self, author, title, year):
     b_id = len(self.bib)
     self.bib[b_id] = book.book(author, title, year, b_id)
     f = open('bd_dump' + self.name, 'wb')
     pickle.dump(self.bib, f)
     f.close()
@bottle.route('/newguest', method='POST')
def insert_newguest():
    name = bottle.request.forms.get("name")
    email = bottle.request.forms.get("email")
    book.insert_name(name, email)
    bottle.redirect('/')


"""
Se configura la conexion de datos
"""
"""
Configura una conexion string al servidor local
"""
connection_string = "mongodb://localhost"
"""
Gestiona la conexion entre MongoDB y PyMongo, PyMongo maneja nuestro pool
"""
connection = pymongo.MongoClient(connection_string)
#Now we want to set a context to the names database we created using the mongo interactive shell
"""
Enviamos la base de datos de nombres al shell de mongo
"""
database = connection.names
"""
Se adjunta la data u objeto
"""
book = book.book(database)

bottle.debug(True)
bottle.run(host='localhost', port=8082)
Exemple #37
0
    def add_book(self, bookName, bookAuthor, bookPublisher, bookQuantity):

        bookObj = book(bookName, bookAuthor, bookPublisher, bookQuantity)
        self.book_list.append(bookObj)
        print('Book is added Successfully')