Skip to main content
https://travis-ci.org/chinapnr/fishbase.svg?branch=master https://coveralls.io/repos/github/chinapnr/fishbase/badge.svg?branch=master https://readthedocs.org/projects/fishbase/badge/?version=latest https://ci.appveyor.com/api/projects/status/ecskod12wy8fvkxu?svg=true

fishbase 简介

fishbase 是由我们自主开发和整理的一套 Python 基础函数库,当前版本为 v1.1.16.

自 2016/3 初次发布以来,我们坚持不断更新,先后发布了 20 余个版本。近一年来,我们逐步形成每月更新 1 到 2 个版本的频率,抽象出了很多通用的方法,主要分为以下模块:

模块

功能函数

fish_common

基本函数包

fish_crypt

加密数据函数包

fish_csv

csv 处理增强函数包

fish_data

数据信息处理函数包,含银行卡、身份证等

fish_date

日期处理增强函数包

fish_file

文件处理增强函数包

fish_logger

日志记录增强函数包

fish_project

project 目录结构生成函数包

fish_random

随机数据生成函数包

fish_system

系统增强函数包

swagger

集成 swagger为flask应用生成接口文档信息

安装

# 通过 pip 进行安装或者更新
pip install -U fishbase

fishbase 能干什么?

集成 swagger 为 flask 应用生成接口文档信息

>>> from fishbase.swagger import doc
>>> from fishbase.swagger.swagger import flask_swagger
>>> from flask import Flask

>>> # 创建 Flask app
>>> app = Flask("Demo Server")

>>> @app.route('/v1/query', methods=['GET'])
>>> @doc.summary("xx业务查询接口", group="xx业务")
>>> @doc.description("测试 Swagger 使用, 参数为 URL 参数 token, 且必传")
>>> @doc.consumes("token", required=True)
>>> def test_query():
>>>     pass

>>> # 将 app 对象传递给 swagger 模块
>>> flask_swagger(app)

>>> if __name__ == "__main__":
>>>     app.run("127.0.0.1", "8899", debug=False)

访问: http://127.0.0.1:8899/swagger/ 即可查看接口信息,并在线调试。更多 swagger 使用技巧,可参考 https://fishbase.readthedocs.io/en/latest/swagger.html

获取文件的绝对路径

>>> from fishbase.fish_common import find_files
>>> print(get_abs_filename_with_sub_path('/etc', 'hosts'))
(True, '/etc/hosts')

根据时间戳获取时间间隔

>>> from fishbase.fish_date import get_time_interval
>>> print(get_time_interval(1548575829,1548476921))
{'days': 1, 'hours': 3, 'minutes': 28, 'seconds': 28}

生成随机数据

>>> from fishbase.fish_random import gen_random_id_card
>>> # 随机生成一个身份证号
>>> print(gen_random_id_card())
['3101091986******47']
>>> from fishbase.fish_random import gen_random_bank_card
>>> # 随机生成一个中国银行的信用卡卡号
>>> print(gen_random_bank_card('中国银行', 'CC'))
625907379******1

创建项目结构

>>> import os
>>> from fishbase.fish_project import init_project_by_yml
>>> package_yml = '''
... project: hellopackage
... tree:
...     - README.md
...     - requirements.txt
...     - setup.py
... '''
>>> # 通过 yml 文件创建一个项目结构
>>> init_project_by_yml(package_yml, '.')
>>> print(os.listdir('./hellopackage'))
['requirements.txt', 'README.md', 'setup.py']

最近更新

2019.12.5 v1.1.16

  • 为 flask 应用添加 swagger 模块 #249

2019.7.17 v1.1.15

  • 添加可选参数,定义日志文件格式 #240

  • 根据银行卡、身份证获取详细信息的方法 #243

2019.6.25 v1.1.14

  • 修复金额数字转中文大写时多个零的错误 #238

  • 按照特定长度分割长文本字符 #239

2019.6.11 v1.1.13

  • 数字金额和中文大写相互转换 #235

更多

更多详细文档,请参见:http://fishbase.readthedocs.io/

如有好的建议,欢迎提 issue :https://github.com/chinapnr/fishbase/issues

Metadata

Release files for fishbase 1.1.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fishbase 1.1.16
File Size Uploaded Provenance Actions
fishbase-1.1.16.tar.gz 2.7 MB Without provenance Details for fishbase-1.1.16.tar.gz

Release files / fishbase-1.1.16.tar.gz

Download URL fishbase-1.1.16.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
a72a902bbb9ade3d07747edff4e2cf01590656d560f5d268cc36caa05a501909
BLAKE2b-256 checksum
How to use checksums
41c53f8feef44635bae18a27efe40faca6a3d34a2c72edb37acdc47f88921b93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.7

Security for fishbase 1.1.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page