예제 #1
0
def add_friend():

    new_friend = Spy('', '', 0, 0.0)  #adding a new friend on account a spy

    #taking friend's details
    new_friend.name = raw_input("Please add your friend's name: ")
    new_friend.salutation = raw_input("Are they Mr. or Ms.?: ")

    new_friend.name = new_friend.salutation + " " + new_friend.name

    new_friend.age = raw_input("Age?")
    new_friend.age = int(new_friend.age)

    new_friend.rating = raw_input("Spy rating?")
    new_friend.rating = float(new_friend.rating)

    #checking for authenticity of a friend
    if len(new_friend.name
           ) > 0 and new_friend.age > 12 and new_friend.rating >= spy.rating:
        friends.append(new_friend)
        print 'Friend Added!'
    else:
        print 'Sorry! Invalid entry. We can\'t add spy with the details you provided'

    return len(friends)
예제 #2
0
def signup():
    spy = Spy("", "", 0, 0.0)  # class for spydetails
    spy.name = raw_input(
        'Enter your username: '******'Enter a valid name '
    elif spy.name.isdigit():  # to check for digit input
        print 'Enter a valid name '
    elif len(spy.name) > 2:  # checking for length of the string name
        password = raw_input("Enter your password: "******" " + spy.name.upper(
            )  #Using + for string concatenation
            print spy.name  #home work
            print "Alright " + spy.name + ".I'd like to know a little bit more about you before we proceed...."  #home work
            spy.age = 0  #variable declaration ,integer type
            spy.rating = 0.0  #variable declaration for float number
            spy.age = input("What is your age?")
            if 65 > spy.age > 16:  # and operator is also a solution of this
                print "CONGRATS...You are eligible for spy."
            else:
                spy.rating = input("What is your rating?")
                if spy.rating >= 8.0:
                    print "GREAT SPY (*****)."  #5 star
                elif 8 > spy.rating > 5.0:  #elif used for mare than one condition
                    print "GOOD SPY (***)"  #3 star
                elif 3.5 < spy.rating <= 5.0:
                    print "AVERAGE SPY.YOU CAN ALWAYS DO BETTER (*)."  #1 star
                else:
                    print "WHO HIRED YOU?"
                spy_is_online = True  #this is boolean
                print "Authentication complete.Welcome %s your age " \
                          "is" + str(spy.age) + "and rating is"+ str(spy.rating) + ".Proud to have " \
                          "you on board." #we can also use placeholders
                with open("login.csv",
                          "ab") as login:  ## writing details in login file
                    writer = csv.writer(login)
                    writer.writerow([
                        spy.name, password, spy.sal, spy.age, spy.rating,
                        spy_is_online
                    ])

                spy_chat(spy.name, spy.age, spy.rating)

        else:
            print "Please check salutation."
    else:
        print "Ooopss please enter a valid name."
예제 #3
0
def add_friend():
    new_friend = Spy('', '', 0, 0.0)

    new_friend.name = raw_input("Please add your friend's name:")
    if len(new_friend.name) > 0 and new_friend.name.isspace(
    ) == False:  # isspace() function is set to false so that user doesnot enter blank spaces

        new_friend.salutation = raw_input("Are they Mr. or Ms.")
        if new_friend.salutation == "Mr." or new_friend.salutation == "Ms.":

            new_friend.name = new_friend.salutation + " " + new_friend.name
            new_friend.age = int(raw_input("age?"))
            new_friend.rating = float(raw_input("Enter rating"))

            if new_friend.age > 18 and new_friend.rating >= spy.rating:
                friend.append(
                    new_friend
                )  # adding new friends to old list using append function
                print "ADD friend!!"
            else:
                print "Sorry!! not eligible"
        else:
            print "enter valid salutation!!"

    else:
        print "sorry! invalid entry....."
    return len(friend)  # to count number of friends in friend[] list
예제 #4
0
def add_friend():
    new_friend = Spy('', '', 0, 0.0)

    new_friend.name = raw_input("enter your name")
    # len function checks the length text to prevent from empty input to the name
    if len(new_friend.name) > 0 and new_friend.name.isspace(
    ) == False:  #isspace() checks whether the string consists of whitespace
        new_friend.salutation = raw_input("Are they Mr. or Miss.?: ")
        if new_friend.salutation == "Mr." or new_friend.salutation == "Miss.":

            new_friend.name = new_friend.salutation + " " + new_friend.name
            new_friend.age = int(raw_input("enter your age"))
            new_friend.rat = float(raw_input("enter your rating"))

            if new_friend.age > 12 and new_friend.rat > spy.rating:
                friends.append(new_friend)
                print "friend added"

            else:
                print "please enter valid age or rating"

        else:
            print "please enter valid salutation"

    else:
        print "Sorry!!we can't move further please enter valid spy name"

    return len(friends)  # it returns no of friends which are added in the fri
예제 #5
0
def load_frnd():
    with open('friends.csv', 'rb') as friend_data:
        reader = list(csv.reader(friend_data))
        for row in reader[1:]:
            spy = Spy(name=row[0],
                      salutation=row[1],
                      rating=(row[2]),
                      age=row[3])
            friends.append(spy)
예제 #6
0
def load_friends():
    with open('friend.csv', 'rU') as friends_data:
        reader = list(csv.reader(friends_data, dialect='excel'))
        for row in reader[1:]:
            if row:
                name = (row[0])
                age = (row[1])
                rating = (row[2])
                spy = Spy(name, age, rating)
                friends.append(spy)
예제 #7
0
파일: main.py 프로젝트: sagarkava/spychat
def load_frnds():
    with open('friends.csv', 'rb') as frinends_data:
        reader = csv.reader(frinends_data)

        for row in reader:
            frnd = Spy(name=row[0],
                       salutation=row[1],
                       rating=row[2],
                       age=row[3])
            friends.append(frnd)
예제 #8
0
파일: main.py 프로젝트: sagarkava/spychat
def add_friend():
    frnd = Spy('', '', 0, 0.0)
    frnd.name = raw_input('What is your friend name?-> ')
    frnd.sal = raw_input('what should we call you? ->')
    frnd.age = input('What is your friend age?->')
    frnd.rating = input('What is your friend rating-> ')
    frnd.is_online = True
    if len(frnd.name) > 2 and 12 < frnd.age < 60 and frnd.rating > spy.rating:
        with open('friends.csv', 'a') as (friends_data):
            writer = csv.writer(friends_data)
            writer.writerow(
                [frnd.name, frnd.sal, frnd.rating, frnd.age, frnd.is_online])

    else:
        print 'Friend cannot be added'
    return len(friends)
예제 #9
0
def add_friend():
    frnd = Spy('', '', 0, 0.0)
    frnd.name = raw_input("enter the friend name: ")
    frnd.sal = raw_input("salutaion? Mr. or Ms.")
    frnd.age = input("friend age? ")
    frnd.rating = input("friend rating? ")
    frnd.is_online = True
    if len(frnd.name) > 0 and 65 > spy.age > 16 and frnd.rating > spy.rating:
        with open('friends.csv', 'ab') as friend_data:
            writer = csv.writer(friend_data)
            writer.writerow(
                [frnd.name, frnd.sal, frnd.rating, frnd.age, frnd.is_online])
            print "congrats...Now you have one more frirnd"
    else:
        print "friend cannot be added"
    return len(friends)
예제 #10
0
                    send_message()
                elif menu_choice == 4:
                    read_message()
                elif menu_choice == 5:
                    read_chat_history()
                else:
                    show_menu = False
    else:
        print 'Sorry you are not of the correct age to be a spy'


if existing == "Y":  #if the spy already exist start chat directly
    start_chat(spy)
else:
    #taking the detail input of spy
    spy = Spy('', '', 0, 0.0)

    spy.name = raw_input(
        "Welcome to spy chat, you must tell me your spy name first: ")

    if len(spy.name) > 0:
        spy.salutation = raw_input("Should I call you Mr. or Ms.?: ")

        spy.age = raw_input("What is your age?")
        spy.age = int(spy.age)

        spy.rating = raw_input("What is your spy rating?")
        spy.rating = float(spy.rating)

        start_chat(spy)
    else:
예제 #11
0
                    read_chat_history()  # calling of function
                elif menu_choic == 6:
                    show_menu = False
                else:
                    print "The option you choose is not valid. Please enter valid choice!"
    else:
        print 'Sorry you are not of the correct age to be a spy'


if (exist == "Y" or exist == "y"):  # if existing user
    print "Welcome " + spy.salutation + " " + spy.name + " your age is " + str(
        spy.age) + " and rating is " + str(spy.rating)
    spy_chat(spy)  # calling of function

elif (exist == "N" or exist == "n"):  # if not a existing user
    spy = Spy('', '', 0, 0.0)
    spy.name = raw_input(
        "Welcome to spy chat, you must tell me your spy name first:")
    if len(spy.name) > 0 and spy.name.isspace() == False:
        spy.salutation = raw_input("What should i call you Mr. or Ms.")
        if spy.salutation == "Mr." or spy.salutation == "Ms.":
            spy.age = int(raw_input("Enter your age"))
            spy.rating = float(raw_input("what is your spy rating"))
            spy.is_online = True
            spy_chat(
                spy
            )  # calling start_chat function to start the chat application
        else:
            print "enter valid salutation!!"

    else:
예제 #12
0
파일: main.py 프로젝트: sagarkava/spychat
from spy_detail import spy, Spy, chatMessage
from steganography.steganography import Steganography
from datetime import datetime
import csv

print 'Hello Buddy'
print 'Let\'s get started'

STATUS_MESSAGE = [
    'Galti badi galti engineering ', 'Busy', 'pleace only call',
    'Be your self ', 'Never give-up', 'Sleeping'
]
frnd1 = Spy('Naman', 'Mr.', 28, 3.9)
frnd2 = Spy('kriti', 'Ms.', 25, 3.8)
friends = [frnd1, frnd2]


def load_frnds():
    with open('friends.csv', 'rb') as frinends_data:
        reader = csv.reader(frinends_data)

        for row in reader:
            frnd = Spy(name=row[0],
                       salutation=row[1],
                       rating=row[2],
                       age=row[3])
            friends.append(frnd)


load_frnds()
예제 #13
0
파일: main.py 프로젝트: dipak45/spychat
                elif menu_choice == 4:
                    read_message()
                elif menu_choice == 5:
                    read_chat_history()
                else:
                    show_menu = False
    else:
        print 'Sorry you are not of the correct age to be a spy'


if existing == "Y":
    password = raw_input("Enter your password:"******"Welcome to spy chat, Enter your spy_name: ")

    spy_len = len(spy.name)
    print spy.name
    print spy_len
    if spy_len <= 0:
        print "INVALID USER NAME"
        exit()
    else:
        print "VERIFIED"
        spy.salutation = raw_input("Enter your spy_gender?: ")
        if spy.salutation.upper() == "MALE":
            print "WELCOME MR " + spy.name
        else:
예제 #14
0
                elif menu_choice == 6:
                    show_menu = False

    else:
        print "Sorry you are not of the correct age to be a spy"


# if spy wants to continue as default user
if (existing == "Y" or existing == "y"):
    print " Welcome you can continue with your existing account " + spy.name + " " + str(
        spy.age)
    spy_chat(spy)

#  For new user app should ask for the name of the user,age and for rating
else:
    spy = Spy('', '', 0, 0.0)
    spy.name = raw_input("welcm to the spy chat,plss enter your name first:")
    if len(spy.name) > 0 and spy.name.isspace() == False:

        spy.sal = raw_input("Should i call you Mr.or Miss.")

        if spy.sal == "Mr." or spy.sal == "Miss.":

            spy.age = int(raw_input("enter your age"))

            spy.rating = float(raw_input("enter spy rating"))

            spy_chat(spy)

        else:
            print "please enter the valid salutation"