Coverage for src/configuraptor/helpers.py: 100%
7 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-21 10:22 +0200
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-21 10:22 +0200
1"""
2Contains stand-alone helper functions.
3"""
5import typing
6import os
7import black.files
10def camel_to_snake(s: str) -> str:
11 """
12 Convert CamelCase to snake_case.
14 Source:
15 https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case
16 """
17 return "".join([f"_{c.lower()}" if c.isupper() else c for c in s]).lstrip("_")
20def find_pyproject_toml() -> typing.Optional[str]:
21 """
22 Find the project's config toml, looks up until it finds the project root (black's logic).
23 """
24 return black.files.find_pyproject_toml((os.getcwd(),))