Skip to main content

通用Python组件库,提供数据读取、路径管理和日志功能

Project description

PublicMethod

通用Python组件库,提供数据读取、路径管理和日志功能的基础类框架。帮助开发者快速构建基于组件的应用程序。

功能特点

  • BaseComponent - 通用基础组件类,提供标准化组件结构
  • PathManager - 路径管理,自动创建时间戳目录
  • DataReader - 数据读取组件,支持多种编码自动检测
  • 日志系统 - 基于Python标准logging模块,支持文件轮转

安装

pip install publicmethod

快速开始

下面是一个使用示例:

# 导入主包中的组件
from publicmethod import BaseComponent

# 或者从子包导入
from publicmethod.core import BaseComponent, PathManager, DataReader

# 创建基础组件实例
component = BaseComponent({
    'debug_mode': True,  # 启用调试模式
    'output_path': 'output'  # 指定输出路径
})

# 读取数据
data = component.read_data('input.txt')

# 开发自定义组件
class MyComponent(BaseComponent):
    def __init__(self, config=None):
        super().__init__(config)
        # 自定义初始化...
    
    def process(self, data=None):
        # 实现自定义处理逻辑
        if data is None:
            data = self._data  # 使用之前读取的数据
        
        # 处理数据
        result = self._process_data(data)
        
        return result
    
    def _process_data(self, data):
        # 实现具体的处理逻辑
        return data.upper()  # 示例:转换为大写

包结构

publicmethod/
├── core/          # 核心组件
│   ├── base_component.py  # 基础组件类
│   ├── path_manager.py    # 路径管理
│   ├── data_reader.py     # 数据读取
│   └── log_config.py      # 日志配置

版本管理

本项目使用Git标签进行版本控制,安装后可通过以下方式获取版本信息:

import publicmethod
print(publicmethod.__version__)

组件说明

BaseComponent

基础组件类,提供以下功能:

  • 配置管理
  • 数据读取
  • 路径管理
  • 日志系统集成
  • 状态管理

PathManager

路径管理器,主要功能:

  • 自动创建带时间戳的输出目录
  • 管理多级目录结构
  • 快速获取文件路径
  • 路径映射管理

DataReader

数据读取组件,支持:

  • 从文件或标准输入读取数据
  • 自动检测文件编码
  • 分块读取大文件

开发

要在开发模式下安装此包:

git clone https://github.com/1034378361/publicmethod.git
cd publicmethod
pip install -e .

许可证

MIT

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

publicmethod-0.1.4.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

publicmethod-0.1.4-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file publicmethod-0.1.4.tar.gz.

File metadata

  • Download URL: publicmethod-0.1.4.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for publicmethod-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e4cb0cb7b72284e7f49ca79ffe61437fa8239cde0f1cd521b6e4206f9fa49929
MD5 4b9a78198ac8aefff6a6138b0d394bc4
BLAKE2b-256 854a581b9137f9c359edf61ca833b913a878df6407203970cb5bac1274a58090

See more details on using hashes here.

File details

Details for the file publicmethod-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: publicmethod-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for publicmethod-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 eefb7657906c91db1fa4f5992e8a1f132e7a5eb50e1ca701aaa5847cbf4520e4
MD5 c8bede0b4cf5bdb90ab22d674259ff1c
BLAKE2b-256 448d60586495c6c3d961ba8219666ff7497997f5f5b9341624d8eef86f5b2a03

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