Skip to content

Commit

Permalink
minor: pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Fiers committed Oct 23, 2012
1 parent d34d636 commit 2f12696
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/python/Yaco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def __setattr__(self, key, value):

#print "setting %s to %s" % (key, value)
old_value = super(Yaco, self).get(key, None)
#sys.stderr.write("\nSetting %s to %s (%s)\n" % (key, value, type(value)))

if isinstance(value, dict):
#setting a dict
Expand All @@ -148,15 +147,15 @@ def __setattr__(self, key, value):
else:
super(Yaco, self).__setitem__(key, Yaco(value))
elif isinstance(value, list):
#parse the list to see if there are dicts - which need to be translated to Yaco objects
# parse the list to see if there are dicts - which need to
# be translated to Yaco objects
new_value = self._list_parser(value)
super(Yaco, self).__setitem__(key, new_value)
else:
super(Yaco, self).__setitem__(key, value)

def has_key(self, key):
rv = super(Yaco, self).has_key(key)
return rv
return key in super(Yaco, self).keys()

def __getattr__(self, key):
"""
Expand All @@ -178,7 +177,6 @@ def __getattr__(self, key):
def __delitem__(self, name):
return super(Yaco, self).__delitem__(name)


def simple(self):
"""
return a simplified representation of this
Expand Down Expand Up @@ -232,7 +230,9 @@ def update(self, data):
>>> assert(v.a[3][1].b == 12)
"""
if not data: return
if not data:
return

for key, value in data.items():
#if isinstance(value, Yaco):
# raise Exception("Wow - updating with a Yaco - "+
Expand All @@ -245,7 +245,8 @@ def update(self, data):
else:
super(Yaco, self).__setitem__(key, Yaco(value))
elif isinstance(value, list):
#parse the list to see if there are dicts - which need to be translated to Yaco objects
# parse the list to see if there are dicts - which
# need to be translated to Yaco objects
new_value = self._list_parser(value)
super(Yaco, self).__setitem__(key, new_value)
else:
Expand All @@ -265,7 +266,8 @@ def load(self, from_file):
>>> import yaml
>>> import tempfile
>>> tf = tempfile.NamedTemporaryFile(delete=False)
>>> tf.write(yaml.dump({'a' : [1,2,3, [1,2,3, {'d' : 4}]], 'b': 4, 'c': '5'}))
>>> tf.write(yaml.dump({'a' : [1,2,3, [1,2,3, {'d' : 4}]],
... 'b': 4, 'c': '5'}))
>>> tf.close()
>>> y = Yaco()
>>> y.load(tf.name)
Expand Down

0 comments on commit 2f12696

Please sign in to comment.