Skip to content

Commit

Permalink
refactor: Remove Map Class
Browse files Browse the repository at this point in the history
  • Loading branch information
dorukozturk committed Feb 15, 2023
1 parent 92ff66e commit 6b21cbc
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions hardeneks/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,38 +69,3 @@ def set_resources(self):
.list_namespaced_horizontal_pod_autoscaler(self.namespace)
.items
)

# Needed to convert dict to Map for testing purposes mainly.
# IF there is a better way for this, i'm all for it.
class Map(dict):
"""
Example:
m = Map({'first_name': 'Eduardo'}, last_name='Pool', age=24, sports=['Soccer'])
"""
def __init__(self, *args, **kwargs):
super(Map, self).__init__(*args, **kwargs)
for arg in args:
if isinstance(arg, dict):
for k, v in arg.items():
self[k] = v

if kwargs:
for k, v in kwargs.items():
self[k] = v

def __getattr__(self, attr):
return self.get(attr)

def __setattr__(self, key, value):
self.__setitem__(key, value)

def __setitem__(self, key, value):
super(Map, self).__setitem__(key, value)
self.__dict__.update({key: value})

def __delattr__(self, item):
self.__delitem__(item)

def __delitem__(self, key):
super(Map, self).__delitem__(key)
del self.__dict__[key]

0 comments on commit 6b21cbc

Please sign in to comment.