Skip to main content

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

Metadata

Release files for publicmethod 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for publicmethod 0.1.4
File Size Uploaded Provenance
publicmethod-0.1.4.tar.gz 19.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for publicmethod 0.1.4
File Interpreter ABI Platform
publicmethod-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 31.3 kB

Release files / publicmethod-0.1.4.tar.gz

Download URL publicmethod-0.1.4.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e4cb0cb7b72284e7f49ca79ffe61437fa8239cde0f1cd521b6e4206f9fa49929
BLAKE2b-256 checksum
How to use checksums
854a581b9137f9c359edf61ca833b913a878df6407203970cb5bac1274a58090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / publicmethod-0.1.4-py3-none-any.whl

Download URL publicmethod-0.1.4-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eefb7657906c91db1fa4f5992e8a1f132e7a5eb50e1ca701aaa5847cbf4520e4
BLAKE2b-256 checksum
How to use checksums
448d60586495c6c3d961ba8219666ff7497997f5f5b9341624d8eef86f5b2a03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Security for publicmethod 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page