Esempio n. 1
0
 def __init__(self, stream, version=None, preserve_quotes=None):
     Reader.__init__(self, stream)
     Scanner.__init__(self)
     Parser.__init__(self)
     Composer.__init__(self)
     BaseConstructor.__init__(self)
     BaseResolver.__init__(self)
Esempio n. 2
0
 def __init__(self, stream, version=None, preserve_quotes=None):
     # type: (StreamTextType, VersionType, 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)
Esempio n. 3
0
 def __init__(self, stream, version=None, preserve_quotes=None):
     # type: (StreamTextType, Optional[VersionType], Optional[bool]) -> None
     self.comment_handling = 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)
Esempio n. 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
Esempio n. 5
0
 def env_var_constructor(loader: BaseConstructor, node: ScalarNode) -> Text:
     """Process environment variables found in the YAML."""
     value = loader.construct_scalar(node)
     expanded_vars = os.path.expandvars(value)
     not_expanded = [
         w for w in expanded_vars.split()
         if w.startswith("$") and w in value
     ]
     if not_expanded:
         raise RasaException(
             f"Error when trying to expand the environment variables in '{value}'. "
             f"Please make sure to also set these environment variables: '{not_expanded}'."
         )
     return expanded_vars
Esempio n. 6
0
 def __init__(self, stream, version=None, preserve_quotes=None):
     CParser.__init__(self, stream)
     BaseConstructor.__init__(self)
     BaseResolver.__init__(self)
Esempio n. 7
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)
Esempio n. 8
0
 def __init__(self, stream, version=None, preserve_quotes=None):
     CParser.__init__(self, stream)
     BaseConstructor.__init__(self)
     BaseResolver.__init__(self)