コード例 #1
0
ファイル: book_func.py プロジェクト: Bhu1Singh/python-lms
def handle_add_new_book():
    book_name = ''
    while True:
        book_name = input("Enter the book name: ")
        if len(book_name) > 0 and str.strip(book_name) != '':
            break
        print('Book name is mandatory!')

    book_writer = ''
    while True:
        book_writer = input('Enter book writer name: ')
        if len(book_writer) > 0 and str.strip(book_writer) != '':
            break
        print("Book writer is mandatory!")

    book = books()
    book.bookName = book_name
    book.bookWriter = book_writer

    add_new_book(book)

    print("\n")
    while True:
        nxt = input(
            "Enter 1 for adding another book or press any other key to return to main menu..."
        )

        if nxt == '1':
            handle_add_new_book()
            break
        else:
            return
コード例 #2
0
def process_search_history_result(book_result : list) -> list:
    book_list = []
    for row in book_result:
        book = books()
        book.bookID = row[0]
        book.bookName = row[1]
        book.bookIssueStatus = row[2]
        book.bookIssuedOn = row[3]
        book.bookReturnDate = row[4]

        book_list.append(book) 

    return book_list
コード例 #3
0
def process_search_result(book_result : list) -> list:
    book_list = []
    for row in book_result:
        book = books()
        book.bookID = row[0]
        book.bookName = row[1]
        book.bookWriter = row[2]
        book.bookRegistrationDate = row[3]
        book.bookIssuedTo = row[4]

        book_list.append(book) 

    return book_list
コード例 #4
0
 def route_book():
     return books(data, arr)
コード例 #5
0
ファイル: importBooks.py プロジェクト: boh1996/LectioAPI
def importBooks ( school_id, branch_id, student_id, session = False, username = False, password = False ):
	try:
		objectList = booksApi.books({
			"school_id" : school_id,
			"branch_id" : branch_id,
			"student_id" : student_id,
			"username" : username,
			"password" : password
		}, session)

		if objectList is None:
				error.log(__file__, False, "Unknown Object")
				return False

		if not "status" in objectList:
			error.log(__file__, False, "Unknown Object")
			return False

		if objectList["status"] == "ok":
			books = []

			for row in objectList["loans"]:
				unique = {
					"title" : row["title"]
				}

				element = {
					"title" : row["title"],
					"price" : row["price"]
				}

				status = sync.sync(db.books, unique, element)

				row["_id"] = status["_id"]

				existing = db.team_elements.find({"name" : row["team_name"], "school_id" : str(school_id), "branch_id" : str(branch_id)})

				if existing.count() > 0:
					if "team_id" in existing[0]:
						row["team_id"] = existing[0]["team_id"]

					row["team_element_id"] = existing[0]["team_element_id"]
				else:
					existing = db.teams.find({"name" : row["team_name"], "school_id" : str(school_id), "branch_id" : str(branch_id)})

					if existing.count() > 0:
						row["team_id"] = existing[0]["team_id"]

				books.append(row)

			unique = {
				"student_id" : str(student_id)
			}

			element = {
				"student_id" : str(student_id),
				"books" : books
			}

			status = sync.sync(db.persons, unique, element)

		else:
			if "error" in objectList:
				error.log(__file__, False, objectList["error"])
				return False
			else:
				error.log(__file__, False, "Unknown error")

	except Exception, e:
		error.log(__file__, False, str(e))
		return False
コード例 #6
0
import tsv
import codecs
from glob import glob
from os.path import join, dirname, basename
from re import escape, compile as re, IGNORECASE
DIR = join(dirname(__file__), "archive", "books")

import books as BOOKS
books = BOOKS.books()

file = codecs.open("names.tsv", "r", "utf-8")
NAMES = list(tsv.DictReader(file))

canonicals = {}
for name in NAMES:
    canonicals.setdefault(name["Name"].lower(), set()).add(name["Canonical"])

# grand regular expression for finding all names
names_expression = ur"(?<![A-Za-z])(?:%s)(?![A-Za-z])" % u"|".join(
    escape(name["Name"]).replace(ur"\ ", ur"\s+")
    for name in sorted(
        NAMES,
        key=lambda name: -len(name["Name"])
    )
    if not name["Constructed"]
)
names_re = re(names_expression)
names_insensitive_re = re(names_expression, IGNORECASE)

space_re = re(ur"\s+")
コード例 #7
0
ファイル: bookmanager.py プロジェクト: hemanth42/holodeck
# Main python console app which accesses the books class and contains the CLI UI

# Author : Hemanth. A

import sys

from books import books


app = books()

def prompt():
    ch = input("Do you want to see anything else? (y/n) \n")
    if ch == 'y':
        main()
    elif ch == 'n':
        exit()
    else:
        print("Invalid Input! \n")
        prompt()

def add():

    title = input("What's the Title Of The Book:  \n")
    author = input("Who's the Author Of The Book? \n")
    rating = input("Rate this book (on a scale of 1 to 5)? \n")
    comment = input("Any Comments Regarding This Book? \n")

    try:
        app.addbook(title,author,rating,comment)
        print("Your Book Has Been Added!")
コード例 #8
0
 def notations(self):
     self.booksInstance = books()
     self.booksInstance.deviceLogin(loginPage)
     self.bookInstance.setNotation()