def __init__(self, name, email, password):
        self.get_date()

        self.person = Person(name, email, password)
        self.name = 'Name: {}'.format(self.person.get_name())
        self.email = 'Email: {}'.format(self.person.get_email())
        self.password = '******'.format(self.person.get_password())

        self.print_console()
 def btnAddActionPerformed(self):
     fullName = self.__txtFullName.get()
     address = self.__txtAddress.get()
     phoneNumber = self.__txtPhoneNumber.get()
     if len(fullName) > 0 and len(address) > 0 and len(phoneNumber) > 0:
         try:
             customer = Person(fullName, address, phoneNumber)
             if self.__customers.__contains__(customer):
                 messagebox.showerror(
                     "Error", "Customer information already exists!")
             else:
                 customer = Customer("", fullName, address, phoneNumber)
                 customer.fixId()
                 self.__parent.addCustomerCallBack(customer)
                 messagebox.showinfo("Success",
                                     "A new customer has been added")
                 self.showDefaultText()
         except Exception:
             messagebox.showerror("Error", "Invalid information format!")
     else:
         messagebox.showerror("Error", "Input fields cannot be left blank!")
Beispiel #3
0
def init(window):
    window.bkgd(curses.color_pair(2))
    window.clear()
    window.box()
    window.keypad(False)

    window.addstr(0, 2, "NEW GAME")

    curses.echo()

    window.addstr(1, 4, "Enter the name of the game:   ")
    gameName = ''

    while len(gameName) == 0:
        gameName = window.getstr(1, 32)

        if len(gameName) == 0:
            window.addstr(1, 60, "The game name cannot be empty")
        else:
            window.addstr(1, 60, "                             ")

    participantsCount = 0
    participants = []

    while participantsCount < 2:
        window.addstr(2, 4, "Enter the number of participants:   ")

        participantsCount = int(window.getstr(2, 38))

        if participantsCount < 2:
            window.addstr(2, 60, "More then 1 participant needed")
        else:
            window.addstr(2, 60, "                              ")

    i = 0
    while i < participantsCount:
        window.addstr(i + 3, 4,
                      "Enter the name of participant " + str(i + 1) + ": ")
        participantName = window.getstr(i + 3, 38)

        if len(participantName) == 0:
            window.addstr(i + 3, 60, "The name cannot be empty")
        else:
            window.addstr(i + 3, 60, "                        ")
            participants.append(Person(participantName))
            i += 1

    game = Game(str(gameName, "utf-8"), participants)

    curses.noecho()
    return game
    def generate_random_persons(self) -> list:
        """Generate random persons by given names from configuration file"""
        persons = list()

        for person in itertools.product(self._first, self._last):
            persons.append(
                Person(person[0], person[1], int(random.choice(range(1, 70)))))

        try:
            with open('./resource/all_person.json', 'w') as f:
                f.write(json.dumps(persons, indent=4, cls=PersonEncoder))
        except FileNotFoundError as e:
            print(e)
        finally:
            f.close()

        return persons
class Register_Control:
    def __init__(self, name, email, password):
        self.get_date()

        self.person = Person(name, email, password)
        self.name = 'Name: {}'.format(self.person.get_name())
        self.email = 'Email: {}'.format(self.person.get_email())
        self.password = '******'.format(self.person.get_password())

        self.print_console()

    def get_date(self):
        self.current_date = datetime.datetime.now()

        self.text_date = '{}_{}_{}'.format(self.current_date.day,
                                           self.current_date.month,
                                           self.current_date.year)
        self.text_time_data = 'Date created: {}'.format(
            self.current_date.strftime("%d/%m/%Y  %H:%M"))

    def print_console(self):
        print(
            '\n Name: ', self.person.get_name(), \
            '\n Email: ', self.person.get_email(), \
            '\n Password: '******'Pasta criada com sucesso!')

            self.file_name = self.dir_path + '/' + self.folder + '/{}_{}.log'.format(
                self.person.get_name(), self.text_date)
            self.file = open(self.file_name, 'w')

            self.file.write(self.name)
            self.file.write('\n')
            self.file.write(self.email)
            self.file.write('\n')
            self.file.write(self.password)
            self.file.write('\n')
            self.file.write(self.text_time_data)

            self.person = {
                "nome": self.name,
                "email": self.email,
                "senha": self.password
            }

            PersonDAO().insert(self.person)

        except:
            print('\n Error saving data')

        finally:
            self.file.close()
            print('\n Data saved successfully')
Beispiel #6
0
 def get(self):
     return Person.person_death(db)
Beispiel #7
0
 def get(self):
     return Person.person_race(db)
Beispiel #8
0
 def get(self):
     return Person.person_ethnicity(db)
Beispiel #9
0
 def get(self):
     return Person.person_gender(db)
Beispiel #10
0
 def get(self):
     return Person.person_total(db)
Beispiel #11
0
from pyspark.sql import SparkSession
from pyspark.sql.functions import first,trim,lower,ltrim,initcap,format_string,coalesce,lit,col
from model.Person import Person

if __name__ == '__main__':
    # Create the SparkSession
    spark = SparkSession \
        .builder \
        .appName("DSL examples") \
        .master('local[*]') \
        .getOrCreate()
    spark.sparkContext.setLogLevel('ERROR')

    people_df = spark.createDataFrame([
        Person("Sidhartha", "Ray", 32, None, "Programmer"),
        Person("Pratik", "Solanki", 22, 176.7, None),
        Person("Ashok ", "Pradhan", 62, None, None),
        Person(" ashok", "Pradhan", 42, 125.3, "Chemical Engineer"),
        Person("Pratik", "Solanki", 22, 222.2, "Teacher")
    ])

    people_df.show()
    people_df.groupBy("firstName").agg(first("weightInLbs")).show()
    people_df.groupBy(trim(lower(col('firstName')))).agg(first("weightInLbs")).show()
    people_df.groupBy(trim(lower(col("firstName")))).agg(first("weightInLbs", True)).show()
    people_df.sort(col("weightInLbs").desc()).groupBy(trim(lower(col("firstName")))).agg(first("weightInLbs", True)).show()
    people_df.sort(col("weightInLbs").asc_nulls_last()).groupBy(trim(lower(col("firstName")))).agg(first("weightInLbs", True)).show()

    corrected_people_df = people_df\
        .withColumn("firstName", initcap("firstName"))\
        .withColumn("firstName", ltrim(initcap("firstName")))\
Beispiel #12
0
# uncle_bob.save()  # bob is now stored in the database

# grandma = Person.create(name='Grandma', birthday=date(1935, 3, 1), is_relative=True)
# herb = Person.create(name='Herb', birthday=date(1950, 5, 5), is_relative=False)

# grandma = Person.create(name='Grandma', birthday=date(1935, 3, 1), is_relative=True)
# grandma.name = 'Grandma L.'
# grandma.save()  # Update grandma's name in the database.

# bob_kitty = Pet.create(owner=uncle_bob, name='Kitty', animal_type='cat')
# herb_fido = Pet.create(owner=herb, name='Fido', animal_type='dog')
# herb_mittens = Pet.create(owner=herb, name='Mittens', animal_type='cat')
# herb_mittens_jr = Pet.create(owner=herb, name='Mittens Jr', animal_type='cat')

print("Select persons:")
for person in Person.select():
    print(person.name, person.is_relative)

print()
print("Select pets with additional queries:")
query = Pet.select().where(Pet.animal_type == 'cat')
for pet in query:
    print(pet.name, pet.owner.name)

print()
print("Select pets with join:")
query = (Pet.
         select(Pet, Person).
         join(Person).
         where(Pet.animal_type == 'cat'))
for pet in query:
Beispiel #13
0
'''
Created on 1 mars 2019

@author: nioannou
'''
import sys

print(sys.version)

from model.Person import Person
if __name__ == '__main__':
    person = Person()
    print('User Abbas has been added with id ', person.set_name('Abbas'))
    print('User associated with id 0 is ', person.get_name(0))