8784: Fix test for latest firefox.
[arvados.git] / doc / _includes / _0_filter_py.liquid
1 #!/usr/bin/env python
2
3 # Import the Arvados sdk module
4 import arvados
5
6 # Get information about the task from the environment
7 this_task = arvados.current_task()
8
9 this_task_input = arvados.current_job()['script_parameters']['input']
10
11 # Create the object access to the collection referred to in the input
12 collection = arvados.CollectionReader(this_task_input)
13
14 # Create an object to write a new collection as output
15 out = arvados.CollectionWriter()
16
17 # Create a new file in the output collection
18 with out.open('0-filter.txt') as out_file:
19     # Iterate over every input file in the input collection
20     for input_file in collection.all_files():
21         # Output every line in the file that starts with '0'
22         out_file.writelines(line for line in input_file if line.startswith('0'))
23
24 # Commit the output to Keep.
25 output_locator = out.finish()
26
27 # Use the resulting locator as the output for this task.
28 this_task.set_output(output_locator)
29
30 # Done!