예제 #1
0
def _load_data(destination, path):
    data = read(path)
    if destination == 'G':
        destination = 'groups'
    elif destination == 'P':
        destination = 'persons'

    data_names = data[destination]
    return data_names
예제 #2
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller

        reading.read(self, '2', controller.shared_data["2ndplace"])
        controller.shared_data['2ndplace'].set('No Vote')

        button1 = tk.Button(self, text='Previous', command=lambda : \
                            self.previous())
        button2 = tk.Button(self, text='Next', command=lambda : \
                            self.next())
        button3 = tk.Button(self,
                            text='Discard Ballot',
                            command=lambda: controller.restart_program())
        button4 = tk.Button(self, text='More Info', command=lambda : \
                            popup.popupmsg(self,controller.helv28b))

        button1.place(relx=0.1, rely=0.75, relwidth=0.2, relheight=0.1)
        button2.place(relx=0.3, rely=0.75, relwidth=0.2, relheight=0.1)
        button3.place(relx=0.7, rely=0.75, relwidth=0.2, relheight=0.1)
        button4.place(relx=0.5, rely=0.75, relwidth=0.2, relheight=0.1)
예제 #3
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller

        reading.read(self, '1', controller.shared_data["1stplace"])
        controller.shared_data["1stplace"].set("No Vote")

        button1 = tk.Button(self,
                            text="Previous",
                            command=lambda: controller.show_frame("PageOne"))
        button2 = tk.Button(self, text="Next", command=lambda: self.next())
        button3 = tk.Button(self,
                            text="Discard Ballot",
                            command=lambda: controller.restart_program())
        button4 = tk.Button(
            self,
            text="More Info",
            command=lambda: popup.popupmsg(self, self.controller.helv28b))

        button1.place(relx=0.1, rely=0.75, relwidth=0.2, relheight=0.1)
        button2.place(relx=0.3, rely=0.75, relwidth=0.2, relheight=0.1)
        button3.place(relx=0.7, rely=0.75, relwidth=0.2, relheight=0.1)
        button4.place(relx=0.5, rely=0.75, relwidth=0.2, relheight=0.1)
예제 #4
0
def queries_popular(timestamp):
    try:
        count = int(request.args.get('size', 3))
    except ValueError:
        response = {'detail': 'count is not a number'}
    else:
        if count > MAX_POPULAR_COUNT:
            response = {
                'detail': 'count max value: {}'.format(MAX_POPULAR_COUNT)
            }
        else:
            response = {'queries': read(timestamp, count)['queries']}

    return jsonify(response)
예제 #5
0
def check_date(destination,path):
    if destination == 'G':
        destination = 'groups'
    elif destination == 'P':
        destination = 'persons'
    # Inicializo la fecha actual
    today = datetime.now()
    #Traigo los datos 
    data = read(path)
    data_names = data[destination]
    data_of_the_day = []

    for name, value in data_names.items():
        day = check_day(value[1][1], today)
        if day == True:
            tiempo = check_time(value[1][0], today, name)
            if tiempo == True:
                data_of_the_day.append(name)
    
    return data_of_the_day
예제 #6
0
def test():
    setup()
    for query, count, populars in [
        ('2015-08-01 00:00', 5, {
            'query1': 10,
            'query2': 4,
            'query3': 3
        }),
        ('2015-08-01 00', 9, {
            'query1': 10,
            'query6': 5,
            'query2': 4
        }),
        ('2015-08-01', 13, {
            'query1': 10,
            'query10': 6,
            'query6': 5
        }),
        ('2015-08', 17, {
            'query1': 10,
            'query14': 7,
            'query10': 6
        }),
        ('2015', 21, {
            'query1': 10,
            'query18': 8,
            'query14': 7
        }),
    ]:
        result = read(query, 3, 'tests')
        print(query, result['count'],
              {r['query']: r['count']
               for r in result['queries']})
        assert result['count'] == count
        assert {r['query']: r['count'] for r in result['queries']} == populars

    print('Tests OK')
def borrow():
    f = open(
        "invoice.txt", "a+"
    )  #creating invoice file inside the function so that the file is created when the function is called
    f.write(
        "--------------------------------------invoice of library----------------------------------------"
    )  #writing value in invoice
    time = str(
        datetime.datetime.now())  #assign converter dateand time to a variable
    f.write("\t\t\t" +
            time)  #use the converted variable to have the date an dtime
    f.write("\n" + "\tYou have borrowed" + " ")
    f.close()
    while True:
        reading.read()  #calling the function inside the while loop
        try:  #first try this then if any error occurs then the exceopt code is run
            book = input("Enter the book no. from above list: "
                         )  #asking the usr to enter the book code
            if book == "c01":
                book1 = int(
                    input(
                        "How many book of \"Brokenwing \"you want to borrow:"))
                if (
                        book1 > int(listed[0][2]) or int(listed[0][2]) < 0
                ):  #comparing the user inputvalue with the listed quantity value to check the no of book
                    print("Out of stock")
                    continue
                else:
                    print("you have borrowed ", book1,
                          "of" + " " + listed[0][0])
                    listed[0][2] = str(
                        int(listed[0][2]) - book1
                    )  #list is updated as per the vlue given by ht user
                    f = open("invoice.txt", "a")
                    f.write(str(book1) + " " + "book of Brokenwing")
                    f.write("\n \tTotal book borrowed:" + str(book1))
                    f.write("\n \tRate of 1 book($):" + listed[0][3])
                    f.write("\n \tTotal amount:" +
                            str(book1 * int(listed[0][3])) + "$")
                    f.close()

            elif book == "c02":
                book2 = int(
                    input(
                        "How many book of \"Muna Madan \"you want to borrow:"))
                if (book2 > int(listed[1][2]) or int(listed[1][2]) < 0):
                    print("out of stock")
                    continue
                else:
                    print("you have borrowed ", book2,
                          "of" + " " + listed[1][0])
                    listed[1][2] = str(int(listed[1][2]) - book2)
                    f = open("invoice.txt", "a")
                    f.write(str(book2) + " " + "book of Muna Madan")
                    f.write("\n \tTotal book borrowed:" + str(book2))
                    f.write("\n \tRate of 1 book($):" + listed[1][3])
                    f.write("\n \tTotal amount:" +
                            str(book2 * int(listed[1][3])) + "$")
                    f.close()

            elif book == "c03":
                book3 = int(
                    input(
                        "How many book of \"Summer love\" you want to borrow:")
                )
                if book3 > 20:
                    print(book3 > int(listed[2][2]) or int(listed[2][2]) < 0)
                    continue
                else:
                    print("you have borrowed ", book3,
                          "of" + " " + listed[2][0])
                    listed[2][2] = str(int(listed[2][2]) - book3)
                    f = open("invoice.txt", "a")
                    f.write(str(book3) + " " + "book of Brokenwing")
                    f.write("\n \tTotal book borrowed:" + str(book3))
                    f.write("\n \tRate of 1 book($):" + listed[2][3])
                    f.write("\n \tTotal amount:" +
                            str(book3 * int(listed[2][3])) + "$")
                    f.close()

            elif book == "c04":
                book4 = int(
                    input(
                        "How many book of \"Programming Python \" you want to borrow:"
                    ))
                if (book4 > int(listed[3][2]) or int(listed[3][2]) < 0):
                    print("Out of stock")
                    continue
                else:
                    print("you have borrowed", book4,
                          "of" + " " + listed[3][0])
                    listed[3][2] = str(int(listed[3][2]) - book4)
                    f = open("invoice.txt", "a")
                    f.write(str(book4) + " " + "book of Brokenwing")
                    f.write("\n \tTotal book borrowed:\t" + str(book4))
                    f.write("\n \tRate of 1 book($):\t" + listed[3][3])
                    f.write("\n \tTotal amount" +
                            str(book4 * int(listed[3][3])) + "$")
                    f.close()
            else:
                print("!!please enter the valid no from above list")
                continue
            f = open("invoice.txt", "a")
            f.write(
                "\n------------------------lending duration is 10 days--------------------------"
            )  #writing value in invoice
            f.write(
                "\n-----------------------------VISIT-AGAIN--------------------------------------"
            )  #writing value in invoice
            f.close()

        except (SyntaxError):
            print("Value not recognized. Retry")
            continue
        ask = input("Do you want to Borrow anything(y/n)")

        if ask == "y":
            continue
        else:

            print("Thank you for visiting ")
            break
def returned():
    w=open("return_invoice.txt","a")
    w.write("---------------------Return-Book-Invoice----------------------")
    time=str(datetime.datetime.now())
    w.write("\t\t\t"+time)
    w.write("\nyou have returned")
    w.close()
    while True:
        reading.read()
           #asking for usr to input the valid book id of which book you want to return    
        print("which book you want to return")
        choice=input("please inter the book code you want to return:")
        c1=int(input("how many days you have book:"))
        if c1>10:
            print("!!!Extra charge for late returning(0.25$ for each day!!!)")#promting the late submission error
            a=str((c1-10)*0.25)#fine been charged according to the extra no of days they have kept the book for 
            
        if choice=="c01":
            cho1=int(input("how many book you want to return"))
            listed[0][2]=str(int(listed[0][2])+cho1)
            w=open("return_invoice.txt","a")
            w.write(str(cho1)+" "+"books")
            w.close()
            
        elif choice=="c02":
            cho2=int(input("how many book you want to return"))
            listed[1][2]=str(int(listed[1][2])+cho2)
            w=open("return_invoice.txt","a")
            w.write(str(cho2)+" "+"books")
            w.close()

        elif choice=="c03":
            cho3=int(input("how many book you want to return"))
            listed[2][2]=str(int(listed[1][2])+cho3)
            w=open("return_invoice.txt","a")
            w.write(str(cho3)+" "+"books")
            w.close()

        elif choice=="c04":
            cho4=int(input("how many book you want to return"))
            listed[3][2]=str(int(listed[3][2])+cho4)
            w=open("return_invoice.txt","a")
            w.write(str(cho4)+" "+"books")
            w.close()

        else:
            print("Enter a valid book id")
            continue
        if c1>10:
            
            w=open("return_invoice.txt","a")
            w.write("\nfine for late Submission($):"+a)
            w.close()
            
        w=open("return_invoice.txt","a")
        w.write("---------------------------Visit-Again----------------------------")
        w.close()

        other=input("Do you want to return any other book (y/n)")
        if other=="y":
            
            continue
        
        else:
            print("Thank you for visiting")
            break
예제 #9
0
def queries_count(timestamp):
    return jsonify({'count': read(timestamp, 1)['count']})