OS : Linux
PHP Version : 7.4.33
Software : Apache/2.4.6 (CentOS) PHP/7.4.33
Information System : Linux apprendre2 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
Disable Function : ó
.Åt_c @ sH d Z d d l Z d d l Z e j d ƒ d e j f d „ ƒ YZ d S( s}
YAMLObject - Provides mapping to/from YAML.
$Id: //eng/vdo-releases/magnesium/src/python/vdo/utils/YAMLObject.py#2 $
iÿÿÿÿNt utilst
YAMLObjectc B sŒ e Z d Z e j Z e d „ ƒ Z e d „ ƒ Z d „ Z e d „ ƒ Z
e d „ ƒ Z e d „ ƒ Z
d „ Z e d „ ƒ Z d „ Z RS(
s÷ Provides conversion of objects to and from YAML representations.
The attributes that are included in the YAML representation are taken
from an instance's __dict__ filtered through the list returned from the
_yamlAttributeKeys property.
The list from the _yamlAttributeKeys property is used to check for missing
attributes when generating the YAML representation. It is also used
to check for missing or extraneous attributes when constructing an instance
from the YAML representation.
Subclasses must override _yamlAttributeKeys.
Subclasses must specify the class attribute yaml_tag which indicates the type
of the instance in the YAML representation.
Class attributes:
yaml_tag (unicode string) - YAML representation identfifier;
must be specified by subclasses
yaml_loader - The loader to use; set to yaml.SafeLoader
to allow yaml.load_safe() to instantiate
objects
c c s1 | j ƒ } | V| j | ƒ } | j | ƒ d S( sˆ Constructs and returns an instance from its YAML representation.
Returns:
instance constructed from YAML representation.
N( t _yamlMakeInstancet construct_mappingt _yamlSetAttributes( t clst loadert nodet instancet mapping( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyt from_yaml> s c C s | j } | j | j | ƒ S( sg Returns a YAML representation of the instance.
Returns:
YAML representation of instance
( t _yamlDatat represent_mappingt yaml_tag( R t dumpert datat yamlData( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyt to_yamlK s c C s t t | ƒ j ƒ i | _ d S( N( t superR t __init__t _preservedExtraAttributes( t self( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyR V s c C s | ƒ S( s Returns an instance of the class specifying placeholder values for
any arguments required by the __init__ method.
The default implementation is to instantiate without arguments.
Subclasses must override if their __init__ method takes arguments.
( ( R ( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyR ] s c C sf t g | j j ƒ D]6 \ } } | | j k r | | j k r | | f ^ q ƒ } | j | j ƒ | S( s
Returns a dictionary containing the data to include in generating
the instance's YAML representation.
The base implementation uses the contents of the instance's __dict__
filtered through the list of keys returned from _yamlAttributeKeys
excluding any that require special handling (subclasses must override this
method to add those) and adds any entries from the preserved extra
attributes.
Returns:
dictionary of data to use in generating the instance's YAML
representation
( t dictt __dict__t iteritemst _yamlAttributeKeyst _yamlSpeciallyHandledAttributest updateR ( R t keyt valueR ( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyR h s $c C s
t ‚ d S( sö Returns a list of the keys for the attributes to include in the
instance's YAML representation.
Must be overridden by subclasses.
Returns:
list of keys for attributes to include in the instance's YAML
representation
N( t NotImplementedError( R ( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyR € s c C s¶ t g | j ƒ D]' \ } } | | j k r | | f ^ q ƒ } | j j | ƒ g | j ƒ D]* } | | j k r] | | j k r] | ^ q] } x" | D] } t | | | | ƒ q” Wd S( s¯ Sets the instance's internal attributes from the YAML attributes.
By default, the attributes are set via invoking setattr() targeted
to the instance. If a subclass uses different internal names or
computes the attributes in some way it must override this method
to handle the attributes appropriately. The subclass must also account
for the possibility that the attributes it receives may not contain the
entirety of such specially handled attributes; in other words, it must
check for each attribute's existence in the attributes dictionary it
receives. Any unspecified attributes must be given a default value in
whatever manner the subclass chooses.
Any entries in the specified attributes which are unknown to the entity
being constructed are preserved for later use in generating YAML output.
Arguments:
attributes (dictionary) - the attributes from the YAML representation
N( R t itemsR R R t keysR t setattr( R t
attributesR R t extraR ( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyR Ž s $
c C s g S( s Returns a list of attributes that are specially handled by subclasses.
These attributes are skipped by _yamlData and _yamlSetAttributes
implemented by YAMLObject.
Subclasses must override both _yamlData and _yamlSetAttributes to handle
these attributes.
( ( R ( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyR s c C sA t | t | ƒ ƒ s* t t d ƒ ƒ ‚ n | j j | j ƒ d S( sˆ Updates the current object (self) from the specified instance.
This is for classes that perform indirect construction using the results
of the YAML load. Instances of such classes are required to invoke this
method themselves.
The specified instance must be the same class (or a subclass) of the
current object to guarantee that any attributes the current object attempts
to update will be available from the instance.
Arguments:
instance (YAMLObject) - object source for update
Raises:
TypeError - specified instance is not the same class (or a subclass)
of the current object
s( attempt to update from incompatible typeN( t
isinstancet typet TypeErrort _R R ( R R ( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyt _yamlUpdateFromInstance¹ s ( t __name__t
__module__t __doc__t yamlt
SafeLoadert yaml_loadert classmethodR
R R R t propertyR R R R R( ( ( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyR " s
( R+ t gettextR, t installR ( ( ( s8 /usr/lib/python2.7/site-packages/vdo/utils/YAMLObject.pyt