Exemple #1
0
    def __init__(self, namespace_name, entity_soup):
        self.name = Commons.parse_type_name(entity_soup[NAME], namespace_name)
        try:
            self.base_type = Commons.parse_type_name(entity_soup[BASE_TYPE],
                                                     namespace_name)
        except KeyError:
            # does not have base type (item?)
            self.base_type = None
        self.abstract = entity_soup.get(ABSTRACT, False)
        self.annotation = [
            Annotation(annotation_soup)
            for annotation_soup in entity_soup.find_all(ANNOTATION,
                                                        recursive=False)
        ]
        self.properties = [
            Property(namespace_name, property_soup)
            for property_soup in entity_soup.find_all(PROPERTY,
                                                      recursive=False)
        ]
        self.navigation_properties = [
            NavigationProperty(namespace_name, navigation_property_soup)
            for navigation_property_soup in entity_soup.find_all(
                NAVIGATION_PROPERTY, recursive=False)
        ]

        self.additional_items = True
        self.set_additional_items()
Exemple #2
0
 def __init__(self, namespace_name, entity_soup):
     self.name = Commons.parse_type_name(entity_soup[NAME], namespace_name)
     try:
         self.base_type = Commons.parse_type_name(entity_soup[BASE_TYPE], namespace_name)
     except KeyError:
         # does not have base type (item?)
         self.base_type = None
     self.abstract = entity_soup.get(ABSTRACT, False)
     self.annotation = [Annotation(annotation_soup) for annotation_soup in
                         entity_soup.find_all(ANNOTATION, recursive=False)]
     self.properties = [Property(namespace_name, property_soup) for property_soup in
                        entity_soup.find_all(PROPERTY, recursive=False)]
     self.navigation_properties = [NavigationProperty(namespace_name, navigation_property_soup) for
                                   navigation_property_soup in
                                   entity_soup.find_all(NAVIGATION_PROPERTY, recursive=False)]
Exemple #3
0
    def __init__(self, metadata_container, namespace_name, type_soup, qualifiers=None):
        """
        :type metadata_container: cts_core.metadata.metadata_container.MetadataContainer
        :type namespace_name: str
        :type type_soup: bs4.element.Tag
        """
        MetadataType.__init__(self, metadata_container, namespace_name, type_soup, qualifiers)

        self.type_category = MetadataTypeCategories.TYPE_DEFINITION

        self.base_type = Commons.parse_type_name(type_soup[UNDERLYING_TYPE], namespace_name)
Exemple #4
0
    def __init__(self, metadata_container, namespace_name, type_soup, qualifiers=None):
        """
        :type metadata_container: cts_core.metadata.metadata_container.MetadataContainer
        :type namespace_name: str
        :type type_soup: bs4.element.Tag
        """
        MetadataModel.__init__(self, metadata_container, type_soup, qualifiers)

        self.name = Commons.parse_type_name(type_soup[NAME], namespace_name)
        self.type_category = None
        self.base_type = None
Exemple #5
0
    def __init__(self, namespace_name, action_soup):
        self.name = Commons.parse_type_name(action_soup["name"], namespace_name)
        try:
            self.is_bound = action_soup[IS_BOUND] == "true"
        except KeyError:
            self.is_bound = False

        self.properties = [Property(namespace_name, property_soup) for property_soup in
                           action_soup.find_all(PROPERTY, recursive=False)]

        self.annotation = [Annotation(annotation_soup) for annotation_soup in
                            action_soup.find_all(ANNOTATION, recursive=False)]
Exemple #6
0
    def __init__(self,
                 metadata_container,
                 namespace_name,
                 entity_soup,
                 qualifiers=None):
        """
        :type metadata_container: cts_core.metadata.metadata_container.MetadataContainer
        :type namespace_name: str
        :type entity_soup: bs4.element.Tag
        """
        MetadataModel.__init__(self, metadata_container, entity_soup,
                               qualifiers)

        self.name = Commons.parse_type_name(entity_soup[NAME], namespace_name)
        try:
            self.base_type = Commons.parse_type_name(entity_soup[BASE_TYPE],
                                                     namespace_name)
        except KeyError:
            # does not have base type
            self.base_type = None
        self.abstract = entity_soup.get(ABSTRACT, False)

        properties = [
            Property(self.metadata_container, namespace_name, property_soup,
                     qualifiers)
            for property_soup in entity_soup.find_all(PROPERTY,
                                                      recursive=False)
        ]
        self._properties = {prop.name: prop for prop in properties}

        navigation_properties = [
            NavigationProperty(self.metadata_container, namespace_name,
                               navigation_property_soup, qualifiers)
            for navigation_property_soup in entity_soup.find_all(
                NAVIGATION_PROPERTY, recursive=False)
        ]
        self._navigation_properties = {
            navigation_property.name: navigation_property
            for navigation_property in navigation_properties
        }
Exemple #7
0
    def __init__(self, metadata_container, namespace_name, entity_soup, qualifiers=None):
        """
        :type metadata_container: cts_core.metadata.metadata_container.MetadataContainer
        :type namespace_name: str
        :type entity_soup: bs4.element.Tag
        """
        MetadataModel.__init__(self, metadata_container, entity_soup, qualifiers)

        self.name = Commons.parse_type_name(entity_soup[NAME], namespace_name)
        try:
            self.base_type = Commons.parse_type_name(entity_soup[BASE_TYPE], namespace_name)
        except KeyError:
            # does not have base type
            self.base_type = None
        self.abstract = entity_soup.get(ABSTRACT, False)

        properties = [Property(self.metadata_container, namespace_name, property_soup, qualifiers) for property_soup in
                      entity_soup.find_all(PROPERTY, recursive=False)]
        self._properties = {prop.name: prop for prop in properties}

        navigation_properties = [NavigationProperty(self.metadata_container, namespace_name, navigation_property_soup, qualifiers) for
                                 navigation_property_soup in entity_soup.find_all(NAVIGATION_PROPERTY, recursive=False)]
        self._navigation_properties = {navigation_property.name: navigation_property for navigation_property in
                                       navigation_properties}
Exemple #8
0
    def __init__(self,
                 metadata_container,
                 namespace_name,
                 type_soup,
                 qualifiers=None):
        """
        :type metadata_container: cts_core.metadata.metadata_container.MetadataContainer
        :type namespace_name: str
        :type type_soup: bs4.element.Tag
        """
        MetadataModel.__init__(self, metadata_container, type_soup, qualifiers)

        self.name = Commons.parse_type_name(type_soup[NAME], namespace_name)
        self.type_category = None
        self.base_type = None
    def __init__(self, namespace_name, type_soup):
        Type.__init__(self, namespace_name, type_soup)
        try:
            self.base_type = Commons.parse_type_name(type_soup[BASE_TYPE], namespace_name)
        except KeyError:
            pass

        self.type = ValueTypesCategory.COMPLEX_TYPE
        self.properties = [Property(namespace_name, property_soup) for property_soup in
                           type_soup.find_all(PROPERTY, recursive=False)]
        self.navigation_properties = [NavigationProperty(namespace_name, property_soup) for property_soup in
                                      type_soup.find_all(NAVIGATION_PROPERTY, recursive=False)]

        self.additional_items = True
        self.set_additional_items()
Exemple #10
0
    def __init__(self,
                 metadata_container,
                 namespace_name,
                 type_soup,
                 qualifiers=None):
        """
        :type metadata_container: cts_core.metadata.metadata_container.MetadataContainer
        :type namespace_name: str
        :type type_soup: bs4.element.Tag
        """
        MetadataType.__init__(self, metadata_container, namespace_name,
                              type_soup, qualifiers)

        self.type_category = MetadataTypeCategories.TYPE_DEFINITION

        self.base_type = Commons.parse_type_name(type_soup[UNDERLYING_TYPE],
                                                 namespace_name)
    def __init__(self, namespace_name, property_soup):
        self.name = property_soup[NAME]
        self.type = Commons.parse_type_name(property_soup[TYPE],
                                            namespace_name)
        self.is_collection = self.type.startswith(COLLECTION)
        self.type = self.type[len(COLLECTION
                                  ):-1] if self.is_collection else self.type

        self.annotations = [
            Annotation(annotation)
            for annotation in property_soup.find_all(ANNOTATION,
                                                     recursive=False)
        ]

        self.nullable = property_soup.get(NULLABLE, "true").lower() != "false"
        self.required = bool([
            annotation for annotation in self.annotations
            if annotation.term == "Redfish.Required"
        ])
Exemple #12
0
    def __init__(self,
                 metadata_container,
                 namespace_name,
                 property_soup,
                 qualifiers=None):
        """
        :type metadata_container: cts_core.metadata.metadata_container.MetadataContainer
        :type namespace_name: str
        :type property_soup: bs4.element.Tag
        """
        MetadataModel.__init__(self, metadata_container, property_soup,
                               qualifiers)

        self.name = property_soup[NAME]
        property_type = property_soup[TYPE]
        self.is_collection = property_type.startswith(
            COLLECTION) and property_type.endswith(")")
        property_type = property_type[
            len(COLLECTION):-1] if self.is_collection else property_type
        self.type = Commons.parse_type_name(property_type, namespace_name)
        self.nullable = property_soup.get(NULLABLE, "true").lower() == "true"
Exemple #13
0
 def __init__(self, namespace_name, type_soup):
     self.name = Commons.parse_type_name(type_soup[NAME], namespace_name)
     self.annotations = [Annotation(annotation) for annotation in type_soup.find_all(ANNOTATION, recursive=False)]
     self.type = None
    def __init__(self, namespace_name, type_soup):
        Type.__init__(self, namespace_name, type_soup)

        self.type = ValueTypesCategory.TYPE_DEFINITION
        base_type = type_soup[UNDERLYING_TYPE]
        self.base_type = Commons.parse_type_name(base_type, namespace_name) if base_type else base_type
 def __init__(self, namespace_name, type_soup):
     self.name = Commons.parse_type_name(type_soup[NAME], namespace_name)
     self.annotations = [Annotation(annotation) for annotation in type_soup.find_all(ANNOTATION, recursive=False)]
     self.type = None
Exemple #16
0
 def test_namespace_none(self):
     self.assertEqual(Commons.parse_type_name("a", None), "a")
Exemple #17
0
 def test_namespace_given(self):
     self.assertEqual(Commons.parse_type_name("a", "b"), "b.a")
Exemple #18
0
 def test_namespace_included(self):
     self.assertEqual(Commons.parse_type_name("b.a", "c"), "b.a")
Exemple #19
0
    def __init__(self, namespace_name, type_soup):
        Type.__init__(self, namespace_name, type_soup)

        self.type = ValueTypesCategory.TYPE_DEFINITION
        base_type = type_soup[UNDERLYING_TYPE]
        self.base_type = Commons.parse_type_name(base_type, namespace_name) if base_type else base_type