當前位置: 首頁>>代碼示例>>Python>>正文


Python yaml.loader方法代碼示例

本文整理匯總了Python中yaml.loader方法的典型用法代碼示例。如果您正苦於以下問題:Python yaml.loader方法的具體用法?Python yaml.loader怎麽用?Python yaml.loader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yaml的用法示例。


在下文中一共展示了yaml.loader方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: HandleEvent

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
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) 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:18,代碼來源:yaml_listener.py

示例2: safe_load

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def safe_load(stream):
    """implementation of safe loader using Ordered Dict Yaml Loader"""
    return yaml.load(stream, ODYL) 
開發者ID:zerwes,項目名稱:hiyapyco,代碼行數:5,代碼來源:odyldo.py

示例3: StreamStart

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def StreamStart(self, event, loader):
    """Handle start of stream event""" 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:4,代碼來源:yaml_listener.py

示例4: StreamEnd

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def StreamEnd(self, event, loader):
    """Handle end of stream event""" 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:4,代碼來源:yaml_listener.py

示例5: DocumentStart

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def DocumentStart(self, event, loader):
    """Handle start of document event""" 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:4,代碼來源:yaml_listener.py

示例6: DocumentEnd

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def DocumentEnd(self, event, loader):
    """Handle end of document event""" 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:4,代碼來源:yaml_listener.py

示例7: Alias

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def Alias(self, event, loader):
    """Handle alias event""" 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:4,代碼來源:yaml_listener.py

示例8: SequenceStart

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def SequenceStart(self, event, loader):
    """Handle start of sequence event""" 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:4,代碼來源:yaml_listener.py

示例9: SequenceEnd

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def SequenceEnd(self, event, loader):
    """Handle end of sequence event""" 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:4,代碼來源:yaml_listener.py

示例10: MappingStart

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def MappingStart(self, event, loader):
    """Handle start of mappping event""" 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:4,代碼來源:yaml_listener.py

示例11: MappingEnd

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
def MappingEnd(self, event, loader):
    """Handle end of mapping event""" 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:4,代碼來源:yaml_listener.py

示例12: _GenerateEventParameters

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
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) 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:36,代碼來源:yaml_listener.py

示例13: Parse

# 需要導入模塊: import yaml [as 別名]
# 或者: from yaml import loader [as 別名]
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)) 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:15,代碼來源:yaml_listener.py


注:本文中的yaml.loader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。