22from dataikuapi .utils import DataikuException
33import json
44import sys
5+ import copy
56
67if sys .version_info >= (3 ,0 ):
78 import urllib .parse
@@ -132,6 +133,8 @@ def __retrieve_article_in_taxonomy__(self, taxonomy, article_id, remove=False):
132133 :param list taxonomy: the current level of taxonomy
133134 :param str article_id: the article to retrieve
134135 :param bool remove: either remove the sub tree structure or not
136+ :returns: the sub tree structure at a specific article level
137+ :rtype: dict
135138 """
136139 idx = 0
137140 for tax_article in taxonomy :
@@ -151,7 +154,7 @@ def move_article_in_taxonomy(self, article_id, parent_article_id=None):
151154 :param str article_id: the main article ID
152155 :param str parent_article_id: the new parent article ID or None for root level
153156 """
154- old_taxonomy = list (self .settings ["taxonomy" ])
157+ old_taxonomy = copy . deepcopy (self .settings ["taxonomy" ])
155158
156159 tax_article = self .__retrieve_article_in_taxonomy__ (self .settings ["taxonomy" ], article_id , True )
157160 if tax_article is None :
@@ -161,8 +164,8 @@ def move_article_in_taxonomy(self, article_id, parent_article_id=None):
161164 self .settings ["taxonomy" ].append (tax_article )
162165 else :
163166 tax_parent_article = self .__retrieve_article_in_taxonomy__ (self .settings ["taxonomy" ], parent_article_id , False )
164- if tax_article is None :
165- self .settings ["taonomy " ] = old_taxonomy
167+ if tax_parent_article is None :
168+ self .settings ["taxonomy " ] = old_taxonomy
166169 raise DataikuException ("Parent article not found (or is one of the article descendants): %s" % (parent_article_id ))
167170 tax_parent_article ["children" ].append (tax_article )
168171
0 commit comments