diff --git a/LCS/pyparameterset/src/__init__.py b/LCS/pyparameterset/src/__init__.py index bd37643c8fbef2d3a51f14685632cd55cacd37ee..bf9d2a8f54b07345e4d0297f697897a1e17915d1 100755 --- a/LCS/pyparameterset/src/__init__.py +++ b/LCS/pyparameterset/src/__init__.py @@ -161,6 +161,16 @@ class parameterset(PyParameterSet): self.replace (str(k), str(v)) # k, v always type string + @staticmethod + def fromString(parset_string): + '''Create a parset from a plain text string. + Splits the string in lines, and parses each '=' seperated key/value pair. + ''' + lines = [l.strip() for l in parset_string.split('\n')] + kv_pairs = [tuple(l.split('=')) for l in lines if '=' in l] + parset_dict = dict(kv_pairs) + return parameterset(parset_dict) + def get(self, key): # type: (object) -> object """Get the parametervalue object of a parameter."""