🐋 Whatsat?
A while back I switched the strptime_format of the BaseFile constructor to a str | list[str] type, when the first matching format of the list would be used.
However, the type hints remained str elsewhere, e.g. in AudioDataset.from_folder(). Since the use of a list could be of interest here (and it works), I should make all type hints accept list[str].
🐳 Usage exemple
Let's say I have the following audio files with a really messy timezone parsing:
| file name |
actual timestamp |
| 2024_02_24_19_56_18_000000+0100.wav |
2024_02_24_18_56_18_000000+0000 |
| 2024_02_24_19_56_28_000000+0100.wav |
2024_02_24_18_56_28_000000+0000 |
| 2024_02_24_18_56_38_000000.wav |
2024_02_24_18_56_38_000000+0000 |
| 2024_02_24_18_56_48_000000.wav |
2024_02_24_18_56_48_000000+0000 |
| 2024_02_24_20_56_58_000000+0200.wav |
2024_02_24_18_56_58_000000+0000 |
| 2024_02_24_20_57_08_000000+0200.wav |
2024_02_24_18_57_08_000000+0000 |
| 2024_02_24_18_57_18_000000+0000.wav |
2024_02_24_18_57_18_000000+0000 |
| 2024_02_24_19_57_28_000000+0100.wav |
2024_02_24_18_57_28_000000+0000 |
| 2024_02_24_21_57_38_000000+0300.wav |
2024_02_24_18_57_38_000000+0000 |
| 2024_02_24_18_57_48_000000+0000.wav |
2024_02_24_18_57_48_000000+0000 |
| 2024_02_24_19_57_58_000000+0100.wav |
2024_02_24_18_57_58_000000+0000 |
| 2024_02_24_18_58_08_000000+0000.wav |
2024_02_24_18_58_08_000000+0000 |
If I want to convert all (both tz-aware and tz-naive) files to UTC, I could do:
ads = AudioDataset.from_folder(
Path(r"..."),
strptime_format=["%y_%m_%d_%H_%M_%S_%f%z","%y_%m_%d_%H_%M_%S_%f"],
timezone="UTC",
mode="files"
)
The static analyses atm warns me about strptime_format being a list[str] but it works as intended: files will be correctely parsed as being continuous in the UTC timezone.
🐋 Whatsat?
A while back I switched the
strptime_formatof theBaseFileconstructor to astr | list[str]type, when the first matching format of the list would be used.However, the type hints remained
strelsewhere, e.g. inAudioDataset.from_folder(). Since the use of a list could be of interest here (and it works), I should make all type hints acceptlist[str].🐳 Usage exemple
Let's say I have the following audio files with a really messy timezone parsing:
If I want to convert all (both tz-aware and tz-naive) files to UTC, I could do:
The static analyses atm warns me about
strptime_formatbeing alist[str]but it works as intended: files will be correctely parsed as being continuous in the UTC timezone.