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