utils¶
academic_doc_generator.core.utils
¶
Small utility helpers.
find_latest_tex(folder, pattern='bewertung_brief_*.tex')
¶
Find the most recently modified TeX file in a folder matching a pattern.
This function searches for files in the given folder whose names match
a specified glob pattern (e.g., bewertung_brief_*.tex). If one or more
files match, the function returns the path to the file with the most
recent modification time. If no files match, it returns None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str
|
Path to the folder where TeX files are searched. |
required |
pattern
|
str
|
Glob pattern for matching file names.
Defaults to |
'bewertung_brief_*.tex'
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The absolute path to the newest matching TeX file as a string, |
Optional[str]
|
or |
Raises:
| Type | Description |
|---|---|
None directly, but errors may propagate if
|
|
Example
find_latest_tex("/tmp", "bewertung_brief_*.tex") '/tmp/bewertung_brief_12345.tex'
Notes
- The "newest" file is determined by the last modification time
(
os.path.getmtime). - The function returns an absolute path suitable for further processing, e.g., compilation with LuaLaTeX.
Source code in src/academic_doc_generator/core/utils.py
get_semester(dt=None)
¶
Determine the semester based on a date.
Winter semester (WS) runs from October 1 to end of February. Summer semester (SoSe) runs from March 1 to end of September.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
Optional[datetime]
|
The date to determine the semester for. Defaults to current date. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Semester string in format "WS25/26" or "SoSe25". |
Source code in src/academic_doc_generator/core/utils.py
load_global_config()
¶
Load settings from global config.yaml file if it exists.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The configuration settings. |
Source code in src/academic_doc_generator/core/utils.py
split_student_name(full_name)
¶
Split a student's full name into first and last name.
Handles formats like "Last, First" or "First Last".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_name
|
str
|
The complete name string. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
Tuple of (first_name, last_name). |