2019-11-12 20:09:18 +01:00
|
|
|
#!/usr/bin/env python3
|
2019-11-12 14:36:23 +01:00
|
|
|
import sys
|
|
|
|
import re
|
2019-11-19 13:52:53 +01:00
|
|
|
from enum import IntEnum,auto,unique
|
2019-11-12 14:36:23 +01:00
|
|
|
import numpy as np
|
|
|
|
from pathlib import Path
|
|
|
|
from lib import LaTeX
|
2019-11-19 13:52:53 +01:00
|
|
|
from lib.Orientation import Orientation
|
2019-11-12 14:36:23 +01:00
|
|
|
from TexSoup import TexSoup
|
2019-11-23 18:08:27 +01:00
|
|
|
from lib.data import dataFileBase,dataType
|
2019-11-12 14:36:23 +01:00
|
|
|
import argparse
|
2019-11-23 18:08:27 +01:00
|
|
|
DEBUG=False
|
2019-11-12 14:36:23 +01:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('--file', type=argparse.FileType('r'))
|
2019-11-23 18:08:27 +01:00
|
|
|
parser.add_argument('--defaultType', type=str, choices=[t.name for t in list(dataType)])
|
2019-11-19 13:52:53 +01:00
|
|
|
parser.add_argument('--MoleculeOrentation',type=str, choices=[t.name for t in list(Orientation)],default=Orientation.LINE.name)
|
2019-11-12 14:36:23 +01:00
|
|
|
args = parser.parse_args()
|
|
|
|
print(args)
|
|
|
|
lines=args.file.readlines()
|
|
|
|
soup=TexSoup(lines)
|
|
|
|
commands=[LaTeX.newCommand(cmd) for cmd in soup.find_all("newcommand")]
|
|
|
|
dat=LaTeX.tabularToData(soup.tabular,commands)
|
|
|
|
scriptpath=Path(sys.argv[0]).resolve()
|
|
|
|
datapath=scriptpath.parents[1]/"static"/"data"
|
|
|
|
if DEBUG:
|
|
|
|
datapath=datapath/"test"
|
|
|
|
if not datapath.exists():
|
|
|
|
datapath.mkdir()
|
2019-11-23 18:08:27 +01:00
|
|
|
datalst=dataFileBase.readFromTable(dat,orientation=Orientation[args.MoleculeOrentation],default=dataType[args.defaultType])
|
2019-11-19 13:52:53 +01:00
|
|
|
for data in datalst:
|
|
|
|
data.toFile(datapath)
|