make-catalog.py
1#!/usr/bin/env python3
2"""Generate the six source-only operator definitions; no credentials are read."""
3import json
4from pathlib import Path
5HERE=Path(__file__).resolve().parent
6columns={'type':'string','default':'c1','maxLength':4096,'description':'One-based columns, for example c1,c3 or c2-c4. At most 1024 selected columns.'}
7delimiter={'type':'string','enum':['tab','comma','dash','underscore','pipe','dot','whitespace'],'default':'tab'}
8characters=['tab','space','whitespace','dot','comma','dash','underscore','pipe','colon']
9specs={
10'change_case':('ChangeCase','Change selected columns to upper or lower case and emit tab-separated text.',{'columns':columns,'delimiter':delimiter,'casing':{'type':'string','enum':['upper','lower'],'default':'upper'}},{'columns':'c1','delimiter':'tab','casing':'upper'},'M3 18 8 6l5 12M5 14h6m5-3h5l-5 7h5'),
11'condense_characters':('CondenseCharacters','Replace runs of a selected delimiter with one character, preserving the other text.',{'character':{'type':'string','enum':characters,'default':'tab'}},{'character':'tab'},'M3 6h18M3 18h18m-15-6h12m-9-3-3 3 3 3m6-6 3 3-3 3'),
12'convert_delimiters':('ConvertDelimiters','Trim each text line and convert runs of a selected delimiter to tabs.',{'character':{'type':'string','enum':characters,'default':'tab'}},{'character':'whitespace'},'M3 7h7m4 0h7M3 17h7m4 0h7M7 10l5 4 5-4'),
13'cut_columns':('CutColumns','Select and reorder text columns, supporting ranges and repeated columns; fill missing values with a dot.',{'columns':columns,'delimiter':delimiter},{'columns':'c1,c4,c2-c3','delimiter':'tab'},'M3 4h18v16H3zM8 4v16m8-16v16M3 9h18'),
14'merge_columns':('MergeColumns','Append a column formed by concatenating the selected tab-separated fields; preserve comment and empty lines.',{'columns':columns},{'columns':'c4,c1,c6'},'M4 4v7l8 5 8-5V4M12 16v5M1 7h6m10 0h6'),
15'add_column':('AddColumn','Append a fixed value or sequential identifier to every line of tabular text.',{'value':{'type':'string','default':'1','maxLength':4096},'iterate':{'type':'boolean','default':False}},{'value':'1','iterate':False},'M3 4h12v16H3zM8 4v16m10-11v6m-3-3h6')}
16result={}
17for name,(cls,description,properties,params,path) in specs.items():
18 result[name]={'name':'galaxy_'+name,'version':'1.0','description':description,'entrypoint':'xstream.galaxy.'+cls,'icon':{'path':path,'color':'#5265ad'},'parameters':{'type':'object','properties':properties,'required':[],'additionalProperties':False},'params':params}
19(HERE/'catalog.json').write_text(json.dumps(result,indent=2)+'\n')