import json


SKILL_TREE = {}


class SkillTreeNode(object):
    def __init__(self, attr, parent):
        self._attr = attr
        self._parent = parent

    @property
    def attr(self):
        return self._attr

    @property
    def parent_name(self):
        return self._parent

    @property
    def parent(self):
        if self._parent is None:
            return None
        else:
            return SKILL_TREE[self._parent]

    def __repr__(self):
        parent = self.parent
        if parent is None:
            return "{cls}({attr})".format(
                    cls=self.__class__.__name__,
                    attr=self.attr)
        else:
            return "{cls}({attr}, {parentname}:{parentnode})".format(
                    cls=self.__class__.__name__,
                    attr=self.attr,
                    parentname=self.parent_name,
                    parentnode=parent)


def _build_skill_tree():
    with open('data/skills.json') as fh:
        data = json.load(fh)

    for skill in data:
        SKILL_TREE[skill] = SkillTreeNode(**data[skill])
_build_skill_tree()


def get(skill):
    return SKILL_TREE[skill]



@@ -7,16 +7,17 @@
  json%0A%0A%0A
+_
 SKILL_TR
@@ -77,16 +77,27 @@
 __(self,
+ name, key,
  attr, p
@@ -100,24 +100,74 @@
 r, parent):%0A
+        self._name = name%0A        self._key = key%0A
         self
@@ -233,20 +233,20 @@
     def 
-attr
+name
 (self):%0A
@@ -266,20 +266,79 @@
 n self._
-attr
+name%0A%0A    @property%0A    def key(self):%0A        return self._key
 %0A%0A    @p
@@ -353,27 +353,20 @@
     def 
-parent_name
+attr
 (self):%0A
@@ -386,22 +386,20 @@
 n self._
-parent
+attr
 %0A%0A    @p
@@ -510,32 +510,33 @@
          return 
+_
 SKILL_TREE%5Bself.
@@ -573,68 +573,8 @@
 f):%0A
-        parent = self.parent%0A        if parent is None:%0A    
     
@@ -592,20 +592,21 @@
 %22%7Bcls%7D(%7B
-attr
+skill
 %7D)%22.form
@@ -601,36 +601,32 @@
 kill%7D)%22.format(%0A
-    
                 
@@ -674,32 +674,152 @@
     
-    attr=self.attr)%0A    
+skill=self.name)%0A%0A%0Adef _make_key(parent, child):%0A    child = child.lower().replace(' ', '_')%0A    if parent:%0A        return parent + '.' + child%0A
     
@@ -836,123 +836,251 @@
     
-    
 return 
-%22%7Bcls%7D(%7Battr%7D
+child%0A%0Adef _process_skill_list(skills
 , 
-%7B
 parent
-name%7D:%7Bparentnode%7D)%22.format(%0A                    cls=self.__class__.__
+_key=None):%0A    for skill in skills:%0A        key = _make_key(parent_key, skill%5B'name'%5D)%0A        _SKILL_TREE%5Bkey%5D = SkillTreeNode(%0A                name=skill%5B'
 name
-__
+'%5D
 ,%0A    
+            key=key,%0A
     
@@ -1101,16 +1101,20 @@
 tr=s
-elf.
+kill%5B'
 attr
+'%5D
 ,%0A  
@@ -1131,80 +1131,82 @@
     
-    
 parent
-name=self.parent_name,%0A                    parentnode=parent)%0A
+=parent_key)%0A        _process_skill_list(skill%5B'child_skills'%5D, key)
 %0A%0Ade
@@ -1307,82 +1307,32 @@
     
-for skill in data:%0A        SKILL_TREE%5Bskill%5D = SkillTreeNode(**data%5Bskill%5D
+_process_skill_list(data
 )%0A_b
@@ -1378,16 +1378,17 @@
  return 
+_
 SKILL_TR

Rework skill_tree for new JSON structure