Beispiel #1
0
    def auto_complete(self, input):
        db_args = DB.create_db()
        Contact.setDB(db_args)

        choices = Contact.complete(self.value)

        self.value = choices[self.get_choice(choices)]
Beispiel #2
0
    def auto_complete(self, input):
        db_args = DB.create_db()
        Contact.setDB(db_args)

        choices = Contact.complete(self.value)

        self.value = choices[self.get_choice(choices)]
Beispiel #3
0
 def internalGraph(self):
     Contact.internalGraph(self)
     self.instance = rdflib.Namespace(
         "http://io-informatics.com/rdf/MAGE/Person/")[self.identifier]
     self.graph.add((self.instance, rdflib.RDF['type'], self.classType))
     self.attributeToGraph(self.instance)
     self.ontologyEntryToGraph(self.instance)
Beispiel #4
0
def add_contact_to_list():

    name = ""
    name_check = False
    email = None
    phone_number = None
    group_to_add = ""
    groups = []
    groups_finished = False

    print("-------------------------------------------")
    print("\t Add a contact")
    print("-------------------------------------------")

    while not name_check:
        print("\t Please enter a contact name and hit ENTER")
        print("\t", end="")
        name = input('')

        if len(name) == 0:
            print("\t No contact name entered, please try again")
        else:
            name_check = True

    print("\t Please enter a contact email and hit ENTER")
    print("\t [To leave email empty, just hit ENTER]")
    print("\t", end="")
    email = input('')

    print("\t Please enter a contact phone number and hit ENTER")
    print("\t", end="")
    phone_number = input('')

    while not groups_finished:
        print("\t Please enter a group name and hit ENTER")
        print("\t", end="")
        group_to_add = input('')

        if len(group_to_add) == 0:
            print("\t No group name entered, please try again")
        else:
            groups.append(group_to_add)
            print("\t Group added successfully")
            print("\t To add another group, type '1' and hit ENTER, otherwise hit ENTER")
            print("\t", end="")

            add_more = input('')
            if add_more == "1":
                groups_finished = False
            else:
                groups_finished = True

    contact = Contact(name, email, phone_number)
    contact.set_groups(groups)
    add_status = ContactDAO.add_a_contact(contact)

    if add_status:
        return name
    else:
        return ""
Beispiel #5
0
    def internalGraph(self):
        Contact.internalGraph(self)
        instance = rdflib.Namespace("http://io-informatics.com/rdf/MAGE/Organization/")[self.identifier]
        self.instance = instance
        self.graph.add((instance, rdflib.RDF['type'], self.classType))
        self.attributeToGraph(instance)
        self.ontologyEntryToGraph(instance)



        
Beispiel #6
0
    def addContact(self, contact: Contact) -> None:
        with open("contacts.csv", "r") as inFile:
            reader = csv.reader(inFile)
            with open("contacts_tmp.csv", "w") as outFile:
                writer = csv.writer(outFile)

                for line in reader:
                    writer.writerow(line)
                writer.writerow([contact.name(), contact.phoneNumber()])
        os.remove("contacts.csv")
        os.rename("contacts_tmp.csv", "contacts.csv")
Beispiel #7
0
    def searchId(self):
        ct = Contact()
        ct.idContact = self.inputId.get()
        self.hiddenId = self.inputId.get()

        self.labelResult["text"] = ct.searchContact()

        self.cleanInputs()

        self.inputName.insert(INSERT, ct.name)
        self.inputNumber.insert(INSERT, ct.number)
        self.inputEmail.insert(INSERT, ct.email)
Beispiel #8
0
def process_registrants(registrants):
    for jsonRegistrant in registrants:
        registrant = json.loads(str(jsonRegistrant))
        add_to_contacts = True
        check_leads = True
        for contact in contactsList:
            if registrant["email"] != "None":
                if registrant["email"] == contact.email:
                    print("Email Found in Contacts")
                    add_to_contacts = False
                    check_leads = False
                    if contact.phone == "None" and registrant[
                            "phone"] != "None":
                        contact.phone = registrant["phone"]
                    break
            if registrant["phone"] != "None":
                if registrant["phone"] == contact.phone:
                    print("Phone Found in Contacts")
                    add_to_contacts = False
                    check_leads = False
                    if contact.email == "None" and registrant[
                            "email"] != "None":
                        contact.email = registrant["email"]
                    break
        if check_leads:
            for lead in leadsList:
                if registrant["email"] != "None":
                    if registrant["email"] == lead.email:
                        print("Email Found in Leads")
                        add_to_contacts = False
                        if registrant["phone"] == "None":
                            registrant["phone"] = lead.phone
                        contactsList.append(
                            Contact(registrant["name"], registrant["email"],
                                    registrant["phone"]))
                        leadsList.remove(lead)
                        break
                if registrant["phone"] != "None":
                    if registrant["phone"] == lead.phone:
                        print("Phone Found in Leads")
                        add_to_contacts = False
                        if registrant["email"] == "None":
                            registrant["email"] = lead.email
                        contactsList.append(
                            Contact(registrant["name"], registrant["email"],
                                    registrant["phone"]))
                        leadsList.remove(lead)
                        break
        if add_to_contacts:
            contactsList.append(
                Contact(registrant["name"], registrant["email"],
                        registrant["phone"]))
Beispiel #9
0
    def updateContact(self, contact: Contact) -> None:
        with open("contacts.csv", "r") as myContactsFile:
            contactsReader = csv.DictReader(myContactsFile)

            with open("contacts_tmp.csv", "w") as outFile:
                writer = csv.writer(outFile)
                writer.writerow(contactsReader.fieldnames)
                for row in contactsReader:
                    if row["name"] == contact.name():
                        writer.writerow([contact.name(), contact.phoneNumber()])
                        continue
                    writer.writerow([row["name"], row["phone number"]])
                    
        os.remove("contacts.csv")
        os.rename("contacts_tmp.csv", "contacts.csv")
Beispiel #10
0
def cli_mode(args):
    person = Contact(args.name, (args.base, args.cursor))
    forename = person.forename
    name = person.name
    mail = person.mail

    if mail == None:
        print('Nouveau contact')
        mail = input('Veuillez saisir le mail: ')
        person.mail = mail

    print('Mode CLI')
    print('Contact:', forename, name)
    print('Mail:', mail)

    person.generateDoc(args.sun)
Beispiel #11
0
def get_all_contacts(phB):
    """
    1. Read in the contacts.txt file
    2. Create new contacts for each line in the file
    """

    f = open("Laboratory/Lab9/contacts.txt", "r")
    contacts = f.read().split("\n")
    f.close()

    print("Data from the file")
    print(contacts)

    print()
    for c in contacts:
        l = c.split(", ")

        name = l[0].split(" ")
        phone = l[1]
        email = l[2]
        birthday = l[3].split(".")

        newContact = Contact(name, phone, email, birthday)
        print(newContact)

        phB.addContact(newContact)
Beispiel #12
0
def create(entity: dict, dao: GenericSQLDAO = None):
    entity_to_create = Contact(**entity)

    dao.create(entity=entity_to_create)

    return success_response(message="Contact created",
                            data={"Contact": dict(entity_to_create)})
Beispiel #13
0
def cli_mode(args):
    person = Contact(args.name, (args.base, args.cursor))
    forename = person.forename
    name = person.name
    mail = person.mail

    if mail == None:
        print('Nouveau contact')
        mail = input('Veuillez saisir le mail: ')
        person.mail = mail

    print('Mode CLI')
    print('Contact:', forename, name)
    print('Mail:', mail)

    person.generateDoc(args.sun)
    def addContact(self, c):
        """
        Given a contact, determine if you are given a dictionary or an instance of 
        a Contact class. Handle the adding to our phone book appropriately and update the counter.

        If you are given a dictionary, assume that a dictionary has the following keys 
        (and the values are in the correct format):
        - name
        - number
        - email
        - birthday

        NOTE: Why do we have to manually update the counter?
        """
        if isinstance(c, Contact):
            self.contactList.append(c)

        elif isinstance(c, dict):
            n = c['name']
            p = c['number']
            e = c['email']
            b = c['birthday']
            newContact = Contact(n, p, e, b)
            self.contactList.append(newContact)
        self.count += 1
Beispiel #15
0
    def main(self, *args, **kwargs):
        form = npyscreen.Form(name="Agenda")
        contact = form.add(ContactAutocomplete, name="Contact:")
        mail = form.add(npyscreen.TitleText, name="Mail:")
        weather = form.add(npyscreen.TitleSelectOne, max_height=len(TextUI.weather_values), 
                value=[0], name="Temps:", values=TextUI.weather_values, scroll_exit=True)

        form.edit()

        (base, cursor) = DB.create_db()
        person = Contact(contact.value, (base, cursor))
        person.mail = mail.value

        npyscreen.notify_wait("Valeur saisie : " + contact.value, title="Vérification")

        DB.close_db(base, cursor)
Beispiel #16
0
    def post(self):
        Guser = users.get_current_user()
        AppEmail = '*****@*****.**'
        if Guser:
            vstrToEmail = self.request.get('vstrToEmail')
            vstrSubject = self.request.get('vstrSubject')
            vstrcomposetextarea = self.request.get('vstrcomposetextarea')
            vstrMessageIndex = self.request.get('vstrMessageIndex')
            vstrMessageIndex = int(vstrMessageIndex)
            message = mail.EmailMessage()
            message.sender = AppEmail
            message.to = vstrToEmail
            message.subject = vstrSubject
            message.html = vstrcomposetextarea

            message.send()
            findRequest = Contact.query(
                Contact.strMessageIndex == vstrMessageIndex)
            thisContactList = findRequest.fetch()
            if len(thisContactList) > 0:
                thisContact = thisContactList[0]
                thisContact.strResponded = True
                thisContact.put()

                self.response.write("Response Successfully sent to recipient")
Beispiel #17
0
    def getAllContacts(self) -> List[Contact]:
        lstContact: List[Contact] = []
        with open("contacts.csv", "r") as myContactsFile:
            contactsReader = csv.DictReader(myContactsFile)
            for row in contactsReader:
                lstContact.append(Contact(row["name"], row["phone number"]))

        return lstContact
 def __init__(self, airport, code, flight_time, dist_from_birk, number,
              contact_name, contact_number):
     self.airport = airport
     self.code = code
     self.flight_time = flight_time
     self.dist_from_birk = dist_from_birk
     self.number = number
     self.contact = Contact(contact_name, contact_number)
Beispiel #19
0
def create(id_: str, entity: dict, dao: GenericSQLDAO = None):
    entity_to_create = Phone(**entity)
    entity_to_create.contact = Contact(id_=id_)

    dao.create(entity=entity_to_create)

    return success_response(message="Phone created",
                            data={"Phone": dict(entity_to_create)})
Beispiel #20
0
    def update():
        selectedContact = Main.selectContact()

        uContact = Contact()
        uContact.id = selectedContact.id

        print(
            "\n================================Update Contact=================================="
        )

        userInput1 = input("\nName : ")
        if not userInput1:
            userInput1 = selectedContact.name
        uContact.name = userInput1

        userInput2 = input("\nContact Number : ")
        if not userInput2:
            userInput2 = selectedContact.contactNumber
        uContact.contactNumber = userInput2

        userInput3 = input("\nAddress : ")
        if not userInput3:
            userInput3 = selectedContact.address
        uContact.address = userInput3

        userInput4 = input("\nEmail : ")
        if not userInput4:
            userInput4 = selectedContact.email
        uContact.email = userInput4

        result = ContactCRUD.update(uContact)
        print("\n{} records Updated".format(result))
Beispiel #21
0
 def getAllContacts():
     '''
         getAllContacts() method tom fetch All contacts from DB.
         Returns Contacts as list of Objects(Contact)
     '''
     contactList = []
     try:
         con = DBConnection.get_connection()  #Getting DB connection
         cur = con.cursor(dictionary=True)
         if cur != None:
             cur.execute(Queries.ALL)
             for contct in cur:
                 c = Contact()
                 c.id = contct['contact_id']
                 c.name = contct['contact_name']
                 c.address = contct['contact_address']
                 c.contactNumber = contct['contact_number']
                 c.email = contct['contact_email']
                 contactList.append(c)
     except (mysql.Error, mysql.Warning) as e:
         print("error in operation")
         print(e)
     finally:
         con.close()
         return contactList
Beispiel #22
0
 def print_contact_meetings(self, name):
     """ Prints the sorted list of events associated with a particular contact with name=name """
     thecontact = Contact(name)
     check_contact = self.contact_present(thecontact)
     if not check_contact:
         return 0
     else:
         self.__list_of_contacts[check_contact[0]].print_meetings()
         return 1
Beispiel #23
0
 def __showUpdateContactsScreen(self) -> None:
     print("Please enter user need to be updated: ", end="")
     name = input()
     if self.__phoneBook.isContactExist(name) == False:
         print("There is no contact with that name")
     else:
         print("New phone number: ")
         phoneNumber: str = input()
         self.__phoneBook.updateContact(Contact(name, phoneNumber))
Beispiel #24
0
    def get(self):
        URL = self.request.uri
        URLlist = URL.split("/")
        vstrMessageIndex = URLlist[len(URLlist) - 1]
        vstrMessageIndex = int(vstrMessageIndex)
        logging.info(vstrMessageIndex)

        findRequest = Contact.query(
            Contact.strMessageIndex == vstrMessageIndex)
        thisContactList = findRequest.fetch()
        if len(thisContactList) > 0:
            thisContact = thisContactList[0]
            template = template_env.get_template(
                'templates/admin/admin/readMessage.html')
            context = {'thisContact': thisContact}
            self.response.write(template.render(context))
        else:
            thisContact = Contact()
Beispiel #25
0
    def get(self):
        Guser = users.get_current_user()
        if Guser:

            findRequest = Contact.query(Contact.strResponded == False)
            thisContactList = findRequest.fetch()
            template = template_env.get_template(
                'templates/admin/admin/contacts.html')
            context = {'thisContactList': thisContactList}
            self.response.write(template.render(context))
Beispiel #26
0
def main():
    raw_contacts_list = get_contacts('phonebook_raw.csv')

    my_phone_book = PhoneBook()
    for raw_contact in raw_contacts_list:
        contact = Contact(raw_contact[:7])
        my_phone_book.add_contact(contact)

    contacts_list = my_phone_book.get_contacts_list()
    write_contacts('phonebook.csv', contacts_list)
Beispiel #27
0
    def add_contact(self):
        print("Please enter contact information")
        first_name = input("First name: ")
        last_name = input("Last name: ")
        phone = input("Phone: ")
        email = input("Email: ")

        new_contact = Contact(first_name, last_name, phone, email)

        self.contacts.append(new_contact)
    def search_by_name(search_name):
        searchContacts = []
        db = MySqlDb()

        rows = db.query(
            'SELECT c.*, g.group_name FROM contact AS c, contact_group AS g, group_link AS gl WHERE c.contact_id = gl.contact_id AND g.group_id = gl.group_id AND c.name LIKE %s;',
            [search_name + "%"])
        db.close_connection()

        prev_name = ""
        new_contact = None
        groups = None

        for entry in rows:
            if len(prev_name) == 0 or prev_name != entry['name']:
                if len(prev_name) != 0:
                    new_contact.set_groups(groups)
                    searchContacts.append(new_contact)

                name = entry['name']
                email = entry['email']
                phone_number = entry['phone_number']
                group = entry['group_name']

                groups = []
                groups.append(group)

                prev_name = name

                new_contact = Contact(name, email, phone_number)
            else:
                group = entry['group_name']
                groups.append(group)

        if new_contact is not None:
            new_contact.set_groups(groups)
            searchContacts.append(new_contact)

        if len(searchContacts) > 0:
            return searchContacts
        else:
            return None
Beispiel #29
0
def find_contact():
    for line in div_contato.splitlines():
        if line.find('E-mail') > 0:
            email = extract_contact_line(line)
        elif line.find('Telefones:') > 0:
            phone = extract_contact_line(line)
        elif line.find('Endereço:') > 0:
            adress = extract_contact_line(line)
        elif line.find('Cidade:') > 0:
            city = extract_contact_line(line)
    return Contact(email, phone, adress, city)
Beispiel #30
0
    def main(self, *args, **kwargs):
        form = npyscreen.Form(name="Agenda")
        contact = form.add(ContactAutocomplete, name="Contact:")
        mail = form.add(npyscreen.TitleText, name="Mail:")
        weather = form.add(npyscreen.TitleSelectOne,
                           max_height=len(TextUI.weather_values),
                           value=[0],
                           name="Temps:",
                           values=TextUI.weather_values,
                           scroll_exit=True)

        form.edit()

        (base, cursor) = DB.create_db()
        person = Contact(contact.value, (base, cursor))
        person.mail = mail.value

        npyscreen.notify_wait("Valeur saisie : " + contact.value,
                              title="Vérification")

        DB.close_db(base, cursor)
Beispiel #31
0
    def create():
        newContact = Contact()
        print(
            "\n================================Add Contact=================================="
        )

        userInput1 = input("\nContact Name : ")
        if not userInput1:
            userInput1 = "No Name"
        newContact.name = userInput1

        userInput2 = input("\nContact Number : ")
        if not userInput2:
            userInput2 = "Unknown"
        newContact.contactNumber = userInput2

        userInput3 = input("\nAddress : ")
        if not userInput3:
            userInput3 = "No Address"
        newContact.address = userInput3

        userInput4 = input("\nEmail : ")
        if not userInput4:
            userInput4 = "Unknown"
        newContact.email = userInput4

        print("\nNew Contact \n{}".format(newContact))

        result = ContactCRUD.insert_contact(newContact)
        print("\n{} records Inserted".format(result))
Beispiel #32
0
def create_new_contact():
    print 'Enter new contact details'
    contact_name = raw_input('Name: ')
    contact_group = raw_input('Category: ')
    contact_email = raw_input('Email: ')
    contact_phone = raw_input('Phone: ')

    contact = Contact(contact_name, contact_group, contact_email, contact_phone)
    status = add_contact(contact)
    if status:
        print 'Contact created successfully'
    else:
        print 'There is some problem creating new contact'
Beispiel #33
0
    def update(self):
        if (self.validateInputs()):
            ct = Contact()
            ct.name = self.inputName.get()
            ct.number = self.inputNumber.get()
            ct.email = self.inputEmail.get()
            ct.idContact = self.hiddenId

            self.labelResult["text"] = ct.updateContact()
            self.cleanInputs()
        else:
            self.labelResult["text"] = "Invalid inputs."
Beispiel #34
0
    def __showAddContactScreen(self) -> None:
        while True:
            print("Enter name: ", end="")
            name: str = input()
            if self.__phoneBook.isContactExist(name) == True:
                print("This user already exist, please enter the other name!")
            else:
                break

        print("Enter phone number: ", end="")
        phoneNumber: str = input()
        newContact: Contact = Contact(name, phoneNumber)
        self.__phoneBook.addContact(newContact)
        return None
def add_contact(user_id, group_id):

    if not r_server.zscore('user:set', user_id):
        return make_response('That user does not exist', 404)

    if not r_server.zscore('group:%s:set' % user_id, group_id):
        return make_response('That group does not exist', 404)

    data = request.get_json(silent=False)

    # Contact has validation for mail field
    try:
        # Due to all contact information is optional, a generated ID is used as
        # storing key
        contact_id = r_server.incr('contact:%s:%s:lastID' % (user_id, group_id))

        contact = Contact(contact_id)
        contact.from_json(data)
    except AttributeError as e:
        r_server.decr('contact:%s:%s:lastID' % (user_id, group_id))
        return make_response(str(e), 400)

    millis = int(round(time.time() * 1000))

    if not r_server.zscore('contact:%s:%s:set' % (user_id, group_id),
                           contact_id):
        r_server.zadd('contact:%s:%s:set' % (user_id, group_id),
                      contact_id, millis)
        r_server.set('contact:%s:%s:%s' % (user_id, group_id, contact_id),
                     jsonpickle.encode(contact))

        return make_response("Contact created.", 201, {'location':
                                'localhost:5000/%s/groups/%s/contacts/%s' %
                                (user_id, group_id, contact_id)})

    return make_response("That contact already exist!", 400)
Beispiel #36
0
    def getContactInfo(self):

        contactList=[]

        contacts=self.doc.xpathEval("//contact_info/contact")

        for contact in contacts:

            type=contact.xpathEval("contact-type")[0].content
            firstName=contact.xpathEval("first_name")[0].content
            lastName=contact.xpathEval("last_name")[0].content
            institute=contact.xpathEval("institute")[0].content

            p=Contact()
            p.setFirstName(firstName)
            p.setLastName(lastName)
            p.setInstitute(institute)
            p.setType(type)

            contactList.append(p)

            

        return contactList
Beispiel #37
0
def cli_mode(args):
    person = Contact(args.name, (args.base, args.cursor))
    forename = person.forename
    name = person.name
    mail = person.mail

    if mail == None:
        print('Nouveau contact')
        mail = input('Veuillez saisir le mail: ')
        person.mail = mail

    person.generateDoc(args.sun)
    person.sendMail()

    print('Le mail a été envoyé à', forename, name)
	def __init__(self,url):
		Contact.__init__(self, url)
		self.url = url
		self.mail = MailLib.MailLib(url)
Beispiel #39
0
from Contact import Contact

contact = Contact()


def process_input(line):
    tokens = line.split()
    if tokens[0] == "add":
        if len(tokens) == 2:
            contact.add_player(tokens[1])
            return
    elif tokens[0] == "remove":
        if len(tokens) == 2:
            contact.remove_player(tokens[1])
            return
    elif tokens[0] == "submit":
        if len(tokens) == 3:
            contact.submit_word(tokens[1], tokens[2])
            return
    print("Not a valid command.")

process_input("add p1")
process_input("add p2")
process_input("add p3")
contact.print_state()
while True:
    process_input(input())
    while contact.has_messages():
        print(contact.read_message())
    contact.print_state()
# utility for analyzing brd log files
#
# simplest use case - take in a dedupe field (email) and
# gather all entries related (including those that do not
# reference the dedupe field).. see findContact
#
# later features could include a report on particular types
# of error (such as remote create/update failures) listing
# all fields with mismatched or invalid options .. see invalidOptionsReport
#
from Contact import Contact
from Line import Line, Index

x = Contact()
x.emailAddress = '*****@*****.**'

logFile = open('NateMike.log', 'r')

log = [line for line in logFile]

meta = []
for line in log:
    meta.append(Line.digest_with_ts(line))


# logic for getting to a MISSING FIELDS error
for metaline in meta:
    if metaline.mType != '':
        print metaline.mType
    if metaline.mType == 'INDEX':
        metaline.process()
Beispiel #41
0
 def __init__(self, *params):
     '''
     Constructor
     '''
     Contact.__init__(self)
Beispiel #42
0
 def __init__(self):
     '''
     Constructor
     '''
     Contact.__init__(self)