devops.files.files
Module for file operations in mstd checks.
Functions
|
Determine the file type based on the filename extension. |
|
Check if a file exists at the given path. |
|
Filter and return only C++ related files from the given list. |
|
Get all directories in the specified directory. |
|
Get all files in the specified directories. |
Get the list of staged files in the git repository. |
|
|
Read the content of a file. |
|
Write text content to a file. |
Classes
|
Enumeration of file types for mstd checks. |
Exceptions
|
Exception raised when a specified file is not found. |
- exception devops.files.files.DevOpsFileNotFoundError(filepath, message=None)[source]
Bases:
ExceptionException raised when a specified file is not found.
- Parameters:
filepath (Path)
message (str | None)
- Return type:
None
- class devops.files.files.FileType(*values)[source]
Bases:
EnumEnumeration of file types for mstd checks.
- UNKNOWN = 0
- CPPHeader = 1
- CPPSource = 2
- CMakeLists = 3
- devops.files.files.determine_file_type(filename)[source]
Determine the file type based on the filename extension.
- devops.files.files.get_files_in_dirs(paths, exclude_dirs=None, exclude_files=None, max_recursion=20)[source]
Get all files in the specified directories.
- Parameters:
paths (Iterable[Path]) – List of directory paths to search for files.
exclude_dirs (list[str] | None) – List of directory names to exclude from the search. Defaults to None.
exclude_files (list[str] | None) – List of file names to exclude from the search. Defaults to None.
max_recursion (int) – Number of maximum recursion through dirs to avoid infinite recursion, default 20
- Returns:
list[Path] – List of file paths found in the specified directories.
- Return type:
list[Path]
- devops.files.files.get_dirs_in_dir(directory='.')[source]
Get all directories in the specified directory.
- devops.files.files.get_staged_files()[source]
Get the list of staged files in the git repository.
- Returns:
list[Path] – List of staged file paths.
- Raises:
subprocess.CalledProcessError – If the git command fails.
- Return type:
- devops.files.files.file_exist(file, *, throwing=False, throw_msg=None)[source]
Check if a file exists at the given path.
- Parameters:
- Returns:
bool – True if the file exists, False otherwise.
- Raises:
DevOpsFileNotFoundError – If the file does not exist and throwing is True.
- Return type: