mirror of
				https://github.com/smyalygames/FiniteVolumeGPU.git
				synced 2025-10-31 20:17:41 +01:00 
			
		
		
		
	fix(common): import type for function in util
This commit is contained in:
		
							parent
							
								
									0d9d47136d
								
							
						
					
					
						commit
						320daff96d
					
				| @ -1,9 +1,9 @@ | ||||
| from pathlib import Path | ||||
| 
 | ||||
| def get_project_root() -> Path: | ||||
|     """ | ||||
|     Gets the root directory of the project. | ||||
|     """ | ||||
|     from pathlib import Path | ||||
| 
 | ||||
|     return Path(__file__).parent.parent.parent | ||||
| 
 | ||||
| 
 | ||||
| @ -26,3 +26,24 @@ def get_includes(file: str, local: bool = False) -> list[str]: | ||||
|         pattern = '^\\W*#include\\s+"(.+?)"\\W*$' | ||||
| 
 | ||||
|     return re.findall(pattern, file, re.M) | ||||
| 
 | ||||
| def unique_file(filename: str) -> str: | ||||
|     """ | ||||
|     Finds a unique name for a filename. Will append a padded 4-digit number to the | ||||
|     tail of the stem of the file name. | ||||
| 
 | ||||
|     Args: | ||||
|         filename: The filename to find a unique name. | ||||
| 
 | ||||
|     Returns: | ||||
|         A unique filename. | ||||
|     """ | ||||
|     import os | ||||
| 
 | ||||
|     i = 0 | ||||
|     stem, ext = os.path.splitext(filename) | ||||
|     while os.path.isfile(filename): | ||||
|         filename = f"{stem}_{str(i).zfill(4)}{ext}" | ||||
|         i = i + 1 | ||||
| 
 | ||||
|     return filename | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Anthony Berg
						Anthony Berg