pymchelper.utils.mcscripter module

Tool for creating MC input files using user-specified tables and ranges.

2019 - Niels Bassler

class pymchelper.utils.mcscripter.Config(fn)[source]

Bases: object

Reading the config file.

parse()[source]

Parse configuration file. All data are read into dicts. There are two dicts: a constant and variable (tabluated) one.

class pymchelper.utils.mcscripter.Generator(templ, cfg)[source]

Bases: object

This generates and writes the output files based on the loaded template files and the config file.

static get_keys(s)[source]

return list of ${} keys in string

static lreplace(s, f, r)[source]

Left adjusted replacement of string f with string r, in string s.

This function is implemented in order to fill in data in FORTRAN77 fields, which are tied to certain positions on the line, i.e. subsequent values may not be shifted.

Finds string f in string s and replaces it with string r, but left adjusted, retaining line length. If length of r is shorter than length of f, remaining chars will be space padded. If length of r is larger than length of f, then characters will be overwritten. A copy of s with the replacement is returned.

write(t, u_dict)[source]

Write a copy of the template, using the substitutions as specifed in the unique dictionary u_dict.

“Unique”, means that any _MIN _MAX _STEP type variables have been set.

class pymchelper.utils.mcscripter.McFile[source]

Bases: object

General MC single file object. This will be used for the template files as well as the generated output files.

write()[source]

Write self to disk, create symlink if that is the case.

class pymchelper.utils.mcscripter.Template(cfg)[source]

Bases: object

Read all files and symlinks specified in the config file, and place them in a list of McFile objects.

read(cfg)[source]

Reads all template files, and creates a list of McFile objects in self.files.

pymchelper.utils.mcscripter.main(args=None)[source]

Main function.