@@ -34,6 +34,24 @@ def migrate(self, manifest: ManifestType) -> None:
3434 :param kwargs: Additional arguments for migration
3535 """
3636
37+ def _is_component (self , obj : Dict [str , Any ]) -> bool :
38+ """
39+ Check if the object is a component.
40+
41+ :param obj: The object to check
42+ :return: True if the object is a component, False otherwise
43+ """
44+ return TYPE_TAG in obj .keys ()
45+
46+ def _is_migratable (self , obj : Dict [str , Any ]) -> bool :
47+ """
48+ Check if the object is a migratable component.
49+
50+ :param obj: The object to check
51+ :return: True if the object is a migratable component, False otherwise
52+ """
53+ return obj [TYPE_TAG ] not in NON_MIGRATABLE_TYPES
54+
3755 def _process_manifest (self , obj : Any ) -> None :
3856 """
3957 Recursively processes a manifest object, migrating components that match the migration criteria.
@@ -54,21 +72,21 @@ def _process_manifest(self, obj: Any) -> None:
5472 None, since we process the manifest in place.
5573 """
5674 if isinstance (obj , dict ):
57- obj_keys = obj .keys ()
58- # check for component type match the designed migration
59- if TYPE_TAG in obj_keys :
60- obj_type = obj [TYPE_TAG ]
61-
62- # do not migrate if the particular type is in the list of non-migratable types
63- if obj_type in NON_MIGRATABLE_TYPES :
75+ # Check if the object is a component
76+ if self ._is_component (obj ):
77+ # Check if the object is allowed to be migrated
78+ if not self ._is_migratable (obj ):
6479 return
6580
81+ # Check if the object should be migrated
6682 if self .should_migrate (obj ):
83+ # Perform the migration, if needed
6784 self .migrate (obj )
6885
6986 # Process all values in the dictionary
70- for v in list (obj .values ()):
71- self ._process_manifest (v )
87+ for value in list (obj .values ()):
88+ self ._process_manifest (value )
89+
7290 elif isinstance (obj , list ):
7391 # Process all items in the list
7492 for item in obj :
0 commit comments