コード例 #1
0
    def delete_contact(self, *args):
        menu = EasyMenu("Veuillez choisir le/les contacts")
        menu.set_prompt("Votre choix (a,b,c,d): ")
        menu.set_multiple(True)

        for contact in self.contacts:
            menu.add_entry(contact.get_string(), None)

        menu.show_menu()
        chx = menu.wait_for_choise()
        contact_to_delete = DataManipulation.get_selected_from_index(
            self.contacts, chx)
        for i in contact_to_delete:
            self.contacts.remove(i)
        # io_formats.get_format(self.DEFAULT_DB_FORMAT).export_data(self.contacts, self.file_path)

        self.make_menu()
コード例 #2
0
    def export_single(self, file_format):
        file_format = file_format[0]
        menu = EasyMenu("Veuillez choisir le/les contacts")
        menu.set_prompt("Votre choix (a,b,c,d): ")
        menu.set_multiple(True)

        for contact in self.contacts:
            menu.add_entry(contact.get_string(), None)

        menu.show_menu()
        chx = menu.wait_for_choise()
        contact_to_write = DataManipulation.get_selected_from_index(
            self.contacts, chx)
        file_path = input("Entrez un chemin pour le fichier: ")
        io_formats.get_format(file_format).export_data(contact_to_write,
                                                       file_path)

        self.make_menu()
コード例 #3
0
    def import_menu(self, *args):
        file_path = input("Entrez un chemin pour le fichier: ")

        menu = EasyMenu("Importation de fichiers")
        menu.set_prompt("Votre choix (a,b,c): ")
        menu.set_multiple(True)

        files_to_process = []

        if os.path.exists(file_path):
            if os.path.isdir(file_path):
                filtered_files = DataManipulation.filter_file(
                    DataManipulation.get_files(file_path),
                    tuple(io_formats.get_ext()))
                for filtered in filtered_files:
                    files_to_process.append(os.path.join(file_path, filtered))
                    menu.add_entry(filtered, None)
                menu.show_menu()
                chx = menu.wait_for_choise()
                sel = DataManipulation.get_selected_from_index(
                    files_to_process, chx)
                for file in sel:
                    ext = os.path.splitext(file)[1]
                    print(ext)
                    l = io_formats.get_format_from_ext(ext).import_data(
                        file_path + '/' + file)
                    self.contacts = self.contacts + l
                self.make_menu()
                return
            else:
                if file_path.endswith(tuple(io_formats.get_ext())):
                    ext = os.path.splitext(file_path)[1]
                    l = io_formats.get_format_from_ext(ext).import_data(
                        file_path)
                    self.contacts = self.contacts + l
            self.make_menu()
            return

        print("Le chemin/fichier n'est pas valide/dans un format reconu")
        self.import_menu()
コード例 #4
0
    def add_field(self):
        c = input(
            "Voulez vous ajouter de nouveaux champs ? (Ces champs peuvent ne pas être présent dans"
            + " certain format  d'exportation)(O/N) : ")
        if c.lower().startswith("o"):
            menu = EasyMenu("Voici les types de champs")
            menu.set_prompt("Votre choix : ")
            menu.set_multiple(True)

            for types in field_types.get_fields():
                menu.add_entry(
                    "{} - {}".format(
                        field_types.get_field(types).NAME,
                        field_types.get_field(types).DESCRIPTION), None)
            menu.show_menu()
            ch = menu.wait_for_choise()
            value = input("Entrez le nom du champs")
            header = field_types.get_field_by_index(ch[0])(value)
            header.ask_value()
            self.available_headers.append(header)
            return self.add_field()
        return