mirror of
https://github.com/OpenFusionProject/scripts.git
synced 2024-11-22 06:00:05 +00:00
77 lines
1.6 KiB
Plaintext
77 lines
1.6 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import json"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def to_db_table_name_mappings(table):\n",
|
||
|
" mappings = {}\n",
|
||
|
" for subtable_name in table:\n",
|
||
|
" mappings[subtable_name] = \"\"\n",
|
||
|
" return mappings"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def gen_mappings(xdt):\n",
|
||
|
" mappings = {}\n",
|
||
|
" for table_name in xdt:\n",
|
||
|
" if \"table\" not in table_name.lower():\n",
|
||
|
" continue\n",
|
||
|
" table = xdt[table_name]\n",
|
||
|
" mappings[table_name] = to_db_table_name_mappings(table)\n",
|
||
|
" return mappings\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"with open('xdt.json', 'r') as f:\n",
|
||
|
" xdt = json.load(f)\n",
|
||
|
"mappings = gen_mappings(xdt)\n",
|
||
|
"with open('mappings.json', 'w') as f:\n",
|
||
|
" json.dump(mappings, f, indent=4)"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": ".venv",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.10.12"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|