Commit b8b1df43 authored by Benjamin Winger's avatar Benjamin Winger

Added explicit constructors for YaML tags

parent 0d07a6fe
......@@ -34,15 +34,9 @@ if __name__ == "__main__":
import traceback
import portmod.globals
import glob
from portmod.yaml import yaml_load
from portmod.yaml import yaml_load, Person, Group
from portmod.main import pybuild_validate, pybuild_manifest
from portmod.repo.metadata import (
get_categories,
get_repo_root,
license_exists,
Person,
Group,
)
from portmod.repo.metadata import get_categories, get_repo_root, license_exists
from portmod.log import err
from portmod.repo.list import read_list
......
......@@ -5,7 +5,6 @@
# Arguments are either a repo path, or mod object.
import os
import yaml
from portmod.yaml import yaml_load
from portmod.globals import ACCEPT_LICENSE
from portmod.repo.list import read_list
......@@ -13,31 +12,6 @@ from portmod.repos import REPOS
from portmod.log import err
class Person(yaml.YAMLObject):
yaml_tag = "!person"
def __init__(self, email, desc=""):
self.email = email
self.desc = desc
def __repr__(self):
return "%s(email=%r, desc=%r)" % (
self.__class__.__name__,
self.email,
self.desc,
)
class Group(yaml.YAMLObject):
yaml_tag = "!group"
def __init__(self, name):
self.name = name
def __repr__(self):
return "%s(name=%r)" % (self.__class__.__name__, self.name)
def get_masters(repo_path):
masters = []
for repo in REPOS:
......
......@@ -6,6 +6,39 @@
import yaml
class Person(yaml.YAMLObject):
yaml_tag = "!person"
def __init__(self, email, desc=""):
self.email = email
self.desc = desc
def __repr__(self):
return "%s(email=%r, desc=%r)" % (
self.__class__.__name__,
self.email,
self.desc,
)
class Group(yaml.YAMLObject):
yaml_tag = "!group"
def __init__(self, name):
self.name = name
def __repr__(self):
return "%s(name=%r)" % (self.__class__.__name__, self.name)
try:
yaml.add_constructor("!person", Person, Loader=yaml.FullLoader)
yaml.add_constructor("!group", Group, Loader=yaml.FullLoader)
except AttributeError:
yaml.add_constructor("!person", Person)
yaml.add_constructor("!group", Group)
# Attempt to use the safer yaml.full_load, but fall back to unsafe load
# to avoid breaking compatibility
def yaml_load(file):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment