core
Core somesy functions.
INPUT_FILES_ORDERED
module-attribute
¶
INPUT_FILES_ORDERED = [
".somesy.toml",
"somesy.toml",
"pyproject.toml",
"package.json",
"Project.toml",
"fpm.toml",
"Cargo.toml",
]
Input files ordered by priority for discovery.
discover_input ¶
discover_input(input_file: Optional[Path] = None) -> Path
Check given input file path. If not given, find somesy configuration file path from default list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_file |
Optional[Path]
|
somesy configuration file path. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
Raised if no somesy input file found from cli input or the defaults. |
Returns:
Type | Description |
---|---|
Path
|
somesy configuration file path. |
Source code in src/somesy/core/core.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
get_input_content ¶
get_input_content(
path: Path, *, no_unwrap: bool = False
) -> Dict[str, Any]
Read contents of a supported somesy input file.
Given a path to a TOML file, this function reads the file and returns its content as a TOMLDocument object. The function checks if the file is a valid somesy input file by checking its name and content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Path
|
path to the input file |
required |
no_unwrap |
bool
|
if True, the function returns the TOMLDocument object instead of unwrapping it |
False
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
the content of the input file as a TOMLDocument object |
Raises:
Type | Description |
---|---|
ValueError
|
if the input file is not a valid somesy input file or if the file is not a TOML file. |
RuntimeError
|
if the input file does not contain a somesy input section at expected key |
Source code in src/somesy/core/core.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|