Ejemplo n.º 1
0
    def is_name_taken(self, account_object_name, account_name):
        '''Check whether the given name is available is a name of an account
        object.

        If the name points to an existing account, propese an action that may
        resolve the conflict.

        Args:
            account_object_name (str): The proposed name of a new account 
                object.
            account_name (str): The EOSIO name of the account mapped with the
                new account object.

        Returns:
            bool: Whether the given name is available is a name of an account
                object.
        '''
        while True:
            account_map_json = manager.account_map()
            if account_map_json is None:
                return False

            is_taken = False
            for name, object_name in account_map_json.items():
                if object_name == account_object_name:
                    if not name == account_name:
                        logger.OUT('''
                The given account object name
                ``{}``
                points to an existing account, of the name {},
                mapped in a file in directory:
                {}
                Cannot overwrite it.

                However, you can free the name by changing the mapping. 
                Do you want to edit the file?
                '''.format(account_object_name, name, self.wallet_dir))
                        is_taken = True
                        break

            if is_taken:
                temp = None
                if account_object_name in Wallet.globals:
                    temp = Wallet.globals[account_object_name]
                    del Wallet.globals[account_object_name]

                answer = input("y/n <<< ")

                if answer == "y":
                    manager.edit_account_map()
                    continue
                else:
                    if temp:
                        Wallet.globals[account_object_name] = temp
                    raise errors.Error('''
                    Use the function 'manager.edit_account_map()' to edit the file.
                    ''')
            else:
                break
Ejemplo n.º 2
0
    def is_name_taken(self, account_object_name, account_name):
        while True:
            account_map_json = manager.account_map(self)
            if account_map_json is None:
                return False

            is_taken = False
            for name, object_name in account_map_json.items():
                if object_name == account_object_name:
                    if not name == account_name:
                        logger.OUT('''
                The given account object name
                ``{}``
                points to an existing account, of the name {},
                mapped in a file in directory:
                {}
                Cannot overwrite it.

                However, you can free the name by changing the mapping. 
                Do you want to edit the file?
                '''.format(account_object_name, name, self.wallet_dir))
                        is_taken = True
                        break

            if is_taken:
                temp = None
                if account_object_name in Wallet.globals:
                    temp = Wallet.globals[account_object_name]
                    del Wallet.globals[account_object_name]

                answer = input("y/n <<< ")

                if answer == "y":
                    manager.edit_account_map()
                    continue
                else:
                    if temp:
                        Wallet.globals[account_object_name] = temp
                    raise errors.Error('''
                    Use the function 'manager.edit_account_map(text_editor="nano")' to edit the file.
                    ''')
            else:
                break
Ejemplo n.º 3
0
 def edit_account_map(self):
     manager.edit_account_map()
Ejemplo n.º 4
0
 def edit_account_map(self, text_editor="nano"):
     manager.edit_account_map(text_editor)