Skip to content

Commit

Permalink
feat: add find_yaml_config_file function
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-RA-King committed Aug 27, 2022
1 parent 5ffd98b commit d4a0500
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/piptools_sync/piptools_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,26 @@ def generate_file() -> dict:
print(end - start)

return mapping


def find_yaml_config_file() -> Path:
"""Find the '.pre-commit-config.yaml' config file in the project directory.
Returns:
pc_file : Path
Path object for the configuration file.
Raise
FileNotFoundError :
If the config file cannot be found.
"""

logger.debug("starting **** find_yaml_config_file ****")
file_list_text = list(ROOT_DIR.iterdir())
file_list_path = [Path(i) for i in file_list_text]
for filepath in file_list_path:
if filepath.name == PRECOMMIT_CONFIG_FILE:
pc_file = filepath
logger.debug(f"found file: {pc_file}")
return pc_file
raise FileNotFoundError(f"Cannot locate '{PRECOMMIT_CONFIG_FILE}'")

0 comments on commit d4a0500

Please sign in to comment.