autoname-2.1.0
توضیحات
an enum `AutoName` from python docs with multiple stringcase options
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | autoname-2.1.0 |
| نام | autoname |
| نسخه کتابخانه | 2.1.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Nutchanon Ninyawee |
| ایمیل نویسنده | me@nutchanon.org |
| آدرس صفحه اصلی | https://github.com/wasdee/autoname |
| آدرس اینترنتی | https://pypi.org/project/autoname/ |
| مجوز | ISC |
# autoname
an enum `AutoName` from [python docs](https://docs.python.org/3/library/enum.html#using-automatic-values) with multiple stringcase options.
## Get Started
```bash
$ pip install autoname
```
```python
from autoname import AutoName
from enum import auto
# an enum class
class GameType(AutoName):
INDIE = auto()
print(GameType.INDIE.value) # "INDIE"
# could be alternative in pydantic instead of literal
from pydantic import BaseModel
class Game(BaseModel):
type: GameType
```
Also have others stringcases coverter
1. `AutoNameLower` - convert name value to lowercase
2. `AutoNameUpper` - convert name value to uppercase
e.g.
```python
from autoname import AutoNameLower
from enum import auto
class GameType(AutoNameLower):
INDIE = auto()
print(GameType.INDIE.value) # "indie"
```
You could also bring your own case convertion algorithm.
```python
from autoname import AutoName, transform
from enum import auto
@transform(function=str.lower)
class GameType(AutoName):
INDIE = auto()
print(GameType.INDIE.value) # "indie"
```
If the `autoname` is not a sound variable name. there are alias too.
- `StrEnum` = `AutoName`
- `LowerStrEnum` = `AutoNameLower`
- `UpperStrEnum` = `AutoNameUpper`
e.g.
```python
from autoname import StrEnum, transform
from enum import auto
class GameType(StrEnum):
INDIE = auto()
print(GameType.INDIE.value) # "INDIE"
```
## Alternative
- `StrEnum` from [`fastapi-utils`](https://github.com/dmontagu/fastapi-utils)
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7,<4.0 | Python |
نحوه نصب
نصب پکیج whl autoname-2.1.0:
pip install autoname-2.1.0.whl
نصب پکیج tar.gz autoname-2.1.0:
pip install autoname-2.1.0.tar.gz