Skip to main content

A collection of reusable python core library from AI Lingues.

Project description

PyCoreLibs

AI Lingues 基础组件库- PyCoreLibs

Message

消息库,基于redis的异步消息框架

参考:redis/README.md

Network

search 搜索引擎

互联网搜索引擎

requests 请求

  • fetch_url 强化版通用网络请求函数,增加了重试机制,并适用于复杂场景。

  • is_url 验证是否为合法url

scrawer 网页文本获取

  • HTMLContent 提取网页内容

system 信息

SystemInfo

获取当前系统信息

  • OS 操作系统
  • CPU
  • Macs 网卡
  • MB 主板

RunTimeInfo 运行期信息

  • get_boot_time 获取系统启动时间和系统已运行时长

    跨平台细节:

      Linux:boot_time 基本来自 btime(自启动以来的挂钟差,包含睡眠/休眠的停留时间)。
    
      Windows:psutil 内部通常用系统 tick 估算,一般不包含睡眠时间(更接近“活跃运行时长”)。
    
  • get_uptime 获取自 start_mono(monotonic 起点)至今的运行时长(不受系统时钟跳变影响,如被 NTP/手动调整,或夏令时切换)

Utils

files文件处理

  • EnumFileSizeUnit

  • FilesInfo 类

    • get_file_size 获取文件大小,并返回指定单位的大小。

      支持B,KB,MB,GB,TB
      
    • line_count

      获取指定文件的总行数
      
      Windows系统: 使用换行符作为判断标记
      Linux系统: 使用系统自带的wc命令统计
      
      注: 近适用于文本类型文件,其他类型如二进制文件统计结果不具备参考意义
      
    • get_directory_last_modified_time 获取指定目录最后修改时间

    • get_directory_last_modified_timestamp 获取指定目录最后修改时间戳

formate 数据格式化指定类型

Formates 类,静态方法如下:

  • fInt 转换为整数
  • fFloat 转换为浮点数
  • fBool 转换为布尔值
  • fDate 按指定格式解析日期
  • fEnum 校验值是否在允许集合内(用于枚举字段)
  • fJSON 解析为 JSON 对象

logger日志

  • 支持自动产生日志
  • 支持同时向控制台和日志文件输出
  • 支持进度条
  • 支持info、warning和error三个级别的日志

strings 字符串处理

UniCodeGenerator 创建随机码,日期前缀 + 随机码

可配置、使用 secrets 生成高强度随机码的编码生成类
| 场景            | 参数示例                                        |
| ----------------| ---------------------------------------------- |
| 邀请码(短)     | `prefix_date=False, random_length=6`           |
| 订单号(当天唯一)| `prefix_date=True, random_length=4`            |
| URL 安全短码     | `charset=string.ascii_letters + string.digits` |

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pycorelibs-0.2.3-cp311-cp311-win_amd64.whl (5.2 MB view details)

Uploaded CPython 3.11Windows x86-64

pycorelibs-0.2.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file pycorelibs-0.2.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pycorelibs-0.2.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 5.2 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pycorelibs-0.2.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 691f5079f018acecd177e2683dd1a1f774fe864a2c98e692df0f0301832fe06f
MD5 6a2ed0f8ba14cfbf521cc7259ab4e8d5
BLAKE2b-256 f22b19bc063f482a6da3dafcedaabc9721647b7b4d739bff96bdfcec7ad80b7c

See more details on using hashes here.

File details

Details for the file pycorelibs-0.2.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycorelibs-0.2.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00262a12a6fc5195a754592b56bed0a35cc9d8ffeee5d8bc93e14889211297a7
MD5 01d2af4ee4e7883857e2e2a5fab2fb88
BLAKE2b-256 e93c94360646dec823d1fcde1c52e3b8e1da0dbe2f63e80b4c6a37626e6e88b3

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