将字符串转换为snakecase
boa-str的Python项目详细描述
boa是一个python包,用于规范化字符串并将其转换为snakecase。
例如,它将用户定义的事件'User Buys Item'转换为'user_buys_item',然后可以在s3的文件路径中使用,或者在redshift中用作架构或表的名称。
它还处理更复杂的情况,例如去掉标点符号,将单词从camelcase或pascalcase转换为snake_case(参见下面的示例)。
安装
在虚拟环境中安装:
$ pip install boa-str
快速启动
>>>importboa>>>my_str='Hello Boa'>>>boa.constrict(my_str)'hello_boa'
示例
>>>importboa>>>boa.constrict('toInfinityAndBeyond')'to_infinity_and_beyond'>>>boa.constrict('Welcome-to-planet-Earth!')'welcome_to_planet_earth'
样式
$ invoke lint
贡献
克隆repo,然后安装dev需求,其中还包括测试需求:
$ git clone https://github.com/astronomerio/boa/ $cd boa $ pip install .[dev]
___