10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-07-22 18:57:38 +02:00

Add prefix support

This commit is contained in:
Mickaël Véril 2020-03-28 13:21:47 +01:00
parent dafaf023f7
commit f1f51a7c62
2 changed files with 6 additions and 4 deletions

View File

@ -13,8 +13,8 @@ parser = argparse.ArgumentParser()
parser.add_argument('--file', type=argparse.FileType('r'))
parser.add_argument('--defaultType', type=str, choices=[t.name for t in list(dataType)])
parser.add_argument('--format',type=str, choices=[t.name for t in list(Format)],default=Format.LINE.name)
parser.add_argument('--debug', action='store_true', help='Debug mode'
)
parser.add_argument('--debug', action='store_true', help='Debug mode')
parser.add_argument('--prefix',type=str,default=None)
args = parser.parse_args()
print(args)
lines=args.file.readlines()
@ -29,4 +29,4 @@ if not datapath.exists():
datapath.mkdir()
datalst=dataFileBase.readFromTable(dat,format=Format[args.format],default=dataType[args.defaultType],commands=commands)
for data in datalst:
data.toFile(datapath)
data.toFile(datapath,args.prefix)

View File

@ -238,13 +238,15 @@ class dataFileBase(object):
dic["DOI"]="" if self.DOI is None else self.DOI
return dic
def toFile(self,datadir):
def toFile(self,datadir,prefix=None):
subpath=datadir/self.GetFileType().name.lower()
if not subpath.exists():
subpath.mkdir()
fileNameComp=[self.molecule.lower().replace(" ","_"),self.method.name]
if self.method.basis:
fileNameComp.append(self.method.basis)
if prefix:
fileNameComp.append(prefix)
fileName="_".join(fileNameComp)+".dat"
file=subpath/fileName
if not file.exists():