mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 05:45:37 +08:00
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
def collate_table(path: str) -> list:
|
|
with open(path) as f:
|
|
contents = f.read()
|
|
first_options: list[dict[str, str | bool | list[str]]] = []
|
|
second_options: list[dict[str, str | bool | list[str]]] = []
|
|
values = [
|
|
{"name": "First Column", "value": "first", "selected": False, "options": first_options},
|
|
{"name": "Second Column", "value": "second", "selected": False, "options": second_options},
|
|
]
|
|
seen_in_column_1 = set()
|
|
seen_in_column_2 = set()
|
|
for line in contents.splitlines():
|
|
parts = line.split("\t")
|
|
if len(parts) >= 1:
|
|
val = parts[0]
|
|
if val not in seen_in_column_1:
|
|
first_options.append({"name": val.upper(), "value": val, "selected": False, "options": []})
|
|
seen_in_column_1.add(val)
|
|
if len(parts) >= 2:
|
|
val = parts[1]
|
|
if val not in seen_in_column_2:
|
|
second_options.append({"name": val.upper(), "value": val, "selected": False, "options": []})
|
|
seen_in_column_2.add(val)
|
|
return values
|