Skip to content
Snippets Groups Projects
Commit 4053ed56 authored by Christoph.Knote's avatar Christoph.Knote
Browse files

Namelist sheet

parent 24dd7e4d
Branches
Tags
No related merge requests found
......@@ -50,34 +50,34 @@ class Namelist:
'''
def __getitem__(self, item):
if item.lower() in self.__namelist['boxmox'].keys():
return self.__namelist['boxmox'][item.lower()]
if item.lower() in self._namelist['boxmox'].keys():
return self._namelist['boxmox'][item.lower()]
else:
raise Exception('{:s} does not exist in Namelist.'.format(item))
def __setitem__(self, item, value):
if item.lower() in self.__namelist['boxmox'].keys():
if item.lower() in self._namelist['boxmox'].keys():
try:
self.__namelist['boxmox'][item] = value
self._namelist['boxmox'][item] = value
except:
raise Exception('Failed to set {:s} to {:s}'.format(item, str(value)))
else:
raise Exception('{:s} does not exist in Namelist'.format(item))
def __str__(self):
return ', '.join( [ ('{:s}: {:s}'.format(item, str(self.__namelist['boxmox'][item]))) for item in self.__namelist['boxmox'].keys() ] )
return ', '.join( [ ('{:s}: {:s}'.format(item, str(self._namelist['boxmox'][item]))) for item in self._namelist['boxmox'].keys() ] )
def keys(self):
return self.__namelist['boxmox'].keys()
return self._namelist['boxmox'].keys()
def write(self, path):
'''
Write namelist to file.
'''
self.__namelist.write(path, 'w')
self._namelist.write(path, 'w')
def read(self, path):
'''
Read namelist from file.
'''
self.__namelist = f90nml.read(path)
self._namelist = f90nml.read(path)
def __init__(self, path = None):
self.__namelist = None
self._namelist = None
firstExample = examples[examples.keys()[0]]
self.read(os.path.join(firstExample.path, "BOXMOX.nml"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment