"""
The MIT License (MIT)

Copyright (c) 2016 Zuse Institute Berlin, www.zib.de

Permissions are granted as stated in the license file you have obtained
with this software. If you find the library useful for your purpose,
please refer to README.md for how to cite IPET.

@author: Gregor Hendel
"""
from ipet.concepts.Editable import Editable, EditableAttributeError

class IpetNode(Editable):
    """
    A Node is an interface to an XML-like ancestor-structure
    """
    active = True
    _attributes2options = {"active":[True, False]}
    
    def __init__(self, active=True):
        """
        constructs a new IpetNode

        Parameters
        ----------
        active : True or "True" if this element should be active, False otherwise
        """
        self.set_active(active)

    def addChild(self, child):
        """
        append a child to this node's children
        """
        pass
    
    def getChildren(self):
        """
        return a list of all children of this node
        """
        return None
    
    def acceptsAsChild(self, child):
        """
        returns whether this node accepts node 'child' as child
        """
        return False
    
    def removeChild(self, child):
        """
        remove the child from this node's children.
        """
        pass
    
    def isActive(self):
        """
        returns True if this node is currently active, False otherwise
        """
        return self.active
    
    def set_active(self, active):
        self.active = True if active in [True, "True"] else False

    def getEditableAttributes(self):
        """
        returns all editable attributes
        """
        return ["active"]

    def getRequiredOptionsByAttribute(self, attr):
        return self._attributes2options.get(attr)

    @staticmethod
    def getNodeTag():
        return "Node"

class IpetNodeAttributeError(EditableAttributeError):
    """
    subclass to allow for richer EditableAttributeErrors
    """

    def __init__(self, *args):
        """
        constructs an IpetNodeAttributeError
        """
        super(IpetNodeAttributeError, self).__init__(*args)


        

@@ -359,16 +359,30 @@
 teError%0A
+import logging
 %0Aclass I
@@ -546,16 +546,43 @@
 False%5D%7D%0A
+    deprecatedattrdir = %7B%7D%0A
     %0A   
@@ -611,13 +611,21 @@
 tive
-=
+ = 
 True
+, **kw
 ):%0A 
@@ -835,16 +835,221 @@
 ctive)%0A%0A
+        for d, message in self.deprecatedattrdir.items():%0A            if d in kw:%0A                logging.warn(%22Warning : The attribute '%7B0%7D' is deprecated and will be ignored; %7B1%7D. %22.format(d, message))%0A%0A
     def 

enable deprecated warnings for ipet node attributes