def test_crud():
    company = Company()
    session.add(company)

    assert [] == crud.object_list(session, company, MyModel)

    obj = crud.create(session, company, MyModel, name='xxx')
    assert obj.name == 'xxx'
    session.commit()

    read_obj = crud.read(session, company, MyModel, obj.id)
    assert read_obj == obj
    assert 1 == crud.object_count(session, company, MyModel)
    assert [read_obj] == crud.object_list(session, company, MyModel)

    crud.update(session, company, MyModel, obj.id, name='aaa')
    session.commit()

    update_obj = crud.read(session, company, MyModel, obj.id)
    assert update_obj.name == 'aaa'

    crud.delete(session, company, MyModel, obj.id)
    delete_obj = crud.read(session, company, MyModel, obj.id)
    assert delete_obj is None

    assert 0 == crud.object_count(session, company, MyModel)
Esempio n. 2
0
async def main(count: Optional[int] = None,
               source: Optional[str] = None,
               iD: Optional[str] = None,
               link: Optional[str] = None):
    if source is None:
        if iD is None:
            if link is None:
                result = crud.read(count=count)
            else:
                result = crud.read(link=link)
        else:
            result = crud.read(id=iD)
    else:
        result = crud.read(count=count, source=source)
    return result
Esempio n. 3
0
def get_files():
    repeat = True
    while repeat:
        print("Alle CSV-Dateien:\n")
        file = crud.get_all_csv_and_json()
        answer = input(
            "Welche CSV-Datei wollen Sie laden? ('cancel' für Abbrechen)")

        if answer.isnumeric():
            answer_int = int(answer)

            if answer_int > 0 and answer_int <= len(file):
                global path
                path = file[answer_int - 1]
                global contacts

                # Überprüfe Dateiendung und rufe READ-Funktion auf.
                file_type = get_file_type(path)
                contacts = crud.read(path, file_type)

                print("\nDatei geladen!\n")

                return
            else:
                print("\nFalsche Eingabe!\n")

        elif answer == "cancel":
            return
        else:
            print("\nFalsche Eingabe!\n")
Esempio n. 4
0
def api_sources():
    if request.method != 'GET':
        return make_response('Malformed request', 400)

    result = crud.read(give_sources=1)

    return jsonify(result)
Esempio n. 5
0
def api_filter():
    if request.method != 'GET':
        return make_response('Malformed request', 400)

    query_parameters = request.args
    source = query_parameters.get('source')
    count = query_parameters.get('count')
    iD = query_parameters.get('_id')
    link = query_parameters.get('link')

    if source is None:
        if iD is None:
            if link is None:
                result = crud.read(count=int(count))
            else:
                result = crud.read(link=str(link))
        else:
            result = crud.read(id=iD)
    else:
        result = crud.read(count=int(count), source=source)

    return jsonify(result)
Esempio n. 6
0
def check_if_saved():
    repeat = True
    while repeat:
        if len(path) == 0 and len(contacts) > 0:
            answer = input(
                "Es gibt nicht gespeicherte Änderungen. Möchten Sie jetzt Speichen? (j/n)"
            )
            if answer == "j":
                save(contacts)
                repeat = False
                print("Erfolgreich gespeichert. Auf Wiedersehen!")
            elif answer == "n":
                repeat = False
                print("Auf Wiedersehen!")
            else:
                print("Falsche Eingabe")

        elif len(path) > 0:
            old_contacts = crud.read(path)
            if contacts == old_contacts:
                answer = input(
                    "Es gibt nicht gespeicherte Änderungen. Möchten Sie jetzt Speichen? (j/n)"
                )
                if answer == "j":
                    save(contacts)
                    repeat = False
                    print("Erfolgreich gespeichert. Auf Wiedersehen!")
                elif answer == "n":
                    repeat = False
                    print("Auf Wiedersehen!")
                else:
                    print("Falsche Eingabe")
            else:
                repeat = False
                print("Auf Wiedersehen")
        else:
            repeat = False
            print("Auf Wiedersehen!")
Esempio n. 7
0
import models as m
import schemas as s
import crud

department = crud.read(m.Department)[1]
students = m.Student.get_honored_by_department(department)
for student in students:
    print(student.grades)

curator = crud.read(m.Curator)[0]
students = m.Student.get_students_by_curator(curator)
for student in students:
    print(student.curator)
Esempio n. 8
0
    # 3 - To Update selected Password
    # 4 - To Delete selected Password
    # 5 - To Exit The Application

    choice = input(
        "Enter the number of the operation you would like to perform: ")

    if choice == "1":
        website_to_create = input(
            "\nEnter the website for which you want the password to be created: "
        )
        password_to_create = input("Enter the password: "******"2":
        website_to_read = input("\nEnter the name of the website: ")
        read(website_to_read)
    elif choice == "3":
        website_to_update = input(
            "\nEnter the website for which you want the password to be updated: "
        )
        password_to_update = input("Enter the new password: "******"4":
        website_to_delete = input(
            "\nEnter the website for which you want the password to be deleted: "
        )
        delete(website_to_delete)
    elif choice == "5":
        print("Goodbye!")
        quit()
else:
Esempio n. 9
0
def update():
    CChis = []
    res = []
    details = []
    Municipio = ""
    Casos = ""
    Tasa = ""
    datos = urllib.request.urlopen(
        'http://coronavirus.saludchiapas.gob.mx/casos-por-municipio').read(
        ).decode()

    soup = BeautifulSoup(datos)
    os.system("cls")
    ################################################## Detalles de Chiapas
    tags = soup.find_all('h5', class_='card-title')
    for itemC in tags:
        num = itemC.get_text()
        CChis.append({'num': num})
    ################################################## Historial
    table = soup.find('table', class_='table')

    for fila in table.find_all("tr"):
        #if nroFila==2:
        nroCelda = 0
        for celda in fila.find_all('td'):
            if nroCelda == 0:
                Municipio = celda.text
                #print("Municipios:", Municipio)

            if nroCelda == 1:
                Casos = celda.text
                #print("Casos:", Casos)

            if nroCelda == 2:
                Tasa = celda.text
                res.append({
                    'Municipio': Municipio,
                    'Casos': Casos,
                    'Tasa': Tasa
                })
                #print("Tasa", Tasa)

            nroCelda = nroCelda + 1
    #nroFila=nroFila+1

    if len(crud.read('History')) == len(res):
        print("No hay cambios")
    else:

        for itemD in crud.read('ActualChis'):
            crud.delete('ActualChis', itemD)
        for item in CChis:
            crud.create('ActualChis', item)

        for itemD in crud.read('History'):
            crud.delete('History', itemD)
        for itemN in res:
            crud.create('History', itemN)
        print('Datos actualizados con exito')

    return 'Datos Actualizados'
Esempio n. 10
0
        # 8. Brute Force
        elif option == '8':
            decrypt.brute_force()

        else:
            # Decrypt Message with the Key
            decryptedMessage = decrypt.decode_message(key)

            # 1. Show Password Table
            if option == '1':
                view.showPasswordTable(decryptedMessage, True)

            # 2. Search
            elif option == '2':
                crud.read(decryptedMessage)

            # 3. Add Password
            elif option == '3':
                crud.input_password(decryptedMessage, key)

            # 4. Edit Password
            elif option == '4':
                crud.edit_password(decryptedMessage, key)

            # 5. Remove Password
            elif option == '5':
                crud.remove_password(decryptedMessage, key)

            # 6. Show Password Hash
            elif option == '6':