Skip to content

Commit

Permalink
construct_scalar only works for scalar values.. who woulda thought
Browse files Browse the repository at this point in the history
  • Loading branch information
fenn committed Jul 17, 2009
1 parent 257b63a commit 0b6ccdd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pymates/pymates.py
Expand Up @@ -14,19 +14,19 @@ class Part(yaml.YAMLObject):
'''used for part mating. argh I hope OCC doesn't already implement this and I just don't know it.'''
yaml_tag = '!part'
yaml_pattern = re.compile("(.*)")
def __init__(self,name="generic part"):
pass
def __init__(self, name="generic part"):
self.name = name
def __repr__(self):
return "Part(name=%s)" % self.name
return "Part(name=%s)" % (self.name)
def yaml_repr(self):
return "!%s\n not implemented: foo" % (self.name, self.__name__)
return "not implemented: %s, %s" % (self.name, self.__class__.__name__) #yaml dumps tag automatically
@classmethod
def to_yaml(cls, dumper, data):
return dumper.represent_scalar(cls.yaml_tag, cls.yaml_repr(data))
@classmethod
def from_yaml(cls, loader, node):
data = loader.construct_scalar(node)
return Part(name="blah") #FIXME: completely wrong
data = loader.construct_mapping(node)
return cls(name=data) #better?

class Interface(yaml.YAMLObject):
'''"units" should be what is being transmitted through the interface, not about the structure.
Expand All @@ -41,7 +41,7 @@ def __init__(self, name, units=None, geometry=None):
def __repr__(self):
return "Interface(name=%s,units=%s,geometry=%s)" % (self.name, self.units, self.geometry)
def yaml_repr(self):
return "!%s\n not implemented: foo" % (self.name)
return "%s\n not implemented: foo" % (self.name)
@classmethod
def to_yaml(cls, dumper, data):
return dumper.represent_scalar(cls.yaml_tag, cls.yaml_repr(data))
Expand Down

0 comments on commit 0b6ccdd

Please sign in to comment.