mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-31 07:04:17 +00:00 
			
		
		
		
	utils/serializer: Handle empty file extensions
The ValueError does not given enough information in the case of an empty file extension. Add a special case to handle files with no extension and prompt the user.
This commit is contained in:
		
				
					committed by
					
						 setrofim
						setrofim
					
				
			
			
				
	
			
			
			
						parent
						
							88731fe489
						
					
				
				
					commit
					578d2d3a16
				
			| @@ -299,6 +299,12 @@ def load(s, fmt='json', *args, **kwargs): | |||||||
| def _read_pod(fh, fmt=None): | def _read_pod(fh, fmt=None): | ||||||
|     if fmt is None: |     if fmt is None: | ||||||
|         fmt = os.path.splitext(fh.name)[1].lower().strip('.') |         fmt = os.path.splitext(fh.name)[1].lower().strip('.') | ||||||
|  |         if fmt == '': | ||||||
|  |             # Special case of no given file extension | ||||||
|  |             message = ("Could not determine format " + | ||||||
|  |             "from file extension for \"{}\". ".format(getattr(fh, 'name', '<none>')) + | ||||||
|  |             "Please specify it or modify the fmt parameter.") | ||||||
|  |             raise ValueError(message) | ||||||
|     if fmt == 'yaml': |     if fmt == 'yaml': | ||||||
|         return yaml.load(fh) |         return yaml.load(fh) | ||||||
|     elif fmt == 'json': |     elif fmt == 'json': | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user