diff options
author | 2016-11-09 15:32:17 -0800 | |
---|---|---|
committer | 2016-11-09 15:33:38 -0800 | |
commit | c1ec492a9788d7cc120d945721b1bfe4b0eb1d90 (patch) | |
tree | 84944eee22f19a360505a20bceccd79d280fe2d3 /Python/pywarpx/Bucket.py | |
parent | e79c90f63b188bd8a45d6feb087861d90b0a7076 (diff) | |
download | WarpX-c1ec492a9788d7cc120d945721b1bfe4b0eb1d90.tar.gz WarpX-c1ec492a9788d7cc120d945721b1bfe4b0eb1d90.tar.zst WarpX-c1ec492a9788d7cc120d945721b1bfe4b0eb1d90.zip |
Initial python wrapped version
Diffstat (limited to 'Python/pywarpx/Bucket.py')
-rw-r--r-- | Python/pywarpx/Bucket.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Python/pywarpx/Bucket.py b/Python/pywarpx/Bucket.py new file mode 100644 index 000000000..5ea65916f --- /dev/null +++ b/Python/pywarpx/Bucket.py @@ -0,0 +1,26 @@ + +class Bucket(object): + """ + The purpose of this class is to be a named bucket for holding attributes. + This attributes will be concatenated into a string and passed into argv during initialization. + """ + def __init__(self, instancename): + self._localsetattr('instancename', instancename) + self._localsetattr('argvattrs', []) + + def _localsetattr(self, name, value): + object.__setattr__(self, name, value) + + def __setattr__(self, name, value): + self.argvattrs.append(name) + #self.__dict__[name] = value + object.__setattr__(self, name, value) + + def attrlist(self): + "Concatenate the attributes into a string" + result = [] + for attr in self.argvattrs: + attrstring = '{0}.{1}={2} '.format(self.instancename, attr, getattr(self, attr)) + result += [attrstring] + return result + |