Commit 1565117b authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

renaming and commenting:

i renamed _userAttributesKeys to _attributesToUpdateKeys because this is what they are.
the attribute in this list are updated by the function update noyhing eslse.

i also renamed rdict as rest, for two reasons, first the python standars suggests to avoid
types in names (unnecessary information) and 'r' was not telling anything.
rest seems to be appropriate since it represent the rest of keywords from kwargs.

I also add a second condition for printing debug info in update: the rest dict0
should not be empty, again would be too much info.
parent a3cc352e
......@@ -83,19 +83,24 @@ class MyFig_base(Figure):
# CONSTRUCTOR --------------------------------------------------------
def __init__(self, rawdata, *args, **kwargs):
self._userAttributesKeys = ['fignum', 'reformat','debug','formatted']
# for the update function
self._attributesToUpdateKeys = ['fignum', 'reformat', 'debug', 'formatted']
# initialise the attribute default values and remove them from kwargs
self.fignum = kwargs.pop('fignum', -1) # need to be hard coded for interactive mode
self.reformat = kwargs.pop('reformat', D_REFORMAT)
self.debug = kwargs.pop('debug', D_DEBUG)
self.formatted = kwargs.pop('formatted', D_FORMATTED)
if hasattr(self,"keywords") :
# update the keywords with there values
if hasattr(self, "keywords") :
for key in self.keywords.keys() :
kwargs.pop(key,None) # remove key if exists
kwargs.pop(key, None) # remove key if exists
self.keywords = {}
# initialise the rawdata
self.rawdata = rawdata
# add figsize in the kwargs for Figure.__init__
......@@ -126,13 +131,13 @@ class MyFig_base(Figure):
# UPDATE -------------------------------------------------------------
def update(self, **kwargs):
rdict = dict()
rest = dict()
# check attributes in keywords
for keyword in kwargs.keys():
# if it is an attribute
if keyword in self._userAttributesKeys:
if keyword in self._attributesToUpdateKeys:
# update value
setattr(self, keyword, kwargs[keyword])
......@@ -146,10 +151,12 @@ class MyFig_base(Figure):
rdict.update({keyword : kwargs[keyword]})
rest.update({keyword : kwargs[keyword]})
if (self.debug) :
print(DBUG + "These keywords have not been updated: " + str(rdict))
if (self.debug and rest != {}) :
print(DBUG + "These keywords have not been updated: " + str(rest))
# PRINT 2 FILE -------------------------------------------------------
Supports Markdown
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