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.4-cp311-cp311-win_amd64.whl (5.8 MB view details)

Uploaded CPython 3.11Windows x86-64

pycorelibs-0.2.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.6 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.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pycorelibs-0.2.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 5.8 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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d07ff7220f02c11371f7b7353c755876b063690b254d681115257c44311cb18b
MD5 915e4428154366ad32c6073bac6b0f22
BLAKE2b-256 85eab44b90e442040d6ea02a7c37253e949869aa470f5c741aaca64fadfa9119

See more details on using hashes here.

File details

Details for the file pycorelibs-0.2.4-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.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d20ee1db4308d1833f4becb0f71445075ccbe9c759501fa1cce9baca894a9dd
MD5 05ad01d33977288ecacbabb1753e83ff
BLAKE2b-256 d3f4c0ad4ea342dea79139e66cfdaee1be72d4a95d9679b3f8d5d3d5db7b1385

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