Skip to content

Commit

Permalink
Merge pull request #15 from kinegratii/develop
Browse files Browse the repository at this point in the history
发布V3.3.0
  • Loading branch information
kinegratii authored Aug 15, 2020
2 parents e7d1d13 + 40adb3c commit 9973d5d
Show file tree
Hide file tree
Showing 37 changed files with 396 additions and 349 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2019 kinegratii
Copyright (c) 2015-2020 kinegratii

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
32 changes: 29 additions & 3 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ A function sets for fetch the values of some axises.
Get list values from dict list.

```python
from borax.fetch import fetch
from borax.datasets.fetch import fetch

objects = [
{'id': 282, 'name': 'Alice', 'age': 30},
Expand All @@ -125,7 +125,12 @@ Output

## Document

See [online document](https://kinegratii.github.io/borax) for more detail, which is powered by [docsify](https://docsify.js.org/) .
The document site is powered by [docsify](https://docsify.js.org/), and hosted on the folowing site:

| Source | Page Link |
| ---- | ---- |
| github | [https://kinegratii.github.io/borax](https://kinegratii.github.io/borax) |
| gitee | [https://kinegratii.gitee.io/borax](https://kinegratii.gitee.io/borax) |

## Development Features

Expand All @@ -137,4 +142,25 @@ See [online document](https://kinegratii.github.io/borax) for more detail, which

## License

This project is issued with MIT License, see LICENSE file for more detail.
```
The MIT License (MIT)
Copyright (c) 2015-2020 kinegratii
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```
40 changes: 33 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ print(dls.countdown()) # 344
将金额转化为符合标准的大写数字。

```
>>> from borax.finance import financial_amount_capital
>>> financial_amount_capital(100000000)
>>> from borax.numbers import FinanceNumbers
>>> FinanceNumbers.to_capital_str(100000000)
'壹亿元整'
>>>financial_amount_capital(4578442.23)
>>>FinanceNumbers.to_capital_str(4578442.23)
'肆佰伍拾柒万捌仟肆佰肆拾贰元贰角叁分'
>>>financial_amount_capital(107000.53)
>>>FinanceNumbers.to_capital_str(107000.53)
壹拾万柒仟元伍角叁分
```

Expand All @@ -91,7 +91,7 @@ print(dls.countdown()) # 344
从数据序列中选择一个或多个字段的数据。

```python
from borax.fetch import fetch
from borax.datasets.fetch import fetch

objects = [
{'id': 282, 'name': 'Alice', 'age': 30},
Expand All @@ -105,7 +105,12 @@ print(names) # ['Alice', 'Bob', 'Charlie']

## 文档

在线文档托管在 [https://kinegratii.github.io/borax](https://kinegratii.github.io/borax) ,由 [docsify](https://docsify.js.org/) 构建。
文档由 [docsify](https://docsify.js.org/) 构建。

|| 网址 |
| ---- | ---- |
| github | [https://kinegratii.github.io/borax](https://kinegratii.github.io/borax) |
| gitee | [https://kinegratii.gitee.io/borax](https://kinegratii.gitee.io/borax) |

## 开发特性和规范

Expand All @@ -117,7 +122,28 @@ print(names) # ['Alice', 'Bob', 'Charlie']

## 开源协议

MIT License (MIT)
```
The MIT License (MIT)
Copyright (c) 2015-2020 kinegratii
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

## 捐赠

Expand Down
2 changes: 1 addition & 1 deletion borax/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding=utf8

__version__ = '3.2.0'
__version__ = '3.3.0'
__author__ = 'kinegratii'
Empty file removed borax/cli/__init__.py
Empty file.
Empty file removed borax/cli/commands/__init__.py
Empty file.
87 changes: 0 additions & 87 deletions borax/cli/commands/mpi.py

This file was deleted.

36 changes: 0 additions & 36 deletions borax/cli/main.py

This file was deleted.

Empty file removed borax/decorators/__init__.py
Empty file.
10 changes: 0 additions & 10 deletions borax/fetch.py

This file was deleted.

42 changes: 10 additions & 32 deletions borax/finance.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,20 @@
# coding=utf8

import re
from decimal import Decimal

from typing import Union

RULES = [
(r'零角零分$', '整'),
(r'零[仟佰拾]', '零'),
(r'零{2,}', '零'),
(r'零([亿|万])', r'\g<1>'),
(r'零+元', '元'),
(r'亿零{0,3}万', '亿'),
(r'^元', '零元')
]
import warnings

MAX_VALUE_LIMIT = 1000000000000
from borax.numbers import FinanceNumbers

__all__ = ['financial_amount_capital']


def financial_amount_capital(num: Union[int, float, Decimal, str]) -> str:
units = '仟佰拾亿仟佰拾万仟佰拾元角分'
digits = '零壹贰叁肆伍陆柒捌玖'
if isinstance(num, str):
_n = int(num)
else:
_n = num
if _n < 0 or _n >= MAX_VALUE_LIMIT:
raise ValueError('Out of range')

num_str = str(num) + '00'
dot_pos = num_str.find('.')
if dot_pos > -1:
num_str = num_str[:dot_pos] + num_str[dot_pos + 1:dot_pos + 3]
capital_str = ''.join([digits[int(i)] for i in num_str])
s_units = units[len(units) - len(num_str):]

o = ''.join('{}{}'.format(u, d) for u, d in zip(capital_str, s_units))
for p, d in RULES:
o = re.sub(p, d, o)

return o
warnings.warn(
'This method is deprecated and will be removed in V3.5.Use borax.numbers.FinanceNumbers instead.',
category=PendingDeprecationWarning
)

return FinanceNumbers.to_capital_str(num)
Loading

0 comments on commit 9973d5d

Please sign in to comment.