@classmethoddef_rename_path_segment(cls,obj_adapter,object,path_segment):# Check if the object is a list - lists will just have an index as a# value, ands this can't be renamedifissubclass(obj_adapter.ADAPTER_OBJECT,objects.ListObjectMixin):obj_adapter=cls.get_object_adapter(cls.ADAPTER_FORMAT,obj_adapter.ADAPTER_OBJECT.LIST_ITEM_TYPE.obj_name())# Return the segment as is, and the next adapter (which is the# LIST_ITEM_TYPE)returnpath_segment,obj_adapterforkey,valueinobj_adapter.MODIFICATIONS.get('fields',{}).items():# Check if this field as actually a nested objectifobject.FIELDS.get(path_segment,{}).get('relation',False):obj_cls=object.FIELDS.get(path_segment).get('relation_cls')obj_adapter=cls.get_object_adapter(cls.ADAPTER_FORMAT,obj_cls)object=objects.DesignateObject.obj_cls_from_name(obj_cls)()# Recurse down into this objectpath_segment,obj_adapter=cls._rename_path_segment(obj_adapter,object,path_segment)# No need to continue the loopbreakifnotisinstance(value.get('rename',NotSpecifiedSential()),NotSpecifiedSential)\
andpath_segment==value.get('rename'):# Just do the renamepath_segment=keyreturnpath_segment,obj_adapter