Commit 6808891d authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

Modified the way keywords are updated

- Now the figure calls the update function of axes
  This is cleaner and object oriented.

def update(self, **kwargs):

    for ax in self.get_axes():
        ax.update(**kwargs)
parent 60942fcf
......@@ -100,3 +100,11 @@ class MyAxes(Axes):
# TESTING THE RAWDATA ------------------------------------------------
def testRawData(self, rawdata):
return(True)
# UPDATE -------------------------------------------------------------
def update(self, **kwargs):
for key in kwargs.keys():
if key in self.keywords.keys():
self.keywords[key] = kwargs[key]
......@@ -138,33 +138,27 @@ class MyFig(Figure):
# update value
setattr(self, keyword, kwargs[keyword])
del rest[keyword]
# For each axes update the keywords
for ax in self.get_axes():
# if aliases is defined with that name
elif keyword in self.aliases.keys():
# update
ax, key = self.aliases[keyword]
ax.keywords[key] = kwargs[keyword]
del rest[keyword]
axrest = rest.copy() # make a copy of rest for this axes
# either a keywords or crap
else:
# if it is an axes keyword
for ax in self.get_axes() :
# Check if a key of rest has an alias for this axes
for krest in rest.keys():
if krest in self.aliases.keys():
alax, alkey = self.aliases[krest]
if keyword in ax.keywords.keys():
ax.keywords.update({keyword: kwargs[keyword]})
delete = True
if delete:
del rest[keyword]
# if there were some crap
if (self.debug and rest != {}) :
print(DBUG + "These keywords have not been updated: " + str(rest))
# If an alias is found then update the rest
if ax == alax:
axrest.update({alkey: rest[krest]})
# When eventual alias are added then update
ax.update(**axrest)
return(True)
# DECLARE ALIASES -------------------------------------------------
def declareAliases(self):
self.aliases = {}
......
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