Skip to content

Commit

Permalink
Merge pull request #14 from 2018-11-27/master
Browse files Browse the repository at this point in the history
1.1.1
  • Loading branch information
2018-11-27 authored Jul 25, 2024
2 parents 0c1dbba + c925bb7 commit 36ca371
Show file tree
Hide file tree
Showing 8 changed files with 389 additions and 278 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine "gqylpy_exception>=3.0.1"
pip install setuptools wheel twine "exceptionx>=4.1.1,<5.0"
- name: Build package
run: python setup.py bdist_wheel
- name: Publish package
Expand Down
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[<img alt="LOGO" src="http://www.gqylpy.com/static/img/favicon.ico" height="21" width="21"/>](http://www.gqylpy.com)
[![Release](https://img.shields.io/github/release/gqylpy/systempath.svg?style=flat-square")](https://github.com/gqylpy/systempath/releases/latest)
[![Release](https://img.shields.io/github/release/gqylpy/systempath.svg?style=flat-square)](https://github.com/gqylpy/systempath/releases/latest)
[![Python Versions](https://img.shields.io/pypi/pyversions/systempath)](https://pypi.org/project/systempath)
[![License](https://img.shields.io/pypi/l/systempath)](https://github.com/gqylpy/systempath/blob/master/LICENSE)
[![Downloads](https://static.pepy.tech/badge/systempath)](https://pepy.tech/project/systempath)

# systempath
English | [中文](https://github.com/gqylpy/systempath/blob/master/README_CN.md)

> Object-oriented operation of files and system paths.
> Make Python operation of files and system paths become simple, simpler, simplest, humane, unified, and flawless.
**systempath** is a highly specialized library designed for Python developers for file and system path manipulation. By providing an intuitive and powerful object-oriented API, it significantly simplifies complex file and directory management tasks, allowing developers to focus more on implementing core business logic rather than the intricacies of low-level file system operations.

<kbd>pip3 install systempath</kbd>

Expand All @@ -24,6 +24,34 @@
>>> file
/home/gqylpy/alpha.txt

>>> file.open.rb().read()
>>> file.content
b'GQYLPY \xe6\x94\xb9\xe5\x8f\x98\xe4\xb8\x96\xe7\x95\x8c'
```

## Core Features

### 1. Object-Oriented Path Representation

- **Directory Class**: Specifically designed to represent directory paths, providing directory-specific operations such as traversal, creation, deletion, and management of subdirectories and files.
- **File Class**: Specifically designed to represent file paths, offering advanced functions beyond basic file operations, including content reading and writing, appending, and clearing.
- **SystemPath Class**: Serves as a universal interface for `Directory` and `File`, providing maximum flexibility to handle any type of path, whether it's a file or directory.

### 2. Automation and Flexibility

- **Automatic Absolute Path Conversion**: Supports automatically converting relative paths to absolute paths during path object initialization, reducing issues caused by incorrect paths.
- **Strict Mode**: Allows developers to enable strict mode, ensuring that paths do exist during initialization; otherwise, exceptions are thrown, enhancing code robustness and reliability.

### 3. Rich Operational Interfaces

- **Path Concatenation**: Supports path concatenation using `/`, `+` operators, and even brackets, making path construction more intuitive and flexible.
- **Comprehensive File and Directory Operations**: Provides a complete set of file and directory operation methods, including but not limited to reading, writing, copying, moving, deleting, and traversing, meeting various file processing needs.

## Usage Scenarios

- **Automation Script Development**: In scenarios such as automated testing, deployment scripts, log management, systempath offers powerful file and directory manipulation capabilities, simplifying script writing processes.
- **Web Application Development**: Handles user-uploaded files, generates temporary files, and more, making these operations simpler and more efficient with systempath.
- **Data Science and Analysis**: When reading, writing, and processing data files stored in the file system, systempath provides a convenient file management approach for data scientists.

## Conclusion

systempath is a comprehensive and easy-to-use library for file and system path manipulation. Through its object-oriented API design, it significantly simplifies the complexity of file and directory management in Python, allowing developers to focus more on implementing core business logic. Whether it's automation script development, web application building, or data science projects, systempath will be an indispensable and valuable assistant.
57 changes: 57 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[<img alt="LOGO" src="http://www.gqylpy.com/static/img/favicon.ico" height="21" width="21"/>](http://www.gqylpy.com)
[![Release](https://img.shields.io/github/release/gqylpy/systempath.svg?style=flat-square")](https://github.com/gqylpy/systempath/releases/latest)
[![Python Versions](https://img.shields.io/pypi/pyversions/systempath)](https://pypi.org/project/systempath)
[![License](https://img.shields.io/pypi/l/systempath)](https://github.com/gqylpy/systempath/blob/master/LICENSE)
[![Downloads](https://static.pepy.tech/badge/systempath)](https://pepy.tech/project/systempath)

# systempath - 专业级的文件与系统路径操作库
[English](README.md) | 中文

**systempath** 是一个专为Python开发者设计的,高度专业化的文件与系统路径操作库。通过提供一套直观且功能强大的面向对象API,它极大地简化了复杂文件与目录管理的任务,使开发者能够更专注于核心业务逻辑的实现,而非底层文件系统操作的细节。

<kbd>pip3 install systempath</kbd>

```python
>>> from systempath import SystemPath, Directory, File

>>> root = SystemPath('/')

>>> home: Directory = root['home']['gqylpy']
>>> home
/home/gqylpy

>>> file: File = home['alpha.txt']
>>> file
/home/gqylpy/alpha.txt

>>> file.content
b'GQYLPY \xe6\x94\xb9\xe5\x8f\x98\xe4\xb8\x96\xe7\x95\x8c'
```

## 核心特性

### 1. 面向对象的路径表示

- **Directory 类**:专门用于表示目录路径,提供目录遍历、创建、删除及子目录与文件管理等目录特定操作。
- **File 类**:专门用于表示文件路径,除了基本的文件操作外,还提供了内容读写、追加、清空等高级功能。
- **SystemPath 类**:作为 `Directory``File` 的通用接口,提供了最大的灵活性,能够处理任何类型的路径,无论是文件还是目录。

### 2. 自动化与灵活性

- **自动绝对路径转换**:支持在路径对象初始化时自动将相对路径转换为绝对路径,减少因路径错误导致的问题。
- **严格模式**:允许开发者启用严格模式,确保路径在初始化时确实存在,否则抛出异常,增强代码的健壮性和可靠性。

### 3. 丰富的操作接口

- **路径拼接**:支持使用 `/``+` 操作符甚至是中括号进行路径拼接,使得路径构建更加直观和灵活。
- **全面的文件与目录操作**:提供了一整套文件与目录操作方法,包括但不限于读取、写入、复制、移动、删除、遍历等,满足各种文件处理需求。

## 使用场景

- **自动化脚本开发**:在自动化测试、部署脚本、日志管理等场景中,systempath 提供强大的文件与目录操作能力,能够简化脚本编写过程。
- **Web应用开发**:处理用户上传的文件、生成临时文件等场景,systempath 使得这些操作更加简单高效。
- **数据科学与分析**:读取、写入和处理存储在文件系统中的数据文件时,systempath 为数据科学家提供了便捷的文件管理方式。

## 结论

systempath 是一个功能全面、易于使用的文件与系统路径操作库。通过其面向对象的API设计,它极大地简化了Python中文件与目录管理的复杂性,使得开发者能够更专注于核心业务逻辑的实现。无论是自动化脚本开发、Web应用构建,还是数据科学项目,systempath 都将是您不可或缺的得力助手。
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gqylpy_exception>=3.0.1
exceptionx>=4.1.2,<5.0
16 changes: 11 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import setuptools
import systempath as i

from systempath import Content
from systempath import File

idoc: list = i.__doc__.split('\n')

Expand All @@ -20,12 +19,19 @@
license='Apache 2.0',
url='http://gqylpy.com',
project_urls={'Source': source},
description='Object-oriented operation of files and system paths.',
long_description=open('README.md', encoding='utf8').read(),
description='''
The `systempath` is a highly specialized library designed for Python
developers for file and system path manipulation. By providing an
intuitive and powerful object-oriented API, it significantly simplifies
complex file and directory management tasks, allowing developers to
focus more on implementing core business logic rather than the
intricacies of low-level file system operations.
'''.strip().replace('\n ', ''),
long_description=File('README.md').content.decode('utf-8'),
long_description_content_type='text/markdown',
packages=[i.__name__],
python_requires='>=3.8',
install_requires=[x.decode() for x in Content('requirements.txt') if x],
install_requires=[x.decode() for x in File('requirements.txt') if x],
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down
Loading

0 comments on commit 36ca371

Please sign in to comment.