Skip to main content

Fishyer's Python Util Library

Project description

我的Python工具库

github地址:fishyer/fish_util pypi地址:fish_util

介绍

这是我自己编写的一些Python工具库,包括:

  • log_util
  • decorator_util:包括trace_exception、trace_time、trace_args、trace_retry、trace_validate等装饰器
  • file_util
  • yaml_util
  • json_util
  • redis_util
  • mysql_util
  • mongo_util
  • oss_util
  • date_util
  • string_util
  • re_util
  • collections_util
  • function_util

安装

pip install fish_util

使用示例

from fish_util.src.log_util import logger
import fish_util.src.decorator_util as decorator_util

logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")


@decorator_util.trace_exception
@decorator_util.trace_time
@decorator_util.trace_args
@decorator_util.trace_retry(max_attempts=2, delay=1)
@decorator_util.trace_validate(
    lambda username: len(username) > 0, lambda password: len(password) > 0
)
def login(username, password):
    if username == "admin" and password == "123456":
        return True
    else:
        return False


def main():
    print(__file__)
    print(login("admin", "123456"))
    print(login("", "123456"))


if __name__ == "__main__":
    main()

输出结果

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fish_util-1.0.33.tar.gz (69.3 kB view hashes)

Uploaded Source

Built Distribution

fish_util-1.0.33-py3-none-any.whl (94.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page