示例#1
0
文件: blt.py 项目: shanemgrey/BOLTS
class ClassName(Designation):
    """
	Python class to provide a name for a BOLTS class, corresponding to a
	ClassNameElement in the blt file.
	"""

    def __init__(self, cn):
        check_schema(cn, "classname", ["name", "labeling"], ["description", "group"])
        Designation.__init__(self)

        try:
            if isinstance(cn["name"], str):
                self.name = Identifier({"nice": cn["name"]})
            else:
                self.name = Identifier(cn["name"])
            if isinstance(cn["labeling"], str):
                self.labeling = Substitution({"nice": cn["labeling"]})
            else:
                self.labeling = Substitution(cn["labeling"])
        except ParsingError as e:
            e.set_class(self.id)
            raise e

        self.description = cn.get("description", "")

        if "group" in cn:
            if isinstance(cn["group"], str):
                self.group = Identifier({"nice": cn["group"]})
            else:
                self.group = Identifier(cn["group"])
        else:
            self.group = Identifier({"nice": ""})

    def get_id(self):
        return self.name.get_safe()
示例#2
0
class ClassName(Designation):
    """
	Python class to provide a name for a BOLTS class, corresponding to a
	ClassNameElement in the blt file.
	"""
    def __init__(self, cn):
        check_schema(cn, "classname", ["name", "labeling"],
                     ["description", "group"])
        Designation.__init__(self)

        try:
            if isinstance(cn['name'], str):
                self.name = Identifier({'nice': cn['name']})
            else:
                self.name = Identifier(cn['name'])
            if isinstance(cn['labeling'], str):
                self.labeling = Substitution({'nice': cn['labeling']})
            else:
                self.labeling = Substitution(cn['labeling'])
        except ParsingError as e:
            e.set_class(self.id)
            raise e

        self.description = cn.get('description', '')

        if 'group' in cn:
            if isinstance(cn['group'], str):
                self.group = Identifier({'nice': cn['group']})
            else:
                self.group = Identifier(cn['group'])
        else:
            self.group = Identifier({'nice': ""})

    def get_id(self):
        return self.name.get_safe()
示例#3
0
文件: blt.py 项目: shanemgrey/BOLTS
class ClassStandard(Designation):
    """
	Python class to provide a standard name for a BOLTS class, corresponding to a
	ClassStandardElement in the blt file.
	"""

    def __init__(self, sn):
        check_schema(
            sn,
            "classstandard",
            ["standard", "labeling", "body"],
            ["group", "year", "status", "replaces", "description"],
        )
        Designation.__init__(self)

        if isinstance(sn["standard"], str):
            self.standard = Identifier({"nice": sn["standard"]})
        else:
            self.standard = Identifier(sn["standard"])
        if "group" in sn:
            if isinstance(sn["group"], str):
                self.group = Identifier({"nice": sn["group"]})
            else:
                self.group = Identifier(sn["group"])
        else:
            self.group = Identifier({"nice": ""})
        if isinstance(sn["labeling"], str):
            self.labeling = Substitution({"nice": sn["labeling"]})
        else:
            self.labeling = Substitution(sn["labeling"])

        self.body = sn["body"]
        self.year = sn.get("year", None)
        self.status = sn.get("status", "active")

        self.replacedby = None

        self.replaces = sn.get("replaces", None)
        self.description = sn.get("description", "")

    def get_id(self):
        return self.standard.get_safe()
示例#4
0
class ClassStandard(Designation):
    """
	Python class to provide a standard name for a BOLTS class, corresponding to a
	ClassStandardElement in the blt file.
	"""
    def __init__(self, sn):
        check_schema(sn, 'classstandard', ['standard', 'labeling', 'body'],
                     ['group', 'year', 'status', 'replaces', 'description'])
        Designation.__init__(self)

        if isinstance(sn['standard'], str):
            self.standard = Identifier({'nice': sn['standard']})
        else:
            self.standard = Identifier(sn['standard'])
        if 'group' in sn:
            if isinstance(sn['group'], str):
                self.group = Identifier({'nice': sn['group']})
            else:
                self.group = Identifier(sn['group'])
        else:
            self.group = Identifier({'nice': ""})
        if isinstance(sn['labeling'], str):
            self.labeling = Substitution({'nice': sn['labeling']})
        else:
            self.labeling = Substitution(sn['labeling'])

        self.body = sn['body']
        self.year = sn.get('year', None)
        self.status = sn.get('status', 'active')

        self.replacedby = None

        self.replaces = sn.get('replaces', None)
        self.description = sn.get('description', '')

    def get_id(self):
        return self.standard.get_safe()