<commit_before>"""Kraken - objects.scene_item module.

Classes:
SceneItem - Base SceneItem Object.

"""

from kraken.core.maths.xfo import Xfo
from kraken.core.objects.attributes.attribute_group import AttributeGroup


class SceneItem(object):
    """Kraken base object type for any 3D object."""

    __kType__ = "SceneItem"

    def __init__(self, name, parent=None):
        super(SceneItem, self).__init__()
        self.name = name
        self.parent = None
        self.component = None
        self.children = []
        self.flags = {}
        self.attributeGroups = []
        self.constraints = []
        self.xfo = Xfo()
        self.color = None
        self.visibility = True
        self.shapeVisibility = True

        if parent is not None:
            parent.addChild(self)

        defaultAttrGroup = AttributeGroup("")
        self.addAttributeGroup(defaultAttrGroup)


    # =============
    # Name methods
    # =============
    def getName(self):
        """Returns the name of the object as a string.

        Return:
        String of the object's name.

        """

        return self.name


    def getFullName(self):
        """Returns the full hierarchical path to this object.

        Return:
        String, full name of the object.

        """

        if self.parent is not None:
            return self.parent.getFullName() + '.' + self.getName()

        return self.getName()


    # ===============
    # Parent Methods
    # ===============
    def getParent(self):
        """Returns the parent of the object as an object.

        Return:
        Parent of this object.

        """

        return self.parent


    def setParent(self, parent):
        """Sets the parent attribute of this object.

        Arguments:
        parent -- Object, object that is the parent of this one.

        Return:
        True if successful.

        """

        self.parent = parent

        return True


    # ==================
    # Hierarchy Methods
    # ==================
    def getContainer(self):
        """Returns the Container the object belongs to.

        Return:
        Object, Container.

        """

        parent = self.getParent()
        while (parent.getKType() != 'Container' and parent is not None):
            parent = parent.getParent()

        return parent


    def getLayer(self):
        """Returns the Layer the object belongs to.

        Return:
        Object, Layer this object belongs to.

        """

        parent = self.getParent()
        while (parent.getKType() != 'Layer' and parent is not None):
            parent = parent.getParent()
<commit_msg>fixed backwards check in while loops.<commit_after>"""Kraken - objects.scene_item module.

Classes:
SceneItem - Base SceneItem Object.

"""

from kraken.core.maths.xfo import Xfo
from kraken.core.objects.attributes.attribute_group import AttributeGroup


class SceneItem(object):
    """Kraken base object type for any 3D object."""

    __kType__ = "SceneItem"

    def __init__(self, name, parent=None):
        super(SceneItem, self).__init__()
        self.name = name
        self.parent = None
        self.component = None
        self.children = []
        self.flags = {}
        self.attributeGroups = []
        self.constraints = []
        self.xfo = Xfo()
        self.color = None
        self.visibility = True
        self.shapeVisibility = True

        if parent is not None:
            parent.addChild(self)

        defaultAttrGroup = AttributeGroup("")
        self.addAttributeGroup(defaultAttrGroup)


    # =============
    # Name methods
    # =============
    def getName(self):
        """Returns the name of the object as a string.

        Return:
        String of the object's name.

        """

        return self.name


    def getFullName(self):
        """Returns the full hierarchical path to this object.

        Return:
        String, full name of the object.

        """

        if self.parent is not None:
            return self.parent.getFullName() + '.' + self.getName()

        return self.getName()


    # ===============
    # Parent Methods
    # ===============
    def getParent(self):
        """Returns the parent of the object as an object.

        Return:
        Parent of this object.

        """

        return self.parent


    def setParent(self, parent):
        """Sets the parent attribute of this object.

        Arguments:
        parent -- Object, object that is the parent of this one.

        Return:
        True if successful.

        """

        self.parent = parent

        return True


    # ==================
    # Hierarchy Methods
    # ==================
    def getContainer(self):
        """Returns the Container the object belongs to.

        Return:
        Object, Container.

        """

        parent = self.getParent()
        while (parent is not None and parent.getKType() != 'Container'):
            parent = parent.getParent()

        return parent


    def getLayer(self):
        """Returns the Layer the object belongs to.

        Return:
        Object, Layer this object belongs to.

        """

        parent = self.getParent()
        while (parent is not None and parent.getKType() != 'Layer'):
            parent = parent.getParent()

{'fraction_non_alphanumeric': 0.12509433962264152, 'fraction_numerical': 0.0003773584905660377, 'mean_word_length': 1.9271120927664274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7360217', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1345, 'n_words': 433}