Python yaml 模块,loader() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用yaml.loader()

项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def HandleEvent(self, event, loader=None):
    """Handle individual PyYAML event.

    Args:
      event: Event to forward to method call in method call.

    Raises:
      IllegalEvent when receives an unrecognized or unsupported event type.
    """

    if event.__class__ not in _EVENT_METHOD_MAP:
      raise yaml_errors.IllegalEvent(
            "%s is not a valid PyYAML class" % event.__class__.__name__)

    if event.__class__ in self._event_method_map:
      self._event_method_map[event.__class__](event, loader)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def HandleEvent(self, event, loader=None):
    """Handle individual PyYAML event.

    Args:
      event: Event to forward to method call in method call.

    Raises:
      IllegalEvent when receives an unrecognized or unsupported event type.
    """

    if event.__class__ not in _EVENT_METHOD_MAP:
      raise yaml_errors.IllegalEvent(
            "%s is not a valid PyYAML class" % event.__class__.__name__)

    if event.__class__ in self._event_method_map:
      self._event_method_map[event.__class__](event, loader)
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def HandleEvent(self, event, loader=None):
    """Handle individual PyYAML event.

    Args:
      event: Event to forward to method call in method call.

    Raises:
      IllegalEvent when receives an unrecognized or unsupported event type.
    """

    if event.__class__ not in _EVENT_METHOD_MAP:
      raise yaml_errors.IllegalEvent(
            "%s is not a valid PyYAML class" % event.__class__.__name__)

    if event.__class__ in self._event_method_map:
      self._event_method_map[event.__class__](event, loader)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def HandleEvent(self, event, loader=None):
    """Handle individual PyYAML event.

    Args:
      event: Event to forward to method call in method call.

    Raises:
      IllegalEvent when receives an unrecognized or unsupported event type.
    """

    if event.__class__ not in _EVENT_METHOD_MAP:
      raise yaml_errors.IllegalEvent(
            "%s is not a valid PyYAML class" % event.__class__.__name__)

    if event.__class__ in self._event_method_map:
      self._event_method_map[event.__class__](event, loader)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def HandleEvent(self, event, loader=None):
    """Handle individual PyYAML event.

    Args:
      event: Event to forward to method call in method call.

    Raises:
      IllegalEvent when receives an unrecognized or unsupported event type.
    """

    if event.__class__ not in _EVENT_METHOD_MAP:
      raise yaml_errors.IllegalEvent(
            "%s is not a valid PyYAML class" % event.__class__.__name__)

    if event.__class__ in self._event_method_map:
      self._event_method_map[event.__class__](event, loader)
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def StreamStart(self, event, loader):
    """Handle start of stream event"""
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def StreamEnd(self, event, loader):
    """Handle end of stream event"""
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def DocumentStart(self, event, loader):
    """Handle start of document event"""
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def DocumentEnd(self, event, loader):
    """Handle end of document event"""
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def Alias(self, event, loader):
    """Handle alias event"""
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def SequenceStart(self, event, loader):
    """Handle start of sequence event"""
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def SequenceEnd(self, event, loader):
    """Handle end of sequence event"""
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def MappingStart(self, event, loader):
    """Handle start of mappping event"""
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def MappingEnd(self, event, loader):
    """Handle end of mapping event"""
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def _GenerateEventParameters(self,
                               stream,
                               loader_class=yaml.loader.SafeLoader):
    """Creates a generator that yields event, loader parameter pairs.

    For use as parameters to HandleEvent method for use by Parse method.
    During testing, _GenerateEventParameters is simulated by allowing
    the harness to pass in a list of pairs as the parameter.

    A list of (event, loader) pairs must be passed to _HandleEvents otherwise
    it is not possible to pass the loader instance to the handler.

    Also responsible for instantiating the loader from the Loader
    parameter.

    Args:
      stream: String document or open file object to process as per the
        yaml.parse method.  Any object that implements a 'read()' method which
        returns a string document will work.
      Loader: Loader class to use as per the yaml.parse method.  Used to
        instantiate new yaml.loader instance.

    Yields:
      Tuple(event, loader) where:
        event: Event emitted by PyYAML loader.
        loader_class: Used for dependency injection.
    """
    assert loader_class is not None
    try:
      loader = loader_class(stream)
      while loader.check_event():
        yield (loader.get_event(), loader)
    except yaml.error.YAMLError, e:
      raise yaml_errors.EventListenerYAMLError(e)
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def Parse(self, stream, loader_class=yaml.loader.SafeLoader):
    """Call YAML parser to generate and handle all events.

    Calls PyYAML parser and sends resulting generator to handle_event method
    for processing.

    Args:
      stream: String document or open file object to process as per the
        yaml.parse method.  Any object that implements a 'read()' method which
        returns a string document will work with the YAML parser.
      loader_class: Used for dependency injection.
    """
    self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def StreamStart(self, event, loader):
    """Handle start of stream event"""
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def StreamEnd(self, event, loader):
    """Handle end of stream event"""
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def DocumentStart(self, event, loader):
    """Handle start of document event"""
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def DocumentEnd(self, event, loader):
    """Handle end of document event"""
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def Alias(self, event, loader):
    """Handle alias event"""
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def SequenceStart(self, event, loader):
    """Handle start of sequence event"""
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def SequenceEnd(self, event, loader):
    """Handle end of sequence event"""
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def MappingStart(self, event, loader):
    """Handle start of mappping event"""
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def MappingEnd(self, event, loader):
    """Handle end of mapping event"""
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def _GenerateEventParameters(self,
                               stream,
                               loader_class=yaml.loader.SafeLoader):
    """Creates a generator that yields event, loader parameter pairs.

    For use as parameters to HandleEvent method for use by Parse method.
    During testing, _GenerateEventParameters is simulated by allowing
    the harness to pass in a list of pairs as the parameter.

    A list of (event, loader) pairs must be passed to _HandleEvents otherwise
    it is not possible to pass the loader instance to the handler.

    Also responsible for instantiating the loader from the Loader
    parameter.

    Args:
      stream: String document or open file object to process as per the
        yaml.parse method.  Any object that implements a 'read()' method which
        returns a string document will work.
      Loader: Loader class to use as per the yaml.parse method.  Used to
        instantiate new yaml.loader instance.

    Yields:
      Tuple(event, loader) where:
        event: Event emitted by PyYAML loader.
        loader_class: Used for dependency injection.
    """
    assert loader_class is not None
    try:
      loader = loader_class(stream)
      while loader.check_event():
        yield (loader.get_event(), loader)
    except yaml.error.YAMLError, e:
      raise yaml_errors.EventListenerYAMLError(e)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def Parse(self, stream, loader_class=yaml.loader.SafeLoader):
    """Call YAML parser to generate and handle all events.

    Calls PyYAML parser and sends resulting generator to handle_event method
    for processing.

    Args:
      stream: String document or open file object to process as per the
        yaml.parse method.  Any object that implements a 'read()' method which
        returns a string document will work with the YAML parser.
      loader_class: Used for dependency injection.
    """
    self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def StreamStart(self, event, loader):
    """Handle start of stream event"""
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def StreamEnd(self, event, loader):
    """Handle end of stream event"""
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def DocumentStart(self, event, loader):
    """Handle start of document event"""
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def DocumentEnd(self, event, loader):
    """Handle end of document event"""
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def Alias(self, event, loader):
    """Handle alias event"""
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def SequenceStart(self, event, loader):
    """Handle start of sequence event"""
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def SequenceEnd(self, event, loader):
    """Handle end of sequence event"""
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def MappingStart(self, event, loader):
    """Handle start of mappping event"""
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def MappingEnd(self, event, loader):
    """Handle end of mapping event"""
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def _GenerateEventParameters(self,
                               stream,
                               loader_class=yaml.loader.SafeLoader):
    """Creates a generator that yields event, loader parameter pairs.

    For use as parameters to HandleEvent method for use by Parse method.
    During testing, _GenerateEventParameters is simulated by allowing
    the harness to pass in a list of pairs as the parameter.

    A list of (event, loader) pairs must be passed to _HandleEvents otherwise
    it is not possible to pass the loader instance to the handler.

    Also responsible for instantiating the loader from the Loader
    parameter.

    Args:
      stream: String document or open file object to process as per the
        yaml.parse method.  Any object that implements a 'read()' method which
        returns a string document will work.
      Loader: Loader class to use as per the yaml.parse method.  Used to
        instantiate new yaml.loader instance.

    Yields:
      Tuple(event, loader) where:
        event: Event emitted by PyYAML loader.
        loader_class: Used for dependency injection.
    """
    assert loader_class is not None
    try:
      loader = loader_class(stream)
      while loader.check_event():
        yield (loader.get_event(), loader)
    except yaml.error.YAMLError, e:
      raise yaml_errors.EventListenerYAMLError(e)
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def Parse(self, stream, loader_class=yaml.loader.SafeLoader):
    """Call YAML parser to generate and handle all events.

    Calls PyYAML parser and sends resulting generator to handle_event method
    for processing.

    Args:
      stream: String document or open file object to process as per the
        yaml.parse method.  Any object that implements a 'read()' method which
        returns a string document will work with the YAML parser.
      loader_class: Used for dependency injection.
    """
    self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def StreamStart(self, event, loader):
    """Handle start of stream event"""
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def StreamEnd(self, event, loader):
    """Handle end of stream event"""
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def DocumentStart(self, event, loader):
    """Handle start of document event"""
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def DocumentEnd(self, event, loader):
    """Handle end of document event"""
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def Alias(self, event, loader):
    """Handle alias event"""
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def SequenceStart(self, event, loader):
    """Handle start of sequence event"""
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def SequenceEnd(self, event, loader):
    """Handle end of sequence event"""
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def MappingStart(self, event, loader):
    """Handle start of mappping event"""
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def MappingEnd(self, event, loader):
    """Handle end of mapping event"""
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def _GenerateEventParameters(self,
                               stream,
                               loader_class=yaml.loader.SafeLoader):
    """Creates a generator that yields event, loader parameter pairs.

    For use as parameters to HandleEvent method for use by Parse method.
    During testing, _GenerateEventParameters is simulated by allowing
    the harness to pass in a list of pairs as the parameter.

    A list of (event, loader) pairs must be passed to _HandleEvents otherwise
    it is not possible to pass the loader instance to the handler.

    Also responsible for instantiating the loader from the Loader
    parameter.

    Args:
      stream: String document or open file object to process as per the
        yaml.parse method.  Any object that implements a 'read()' method which
        returns a string document will work.
      Loader: Loader class to use as per the yaml.parse method.  Used to
        instantiate new yaml.loader instance.

    Yields:
      Tuple(event, loader) where:
        event: Event emitted by PyYAML loader.
        loader_class: Used for dependency injection.
    """
    assert loader_class is not None
    try:
      loader = loader_class(stream)
      while loader.check_event():
        yield (loader.get_event(), loader)
    except yaml.error.YAMLError, e:
      raise yaml_errors.EventListenerYAMLError(e)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def Parse(self, stream, loader_class=yaml.loader.SafeLoader):
    """Call YAML parser to generate and handle all events.

    Calls PyYAML parser and sends resulting generator to handle_event method
    for processing.

    Args:
      stream: String document or open file object to process as per the
        yaml.parse method.  Any object that implements a 'read()' method which
        returns a string document will work with the YAML parser.
      loader_class: Used for dependency injection.
    """
    self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def StreamStart(self, event, loader):
    """Handle start of stream event"""