def save_blacklist(data): blacklist_file = os.path.join(get_data_files_directory_for_plugin("callerid"), BLACKLIST_FILE) try: with open(blacklist_file, 'w') as fp_blacklist: fp_blacklist.write(data) except IOError: # notification flash(gettext(u"Error while saving the blacklist file"), "error") flash(gettext(u"Blacklist updated. Please restart the plugin."), "success")
def save_contacts(data): contacts_file = os.path.join(get_data_files_directory_for_plugin("callerid"), CONTACTS_FILE) try: with open(contacts_file, 'w') as fp_contacts: fp_contacts.write(data) except IOError: # notification flash(gettext(u"Error while saving the contacts file"), "error") flash(gettext(u"Contacts list updated. Please restart the plugin."), "success")
def read_blacklist(): blacklist_file = os.path.join(get_data_files_directory_for_plugin("callerid"), BLACKLIST_FILE) blacklist = "" # phone number : reason try: with open(blacklist_file, 'rb') as fp_blacklist: blacklist = fp_blacklist.read() except IOError: # we return an empty file return "" return blacklist
def read_contacts(): contacts_file = os.path.join(get_data_files_directory_for_plugin("callerid"), CONTACTS_FILE) contacts = "" # name : phone number try: with open(contacts_file, 'rb') as fp_contacts: contacts = fp_contacts.read() except IOError: # we return an empty file return "" return contacts