def hydrate(self, values):
def hydrate_(obj):<EOL><INDENT>if isinstance(obj, Structure):<EOL><INDENT>try:<EOL><INDENT>f = self.hydration_functions[obj.tag]<EOL><DEDENT>except KeyError:<EOL><INDENT>return obj<EOL><DEDENT>else:<EOL><INDENT>return f(*map(hydrate_, obj.fields))<EOL><DEDENT><DEDENT>elif isinstance(obj, list):<EOL><INDENT>return list(map(hydrate_, obj))<EOL><DEDENT>elif isinstance(obj, dict):<EOL><INDENT>return {key: hydrate_(value) for key, value in obj.items()}<EOL><DEDENT>else:<EOL><INDENT>return obj<EOL><DEDENT><DEDENT>return tuple(map(hydrate_, values))<EOL>
Convert PackStream values into native values.