#!/usr/bin/env python
# Copyright (C) The Arvados Authors. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

import arvados
import os
import re

this_job = arvados.current_job()
this_task = arvados.current_task()
this_job_input = this_job['script_parameters']['input']
manifest_text = ""
for f in arvados.CollectionReader(this_job_input).all_files():
    if f.name() in this_job['script_parameters']['names']:
        manifest_text += f.as_manifest()

this_task.set_output(arvados.Keep.put(manifest_text))