Skip to main content

python工具集

Project description

pxtool

pxtool 是一个Python工具集合,提供了日志处理和JSON文本处理等实用功能。

安装

pip install pxtool

功能特性

1. 日志处理 (set_log)

  • 支持彩色控制台输出
  • 自动创建日志文件并按日期命名
  • 支持自定义日志级别(包括TRACE级别)
  • 同时输出到文件和控制台

示例:

from pxtool import setup_logger
import logging

# 初始化日志配置
setup_logger(log_filename_prefix='myapp', level=logging.INFO)

# 使用日志
logging.debug("调试信息")
logging.info("普通信息")
logging.warning("警告信息")
logging.error("错误信息")

2. JSON处理 (json_deal)

  • 移除JSON文本中的Markdown代码块包装
  • 支持多种格式的JSON文本清理

示例:

from pxtool import remove_json_wrapper

json_text = '''```json
{
    "name": "pxtool",
    "version": "0.1.0"
}
```'''

cleaned_json = remove_json_wrapper(json_text)
print(cleaned_json)

开放api

pip install pxtool[openapi]

def call(xxx: str, url_suffix: str = '/XXXX/XXXX') -> Any:
    ucg_config = {
        'app_key': os.getenv('GATEWAY_APP_KEY', ''),
        'app_secret': os.getenv('GATEWAY_APP_SECRET', ''),
        'host': os.getenv('GATEWAY_HOST', 'https://xxx.xxx')
    }

    api_service = ApiGatewayService(ucg_config)

    query_params = {
        "XXX": xxx
    }

    return api_service.call_api(
        api_path=url_suffix,
        method='GET',
        query_params=query_params
    )

要求

  • Python >= 3.6
  • termcolor (用于彩色日志输出)

许可证

MIT License

作者

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

pxtool-0.1.3.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pxtool-0.1.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pxtool-0.1.3.tar.gz.

File metadata

  • Download URL: pxtool-0.1.3.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pxtool-0.1.3.tar.gz
Algorithm Hash digest
SHA256 48e1767c951a5eecdfae32b4e5c132eab13258117eb5f316b7934d846c001af5
MD5 59a551d25193406e4a7f72d14b2ecb7e
BLAKE2b-256 8ce9f3ad7044ce1ff54cd848b39fdbfffbbbcd42e0bef8117637e73c9101dd61

See more details on using hashes here.

File details

Details for the file pxtool-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pxtool-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pxtool-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 142329320b2f38755e9f16d47586be0940deed3b2014dea66b5cccac116e12d6
MD5 93c1a439b48e2e0ba9bb3edf77383375
BLAKE2b-256 9c407dc5fc3c260ef01303c714df35fd7190de6b6ca61c59ad6562726e68bb11

See more details on using hashes here.

Supported by

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