mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-11-04 09:02:12 +00:00 
			
		
		
		
	utils/misc: Replace deprecated __import__ by importlib
Use importlib.import_module instead of __import__ as per Python doc recommendation. This will also fix the case where the class is in a package's submodule (since __import__ returns the top-level package), e.g. "foo.bar.Class".
This commit is contained in:
		
				
					committed by
					
						
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							77ebefba08
						
					
				
				
					commit
					28b78a93f1
				
			@@ -236,7 +236,12 @@ def load_class(classpath):
 | 
			
		||||
    """Loads the specified Python class. ``classpath`` must be a fully-qualified
 | 
			
		||||
    class name (i.e. namspaced under module/package)."""
 | 
			
		||||
    modname, clsname = classpath.rsplit('.', 1)
 | 
			
		||||
    return getattr(__import__(modname), clsname)
 | 
			
		||||
    mod = importlib.import_module(modname)
 | 
			
		||||
    cls = getattr(mod, clsname)
 | 
			
		||||
    if isinstance(cls, type):
 | 
			
		||||
        return cls
 | 
			
		||||
    else:
 | 
			
		||||
        raise ValueError(f'The classpath "{classpath}" does not point at a class: {cls}')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_pager():
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user