1const t=`name: Filter text 2inputs: 3- {name: Text} 4- {name: Pattern, default: '.*'} 5outputs: 6- {name: Filtered text} 7metadata: 8 annotations: 9 author: Your Name <[email protected]> 10implementation: 11 container: 12 image: python:3.8 13 command: 14 - sh 15 - -ec 16 - | 17 # This is how additional packages can be installed dynamically 18 python3 -m pip install pip six 19 # Run the rest of the command after installing the packages. 20 "$0" "$@" 21 - python3 22 - -u # Auto-flush. We want the logs to appear in the console immediately. 23 - -c # Inline scripts are easy, but have size limitaions and the error traces do not show source lines. 24 - | 25 import os 26 import re 27 import sys 28 29 text_path = sys.argv[1] 30 pattern = sys.argv[2] 31 filtered_text_path = sys.argv[3] 32 33 regex = re.compile(pattern) 34 35 os.makedirs(os.path.dirname(filtered_text_path), exist_ok=True) 36 with open(text_path, 'r') as reader: 37 with open(filtered_text_path, 'w') as writer: 38 for line in reader: 39 if regex.search(line): 40 writer.write(line) 41 - {inputPath: Text} 42 - {inputValue: Pattern} 43 - {outputPath: Filtered text}`;export{t as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.