Work out the command arguments for a given command

def _get_command_args(self, command, args):
        '''Work out the command arguments for a given command'''
        command_args = {}
        command_argument_names =\
            command.__code__.co_varnames[:command.__code__.co_argcount]

        for varname in command_argument_names:
            if varname == 'args':
                command_args['args'] = args
            elif varname in self.provide_args:
                command_args[varname] = self.provide_args[varname]
            else:
                command_args[varname] = getattr(args, varname)
        return command_args