Fix some things that I broke and further cleanup

This commit is contained in:
David Robertson
2020-04-29 02:46:52 +01:00
parent 72c2dd5f26
commit a05c174ec8
41 changed files with 314 additions and 308 deletions

View File

@@ -709,11 +709,10 @@ class FlatCAMDefaults:
def __iter__(self):
return self.defaults.__iter__()
def set_change_callback(self, callback):
self.defaults.set_change_callback(callback)
def __getattr__(self, item):
# Unfortunately this method alone is not enough to pass through the other magic methods above.
return self.defaults.__getattribute__(item)
def update(self, *args, **kwargs):
return self.defaults.update(*args, **kwargs)
##### Additional Methods #####
@@ -828,4 +827,18 @@ class FlatCAMDefaults:
if param.find(routes[param].__name__.lower() + "_") == 0:
p = param[len(routes[param].__name__) + 1:]
if p in routes[param].defaults:
routes[param].defaults[p] = self.defaults[param]
routes[param].defaults[p] = self.defaults[param]
def report_usage(self, resource):
"""
Increments usage counter for the given resource
in self.defaults['global_stats'].
:param resource: Name of the resource.
:return: None
"""
if resource in self.defaults['global_stats']:
self.defaults['global_stats'][resource] += 1
else:
self.defaults['global_stats'][resource] = 1