chatora.mmid-0.1.4
توضیحات
Python helper libraries for MMID.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX :: Linux |
| نام فایل | chatora.mmid-0.1.4 |
| نام | chatora.mmid |
| نسخه کتابخانه | 0.1.4 |
| نگهدارنده | ['Takao Magoori'] |
| ایمیل نگهدارنده | ['takaomag@users.noreply.github.com'] |
| نویسنده | Takao Magoori |
| ایمیل نویسنده | takaomag@users.noreply.github.com |
| آدرس صفحه اصلی | https://github.com/takaomag/chatora.mmid |
| آدرس اینترنتی | https://pypi.org/project/chatora.mmid/ |
| مجوز | MIT |
chatora.mmid
============
Python helper libraries for MMID which is similar to UUIDv1 but sortable.
## Usage
```python
import datetime
import random
import uuid
from chatora.mmid.api import BaseMMID1
BASE_DT = datetime.datetime(2011, 1, 1, tzinfo=datetime.timezone.utc)
class MMID1v0(BaseMMID1):
__slots__ = ('int',)
UUID_VERSION = 4
MMID_VERSION = 0
TS_BIT_LENGTH = 55
EPOCH_DT = datetime.datetime(2010, 1, 1, tzinfo=datetime.timezone.utc)
# Construct
assert MMID1v0().version == 4
assert MMID1v0(dt=BASE_DT).dt == MMID1v0(ts=BASE_DT.timestamp()).dt == BASE_DT
# Sortable, which is useful for RDB column index (PostgreSQL UUID/BYTEA, MySQL BINARY).
assert MMID1v0(dt=BASE_DT) < MMID1v0(dt=BASE_DT + datetime.timedelta(days=1))
clock_seq = random.getrandbits(14)
assert MMID1v0(dt=BASE_DT, clock_seq=clock_seq) == MMID1v0(dt=BASE_DT, clock_seq=clock_seq)
# create_min_instance_from_time()/create_max_instance_from_time() may be useful in case of range query on RDB.
assert MMID1v0.create_min_instance_from_time(
dt=BASE_DT,
) == MMID1v0(hex_='811ed178-c6c0-4000-0000-000000000000')
assert MMID1v0.create_max_instance_from_time(
dt=BASE_DT,
) == MMID1v0(hex_='811ed178-c6c0-4000-ffff-ffffffffffff')
# Compatible with UUID1
uuid1 = uuid.uuid1()
mmid1v0 = MMID1v0(src_uuid1=uuid1)
assert uuid1 == mmid1v0
assert mmid1v0.uuid1 == uuid1
```
Changelog
=========
0.1 (2019-01-16)
----------------
- Birth!
0.1.1 (2019-01-16)
------------------
- Remove unused requirements.
0.1.2 (2019-01-17)
------------------
- Fix timestamp/datetime precision.
- Accept decimal.Decimal() timestamp values.
0.1.3 (2019-01-17)
------------------
- Fix timestamp/datetime precision.
0.1.4 (2019-05-14)
------------------
- Remove `structlog` dependency.
نیازمندی
| مقدار | نام |
|---|---|
| >=41.0.1 | setuptools |
| >=19.1.1 | pip |
| >=0.33.1 | wheel |
| >=19.0 | packaging |
| >=0.2.3 | chatora.util |
| >=0.5.3 | bumpversion |
| >=0.38 | check-manifest |
| >=0.4.1 | colorama |
| >=0.5.1 | click-completion |
| >=0.5 | click-help-colors |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl chatora.mmid-0.1.4:
pip install chatora.mmid-0.1.4.whl
نصب پکیج tar.gz chatora.mmid-0.1.4:
pip install chatora.mmid-0.1.4.tar.gz