Commit 1cadb43e authored by Lukas Riedel's avatar Lukas Riedel 📝

Replace configparser by DUNE inifile parser in parfield module

parent 130c12d4
import h5py
import os
import sys
import configparser
import numpy as np
from dune.testtools.parser import parse_ini_file
from dorie.utilities.text_to_bool import text_to_bool
class BaseConverter(object):
......@@ -20,9 +21,7 @@ class BaseConverter(object):
_dataset = None # The field to be written into the target file
def __init__(self, param, input_file=None):
self._cp = configparser.ConfigParser(interpolation=None)
with open(param) as file:
self._cp.read_file(file)
self._cp = parse_ini_file(param)
outfile = self._read_parameter('general', 'outputFile')
dataset = self._read_parameter('general', 'dataset')
......
......@@ -8,7 +8,8 @@ import argparse
import warnings
import subprocess
import multiprocessing
import configparser
from dune.testtools.parser import parse_ini_file
from dorie.parfield.converter import BaseConverter, \
BinaryConverter, \
......@@ -47,14 +48,13 @@ if __name__ == "__main__":
parser.add_argument('--debug',help='Display warnings',action='store_true',required=False)
args = vars(parser.parse_args())
cp = configparser.ConfigParser(interpolation=None)
with open(args["param"]) as file:
cp.read_file(file)
# retrieve the inifile tree
inifile = parse_ini_file(args["param"])
params = {}
for par in ("converter", "outputFile"):
try:
params[par] = cp["general"][par]
params[par] = inifile["general"][par]
except KeyError:
raise RuntimeError("Missing option general.{} in "
"parameter file {}".format(par, args["param"]))
......@@ -72,7 +72,7 @@ if __name__ == "__main__":
print("FFT Field generator failed")
sys.exit(1)
rng_outpath = cp.get("general", "tempDir")
rng_outpath = inifile["general"]["tempDir"]
input_file = os.path.join(rng_outpath, "field.stoch.h5")
# CALL CONVERTER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment