跳转到主要内容

将字符串转换为snakecase

项目描述

PyPI CircleCI Codecov

Boa是一个Python包,用于规范化字符串并将其转换为snakecase。

例如,它将用户定义的事件 'User Buys Item' 转换为 'user_buys_item',然后可以用于S3中的文件路径,或作为Redshift中的模式或表名称。

它还处理更复杂的情况,如去除标点符号,并将单词从camelCase或PascalCase转换为snake_case(请参阅下面的示例)。

安装

在您的虚拟环境中安装

$ pip install boa-str

快速入门

>>> import boa
>>> my_str = 'Hello Boa'
>>> boa.constrict(my_str)
'hello_boa'

示例

>>> import boa
>>> boa.constrict('toInfinityAndBeyond')
'to_infinity_and_beyond'
>>> boa.constrict('Welcome-to-planet-Earth!')
'welcome_to_planet_earth'

测试

我们使用 nose2coverage 进行单元测试。

使用测试要求安装

$ pip install boa-str[test]

然后运行

$ invoke test

风格

$ invoke lint

贡献

克隆存储库,然后使用开发要求安装,这还包括测试要求

$ git clone https://github.com/astronomerio/boa/
$ cd boa
$ pip install .[dev]

🐍️🐍️🐍️

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

boa-str-1.1.0.tar.gz (2.7 kB 查看散列值)

上传时间

构建分布

boa_str-1.1.0-py2.py3-none-any.whl (4.3 kB 查看散列值)

上传时间 Python 2 Python 3