def flatten_command(self, cmd):
    cmd = listify(cmd, unholder=True)
    final_cmd = []
    for c in cmd:
        if isinstance(c, str):
            final_cmd.append(c)
        elif isinstance(c, File):
            self.depend_files.append(c)
            final_cmd.append(c)
        elif isinstance(c, dependencies.ExternalProgram):
            if (not c.found()):
                m = 'Tried to use not-found external program {!r} in "command"'
                raise InvalidArguments(m.format(c.name))
            path = c.get_path()
            if os.path.isabs(path):
                self.depend_files.append(File.from_absolute_file(path))
            final_cmd += c.get_command()
        elif isinstance(c, (BuildTarget, CustomTarget)):
            self.dependencies.append(c)
            final_cmd.append(c)
        elif isinstance(c, list):
            final_cmd += self.flatten_command(c)
        else:
            raise InvalidArguments('Argument {!r} in "command" is invalid'.format(c))
    return final_cmd
def flatten_command(self, cmd):
    cmd = listify(cmd, unholder=True)
    final_cmd = []
    for c in cmd:
        if isinstance(c, str):
            final_cmd.append(c)
        elif isinstance(c, File):
            self.depend_files.append(c)
            final_cmd.append(c)
        elif isinstance(c, dependencies.ExternalProgram):
            if (not c.found()):
                m = 'Tried to use not-found external program {!r} in "command"'
                raise InvalidArguments(m.format(c.name))
            path = c.get_path()
            if os.path.isabs(path):
                self.depend_files.append(File.from_absolute_file(path))
            final_cmd += c.get_command()
        elif isinstance(c, (BuildTarget, CustomTarget)):
            self.dependencies.append(c)
            final_cmd.append(c)
        elif isinstance(c, list):
            final_cmd += self.flatten_command(c)
        else:
            raise InvalidArguments('Argument {!r} in "command" is invalid'.format(c))
    return final_cmd