-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsv_templates.py
50 lines (38 loc) · 1.03 KB
/
tsv_templates.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
"""Tiny TSV templates engine."""
import json
def deserialize(serialized):
return map(lambda value: value, serialized.split('}{'))
def list_item(**_kwargs):
return ''
def main(table_definitions, **_kwargs):
return [
'table_name',
'field_name',
'field_type',
'field_length',
'relationship_type'
'relationship_table'
'flags',
'description'
]
return table_definitions
def table_definition(
table_id,
table_definition_rows,
table_relationships_rows,
**_kwarg
):
fields = deserialize(table_definition_rows)
relationships = deserialize(table_relationships_rows)
def table_definition_row(**kwargs):
return json.dumps(kwargs)
def table_relationships_rows(**kwargs):
return json.dumps(kwargs)
tsv_templates = {
'list_item': list_item,
'main': main,
'table_definition': table_definition,
'table_definition_row': table_definition_row,
'table_relationships_rows': table_relationships_rows,
}