def add_phone(self, fields, data): """Read the TEL property of a VCard.""" tel = data.strip() if tel: addr = Address() addr.set_phone(self.unesc(tel)) self.person.add_address(addr)
def add_address(self, fields, data): """Read the ADR property of a VCard.""" data_fields = self.split_unescaped(data, ';') data_fields = [x.strip() for x in self.unesc(data_fields)] if ''.join(data_fields): addr = Address() def add_street(strng): if strng: already = addr.get_street() if already: addr.set_street("%s %s" % (already, strng)) else: addr.set_street(strng) addr.add_street = add_street set_func = [ 'add_street', 'add_street', 'add_street', 'set_city', 'set_state', 'set_postal_code', 'set_country' ] for i, data in enumerate(data_fields): if i >= len(set_func): break getattr(addr, set_func[i])(data) self.person.add_address(addr)
def column_phone(self,data): try: if data[5]: addr = Address() addr.unserialize(data[5][0]) return addr.get_phone() except: pass return ''
def column_phone(self, data): try: if data[5]: addr = Address() addr.unserialize(data[5][0]) return addr.get_phone() except: pass return ''
def column_postal_code(self, data): try: if data[5]: addr = Address() addr.unserialize(data[5][0]) return addr.get_postal_code() except: pass return cuni('')
def column_locality(self, data): try: if data[5]: addr = Address() addr.unserialize(data[5][0]) return addr.get_locality() except: pass return cuni('')
def add_address(self, fields, data): """Read the ADR property of a VCard.""" data_fields = self.split_unescaped(data, ';') data_fields = [x.strip() for x in self.unesc(data_fields)] if ''.join(data_fields): addr = Address() def add_street(strng): if strng: already = addr.get_street() if already: addr.set_street("%s %s" % (already, strng)) else: addr.set_street(strng) addr.add_street = add_street set_func = ['add_street', 'add_street', 'add_street', 'set_city', 'set_state', 'set_postal_code', 'set_country'] for i, data in enumerate(data_fields): if i >= len(set_func): break getattr(addr, set_func[i])(data) self.person.add_address(addr)
def add_button_clicked(self, obj): """ Called when the Add button is clicked. Creates a new Address instance and calls the EditAddress editor with the new address. If the window already exists (WindowActiveError), we ignore it. This prevents the dialog from coming up twice on the same object. """ addr = Address() try: from .. import EditAddress EditAddress(self.dbstate, self.uistate, self.track, addr, self.add_callback) except WindowActiveError: return