Пример #1
0
def add_multi_constructor(tag_prefix, multi_constructor, Loader=None,
                          constructor=Constructor):
    # type: (Any, Any, Any, Any) -> None
    """
    Add a multi-constructor for the given tag prefix.
    Multi-constructor is called for a node if its tag starts with tag_prefix.
    Multi-constructor accepts a Loader instance, a tag suffix,
    and a node object and produces the corresponding Python object.
    """
    if Loader is None:
        constructor.add_multi_constructor(tag_prefix, multi_constructor)
    else:
        if False and hasattr(Loader, 'add_multi_constructor'):
            Loader.add_multi_constructor(tag_prefix, constructor)
            return
        if issubclass(Loader, BaseLoader):
            BaseConstructor.add_multi_constructor(tag_prefix, multi_constructor)
        elif issubclass(Loader, SafeLoader):
            SafeConstructor.add_multi_constructor(tag_prefix, multi_constructor)
        elif issubclass(Loader, google.appengine._internal.ruamel.yaml.loader.Loader):
            Constructor.add_multi_constructor(tag_prefix, multi_constructor)
        elif issubclass(Loader, RoundTripLoader):
            RoundTripConstructor.add_multi_constructor(tag_prefix, multi_constructor)
        else:
            raise NotImplementedError
Пример #2
0
 def __init__(self, stream, version=None, preserve_quotes=None):
     # type: (StreamTextType, Optional[VersionType], Optional[bool]) -> None
     Reader.__init__(self, stream, loader=self)
     Scanner.__init__(self, loader=self)
     Parser.__init__(self, loader=self)
     Composer.__init__(self, loader=self)
     BaseConstructor.__init__(self, loader=self)
     VersionedResolver.__init__(self, version, loader=self)
Пример #3
0
 def __init__(self, stream, version=None, preserve_quotes=None):
     # type: (StreamTextType, Optional[VersionType], Optional[bool]) -> None
     Reader.__init__(self, stream, loader=self)
     Scanner.__init__(self, loader=self)
     Parser.__init__(self, loader=self)
     Composer.__init__(self, loader=self)
     BaseConstructor.__init__(self, loader=self)
     VersionedResolver.__init__(self, version, loader=self)
Пример #4
0
def add_constructor(tag, object_constructor, Loader=None, constructor=Constructor):
    # type: (Any, Any, Any, Any) -> None
    """
    Add an object constructor for the given tag.
    object_onstructor is a function that accepts a Loader instance
    and a node object and produces the corresponding Python object.
    """
    if Loader is None:
        constructor.add_constructor(tag, object_constructor)
    else:
        if hasattr(Loader, 'add_constructor'):
            Loader.add_constructor(tag, object_constructor)
            return
        if issubclass(Loader, BaseLoader):
            BaseConstructor.add_constructor(tag, object_constructor)
        elif issubclass(Loader, SafeLoader):
            SafeConstructor.add_constructor(tag, object_constructor)
        elif issubclass(Loader, Loader):
            Constructor.add_constructor(tag, object_constructor)
        elif issubclass(Loader, RoundTripLoader):
            RoundTripConstructor.add_constructor(tag, object_constructor)
        else:
            raise NotImplementedError
Пример #5
0
 def __init__(self, stream, version=None, preserve_quotes=None):
     # type: (StreamTextType, Optional[VersionType], Optional[bool]) -> None
     CParser.__init__(self, stream)
     self._parser = self._composer = self
     BaseConstructor.__init__(self, loader=self)
     BaseResolver.__init__(self, loadumper=self)
Пример #6
0
 def __init__(self, stream, version=None, preserve_quotes=None):
     # type: (StreamTextType, Optional[VersionType], Optional[bool]) -> None
     CParser.__init__(self, stream)
     self._parser = self._composer = self
     BaseConstructor.__init__(self, loader=self)
     BaseResolver.__init__(self, loadumper=self)