Ejemplo n.º 1
0
    def _createEnumerationFields(self, pyutClass: PyutClass,
                                 enumValues: List[str]):
        """
        TODO:  Create a PyutEnumeration at some point
        For now simulate with a bunch of fields in a class that is `Stereotyped` as
        Enumeration

        """
        pyutClass.setStereotype(stereotype=XSDParser.ENUMERATION_STEREOTYPE)
        pyutClass.setShowStereotype(theNewValue=True)

        for val in enumValues:
            pyutField: PyutField = PyutField(
                name=val.upper(),
                defaultValue=val,
                visibility=PyutVisibilityEnum.PUBLIC)
            pyutClass.addField(pyutField)
Ejemplo n.º 2
0
    def _addFields(self, pyutClass: PyutClass) -> PyutClass:
        """
        Can look like this:

           fieldData: x:int=0
           fieldData = 0

        Args:
            pyutClass:  Where to add the fields

        Returns:  The updated input class

        """
        for fieldData in self.visitor.fields:
            self.logger.debug(f'fieldData: {fieldData}')
            pyutField: PyutField = self._parseFieldToPyut(fieldData)
            pyutClass.addField(pyutField)

        return pyutClass
Ejemplo n.º 3
0
    def _createDataClassPropertiesAsFields(
            self, pyutClass: PyutClass,
            dataClassProperties: DataClassProperties) -> PyutClass:
        """

        Args:
            pyutClass:  The PyutClass to update
            dataClassProperties:    The dataclass properties to parse

        Returns:
            Updated PyutClass with new fields
        """
        className: str = pyutClass.name
        for dPropertyTuple in dataClassProperties:
            if dPropertyTuple[0] == className:

                pyutField: PyutField = self._parseFieldToPyut(
                    fieldData=dPropertyTuple[1])
                pyutClass.addField(pyutField)

        return pyutClass