Parser¶
Date and path parsing utilities used throughout ProgridPy. Provides flexible date parsing that accepts multiple string formats (YYYYMMDD, YYYY-MM-DD, YYYY/MM/DD), datetime.date, datetime.datetime, and None (defaults to today in the given timezone).
Key Functions¶
parse_datetime-- Parses a date value into a timezone-awaredatetime. Accepts strings,date,datetime, orNone.parse_file_location-- Converts a string to aFileLocationenum member.ensure_output_file/to_path-- Path normalization and parent-directory creation helpers.
Functions¶
parse_datetime
¶
Parse datetime in various formats: YYYYMMDD, YYYY/MM/DD, YYYY-MM-DD.
Arguments: value (str | date | datetime | None): Date to parse tz (str | tzinfo): Timezone name or tzinfo instance
Returns: datetime: Parsed datetime object
Raises: ValueError: If the date format is not supported
Source code in src/progridpy/utils/parser.py
parse_file_location
¶
Parse file location string to FileLocation enum.
Arguments: location_str (str): Location string to parse
Returns: FileLocation: Parsed FileLocation enum
Raises: ValueError: If the location string is not supported