impuls.tools.strings

impuls.tools.strings.camel_to_snake(camel: str) str

Converts camelCase or PascalCase to snake_case.

>>> camel_to_snake("Foo")
'foo'
>>> camel_to_snake("FooBar")
'foo_bar'
>>> camel_to_snake("fooBarBaz")
'foo_bar_baz'
impuls.tools.strings.is_portable_name(name: str) bool

Checks if a name can be used as a filename - that is it only contains ASCII letters, digits, dot, hyphen or underscores, contains at least one character, and has no special meaning on certain systems (like “.”, “..” or “COM”)

impuls.tools.strings.ILLEGAL_PORTABLE_NAMES: frozenset[str] = frozenset({'.', '..', 'AUX', 'CLOCK$', 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'CON', 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9', 'NUL', 'PRN'})

Set of filenames which can’t be reliably used on some operating systems.

For example, “.” and “..” (dot and dot-dot) have special meaning in POSIX, while Windows has its own set of forbidden filenames.