Browse Source

Merge "Make UnsafeTag self registering"

changes/28/636728/3
Zuul 2 years ago
committed by Gerrit Code Review
parent
commit
29bdc54278
1 changed files with 2 additions and 7 deletions
  1. +2
    -7
      zuul/lib/yamlutil.py

+ 2
- 7
zuul/lib/yamlutil.py View File

@ -27,6 +27,8 @@ except ImportError:
class UnsafeTag(yaml.YAMLObject):
yaml_tag = u'!unsafe'
yaml_dumper = yaml.SafeDumper
yaml_loader = yaml.SafeLoader
def __init__(self, unsafe_var):
self.unsafe_var = unsafe_var
@ -43,13 +45,6 @@ class UnsafeTag(yaml.YAMLObject):
return self.unsafe_var
# Just calling SafeLoader and SafeDumper without yaml module prefix
# does not work and cyaml is using yaml.SafeConstructor yaml.SafeRepresenter
# underneath so this just fine for both
yaml.SafeLoader.add_constructor(UnsafeTag.yaml_tag, UnsafeTag.from_yaml)
yaml.SafeDumper.add_multi_representer(UnsafeTag, UnsafeTag.to_yaml)
def safe_load(stream, *args, **kwargs):
return yaml.load(stream, *args, Loader=SafeLoader, **kwargs)


Loading…
Cancel
Save