File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -772,6 +772,33 @@ def get_terminology_equivalent(self):
772772 except KeyError :
773773 return None
774774
775+ def _reorder (self , childlist , new_index ):
776+ print (childlist , new_index )
777+ lst = childlist
778+ old_index = lst .index (self )
779+
780+ # 2 cases: insert after old_index / insert before
781+ if new_index > old_index :
782+ new_index += 1
783+ lst .insert (new_index , self )
784+ if new_index < old_index :
785+ del lst [old_index + 1 ]
786+ else :
787+ del lst [old_index ]
788+ return old_index
789+
790+ def reorder (self , new_index ):
791+ """
792+ Move this object in its parent child-list to the position *new_index*.
793+
794+ :return: The old index at which the object was found.
795+ """
796+ if not self .parent :
797+ raise ValueError ("odml.Property.reorder: "
798+ "Property has no parent, cannot reorder in parent list." )
799+
800+ return self ._reorder (self .parent .properties , new_index )
801+
775802 def extend (self , obj , strict = True ):
776803 """
777804 Extend the list of values stored in this property by the passed values. Method
You can’t perform that action at this time.
0 commit comments