Example #1
0
    def import_vcard(self, filename):
        data = open(filename, 'r').read()
        log.debug_block(filename, data)

        for card in vcard.VCards(vcard.VFile(vcard.opentextfile(filename))):
            log.debug(card)

            if card['name']:
                fax = ''
                for x in range(1, 9999):
                    if x == 1:
                        s = 'phone'
                    else:
                        s = 'phone%d' % x

                    try:
                        card[s]
                    except KeyError:
                        break
                    else:
                        if 'fax' in card[s]['type']:
                            fax = card[s]['number']
                            break

                org = card.get('organisation', '')
                if org:
                    org = [org]
                else:
                    org = card.get('categories', '').split(';')
                    if not org:
                        org = []

                org.append(to_unicode('All'))
                groups = [o for o in org if o]

                name = card['name']
                notes = card.get('notes', to_unicode(''))
                log.debug("Import: name=%s, fax=%s group(s)=%s notes=%s" %
                          (name, fax, ','.join(groups), notes))
                self.set(name, to_unicode(''), to_unicode(''), to_unicode(''),
                         fax, groups, notes)

        return True, ''
Example #2
0
    def import_vcard(self, filename):
        data = file(filename, 'r').read()
        log.debug_block(filename, data)

        for card in vcard.VCards(vcard.VFile(vcard.opentextfile(filename))):
            log.debug(card)

            if card['name']:
                fax = ''
                for x in range(1, 9999):
                    if x == 1:
                        s = 'phone'
                    else:
                        s = 'phone%d' % x

                    try:
                        card[s]
                    except KeyError:
                        break
                    else:
                        if 'fax' in card[s]['type']:
                            fax = card[s]['number']
                            break

                org = card.get('organisation', '')
                if org:
                    org = [org]
                else:
                    org = card.get('categories', '').split(';')
                    if not org:
                        org = []

                org.append(u'All')
                groups = [o for o in org if o]

                name = card['name']
                notes = card.get('notes', u'')
                log.debug("Import: name=%s, fax=%s group(s)=%s notes=%s" % (name, fax, ','.join(groups), notes))
                self.set(name, u'', u'', u'', fax, groups, notes)

        return True, ''
Example #3
0
    def import_vcard(self, filename):
        data = open(filename, "r").read()
        log.debug_block(filename, data)

        for card in vcard.VCards(vcard.VFile(vcard.opentextfile(filename))):
            log.debug(card)

            if card["name"]:
                fax = ""
                for x in range(1, 9999):
                    if x == 1:
                        s = "phone"
                    else:
                        s = "phone%d" % x

                    try:
                        card[s]
                    except KeyError:
                        break
                    else:
                        if "fax" in card[s]["type"]:
                            fax = card[s]["number"]
                            break

                org = card.get("organisation", "")
                if org:
                    org = [org]
                else:
                    org = card.get("categories", "").split(";")
                    if not org:
                        org = []

                org.append(to_unicode("All"))
                groups = [o for o in org if o]

                name = card["name"]
                notes = card.get("notes", to_unicode(""))
                log.debug("Import: name=%s, fax=%s group(s)=%s notes=%s" % (name, fax, ",".join(groups), notes))
                self.set(name, to_unicode(""), to_unicode(""), to_unicode(""), fax, groups, notes)

        return True, ""