Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
penut85420 committed Jan 6, 2021
1 parent 5b00bd3 commit ba971ef
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 21 deletions.
56 changes: 41 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,61 @@
# Penut

![GitHub Release](https://img.shields.io/github/v/release/penut85420/penut?style=for-the-badge)
![PyPI Release](https://img.shields.io/pypi/v/penut?style=for-the-badge)
![Python Version](https://img.shields.io/pypi/pyversions/penut?style=for-the-badge)
![PyPI Downloads](https://img.shields.io/pypi/dm/penut?style=for-the-badge)
![License](https://img.shields.io/pypi/l/penut?style=for-the-badge)

## Introduction
+ This package is a collection of my useful functions, including some useful IO operations.

## Installation
+ You can install this package through pip:
```
pip install penut
```bash
$ pip install penut
```

## Usage
+ You can easily load or dump and json/pkl/csv/npy file:
+ Easily load or dump and json/pkl/csv/npy file:
```python
import penut.io as pio
data = pio.load('./data.json')
data = pio.load('./data.pkl')
data = pio.load('./data.csv')
data = pio.load('./data.npy')
data = pio.load('data.json')
data = pio.load('data.pkl')
data = pio.load('data.csv')
data = pio.load('data.npy')
pio.dump(data, './data.json')
pio.dump(data, './data.pkl')
pio.dump(data, './data.csv')
pio.dump(data, './data.npy')
pio.dump(data, 'data.json')
pio.dump(data, 'data.pkl')
pio.dump(data, 'data.csv')
pio.dump(data, 'data.npy')
```
+ You can easily measure the execution time of code:
+ Easily measure the execution time of code:
```python
from penut.uitls import TimeCost
import time
from penut import TimeCost
with TimeCost('Sleep Time'):
import time
time.sleep(1)
time.sleep(1)
# Output: Sleep Time: 1.000262s
# With custom format
fmt = lambda msg, tts: f'Hello {msg}, you cost {tts:.2f}s!!'
with TimeCost('Custom Format', verbose_fmt=fmt):
time.sleep(1)
# Output: Hello Custom Format, you cost 1.00s!!
```
+ Easily convert `datetime.timedelta` to string:
```python
from penut import td2s
from datetime import datetime
a = datetime(2021, 1, 6, 11, 32, 23)
b = datetime(2021, 1, 7, 12, 38, 17)
d = b - a
print(td2s(d)) # 62:17:54
fmt = lambda h, m, s: f'{h}h{m}m{s}s'
print(td2s(d, fmt)) # 62h17m54s
```
10 changes: 6 additions & 4 deletions mk_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
# 2. Build dist by `python setup.py sdist bdist_wheel`.
# 3. Upload by `twine upload dist/*`.

python -m pip install -U setuptools wheel twine
# python -m pip install -U setuptools wheel twine
rm -rf build dist penut_utils.egg-info
python setup.py sdist bdist_wheel
python -m twine upload --repository testpypi dist/*
# python -m twine upload dist/*
# python -m pip install -i https://test.pypi.org/simple/ penut_utils==0.0.1
# python -m twine upload --repository testpypi dist/* # Upload to test pypi
python -m twine upload dist/*

# Install from test pypi
# python -m pip install -i https://test.pypi.org/simple/ penut
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import setuptools

setuptools.setup(
name="penut-utils",
version="0.0.3",
name="penut",
version="0.0.1",
author="PenutChen",
author_email="penut85420@gmail.com",
description="This is a collection of my useful functions.",
Expand Down

0 comments on commit ba971ef

Please sign in to comment.