Modify

Ticket #209 (new enhancement)

Opened 2 years ago

YAMLObject to work with any loader

Reported by: poke Owned by: xi
Priority: normal Component: pyyaml
Severity: normal Keywords:
Cc:

Description

I’m using SafeLoader with all my PyYAML load commands. However to be able to use custom YAMLObjects, I am required to set the custom object’s yaml_loader property to that loader as well to make it discoverable. This should work differently, so a single YAMLObject subtype is not bound to a single Loader type.

For example when loading using this line:

yaml.load( stream, Loader=yaml.SafeLoader )

I am required to define a YAMLObject like this:

class YamlTest ( YAMLObject ):
    yaml_tag = '!Test'
    yaml_loader = yaml.SafeLoader

The metaclass should store the constructor and representer references somewhere outside of the Loader and Dumper class objects so defined types work universally.

Attachments

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from xi. Next status will be 'new'
The owner will be changed from xi to anonymous. Next status will be 'assigned'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.