staran 1.0.0__tar.gz → 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
staran-1.0.3/PKG-INFO ADDED
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: staran
3
+ Version: 1.0.3
4
+ Summary: staran - 轻量级Python日期工具库
5
+ Home-page: https://github.com/starlxa/staran
6
+ Author: StarAn
7
+ Author-email: starlxa@icloud.com
8
+ License: MIT
9
+ Project-URL: Bug Reports, https://github.com/starlxa/staran/issues
10
+ Project-URL: Source, https://github.com/starlxa/staran
11
+ Keywords: date datetime utilities time-processing
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Topic :: Utilities
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.7
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Operating System :: OS Independent
24
+ Requires-Python: >=3.7
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: author
28
+ Dynamic: author-email
29
+ Dynamic: classifier
30
+ Dynamic: description
31
+ Dynamic: description-content-type
32
+ Dynamic: home-page
33
+ Dynamic: keywords
34
+ Dynamic: license
35
+ Dynamic: license-file
36
+ Dynamic: project-url
37
+ Dynamic: requires-python
38
+ Dynamic: summary
39
+
40
+ # Staran v1.0.3 - 企业级多功能工具库
41
+
42
+ [![Python Version](https://img.shields.io/badge/python-3.7%2B-blue.svg)](https://python.org)
43
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
44
+ [![Test Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](#测试)
45
+
46
+ 一个现代化的Python多功能工具库,为企业应用提供一系列高质量、零依赖的解决方案。
47
+
48
+ ## 🚀 核心理念
49
+
50
+ `staran` 旨在成为一个可扩展的工具库,包含多个独立的、高质量的模块。每个模块都专注于解决特定领域的问题,并遵循统一的设计标准。
51
+
52
+ ### 当前模块
53
+ - **`date`**: 企业级日期处理工具 (v1.0.3)
54
+
55
+ ### 未来模块
56
+ - `file`: 文件处理工具
57
+ - `crypto`: 加解密工具
58
+ - ...
59
+
60
+ ## 📁 项目结构
61
+
62
+ ```
63
+ staran/
64
+ ├── __init__.py # 主包入口,未来可集成更多工具
65
+ └── date/ # 日期工具模块
66
+ ├── __init__.py # date模块入口
67
+ ├── core.py # 核心Date类
68
+ ├── tests/ # date模块的测试
69
+ ├── utils/ # date模块的工具函数
70
+ └── examples/ # date模块的示例
71
+ ```
72
+
73
+ ---
74
+
75
+ ## ✨ `date` 模块 - 企业级日期处理
76
+
77
+ `date` 模块提供了强大的日期处理功能,具有统一API、智能格式记忆和企业级日志等特性。
78
+
79
+ ### 快速开始
80
+
81
+ #### 安装
82
+
83
+ ```bash
84
+ pip install staran
85
+ ```
86
+
87
+ #### 基本用法
88
+
89
+ ```python
90
+ from staran.date import Date, today
91
+
92
+ # 快速创建日期
93
+ today_date = today()
94
+ print(today_date) # 2025-07-29
95
+
96
+ # 从字符串创建
97
+ date = Date.from_string("20250415")
98
+ print(date.format_chinese()) # 2025年04月15日
99
+
100
+ # 日期运算(保持格式)
101
+ future = date.add_months(3)
102
+ print(future) # 20250715
103
+ ```
104
+
105
+ ### 📚 `date` 模块详细文档
106
+
107
+ #### 1. 创建日期对象
108
+
109
+ ```python
110
+ from staran.date import Date
111
+
112
+ # 多种创建方式
113
+ d1 = Date(2025, 4, 15) # 从参数
114
+ d2 = Date.from_string("202504") # 从字符串(智能解析)
115
+ d3 = Date.from_string("20250415") # 完整格式
116
+ d4 = Date.from_string("2025") # 年份格式
117
+ d5 = Date.today() # 今日
118
+ ```
119
+
120
+ #### 2. 智能格式记忆
121
+
122
+ `date` 模块会记住输入格式,并在运算后保持相同格式:
123
+
124
+ ```python
125
+ year_date = Date.from_string("2025")
126
+ print(year_date.add_years(1)) # 2026
127
+
128
+ month_date = Date.from_string("202504")
129
+ print(month_date.add_months(2)) # 202506
130
+
131
+ full_date = Date.from_string("20250415")
132
+ print(full_date.add_days(10)) # 20250425
133
+ ```
134
+
135
+ #### 3. 统一API命名
136
+
137
+ `date` 模块遵循统一的API命名规范,如 `from_*`, `to_*`, `get_*`, `is_*`, `add_*/subtract_*` 等,具体请参考 `staran/date/examples/basic_usage.py`。
138
+
139
+ #### 4. 异常处理
140
+
141
+ `date` 模块提供了一套清晰的异常类,以便更好地处理错误:
142
+
143
+ - `DateError`: 所有日期相关错误的基类。
144
+ - `InvalidDateFormatError`: 当输入字符串格式不正确时抛出。
145
+ - `InvalidDateValueError`: 当日期值无效时(如月份为13)抛出。
146
+
147
+ **示例:**
148
+ ```python
149
+ from staran.date import Date, InvalidDateValueError, InvalidDateFormatError
150
+
151
+ try:
152
+ Date("2025", 13, 1)
153
+ except InvalidDateValueError as e:
154
+ print(e)
155
+
156
+ try:
157
+ Date("invalid-date")
158
+ except InvalidDateFormatError as e:
159
+ print(e)
160
+ ```
161
+
162
+ ## 🧪 测试
163
+
164
+ 运行 `date` 模块的完整测试套件:
165
+
166
+ ```bash
167
+ # 彩色测试输出
168
+ python -m staran.date.tests.run_tests
169
+
170
+ # 标准unittest
171
+ python -m unittest staran.date.tests.test_core
172
+ ```
173
+
174
+ 测试覆盖率:**100%**(64项测试,涵盖所有功能模块)
175
+
176
+ ## 📄 许可证
177
+
178
+ MIT License - 详见 [LICENSE](LICENSE) 文件
179
+
180
+ ## 🤝 贡献
181
+
182
+ 欢迎为 `staran` 贡献新的工具模块或改进现有模块!
183
+
184
+ 1. Fork 本项目
185
+ 2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
186
+ 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
187
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
188
+ 5. 开启Pull Request
189
+
190
+ ## 📞 支持
191
+
192
+ - 📧 Email: team@staran.dev
193
+ - 📖 文档: https://staran.readthedocs.io/
194
+ - 🐛 问题报告: https://github.com/starlxa/staran/issues
195
+
196
+ ---
197
+
198
+ **Staran v1.0.3** - 让工具开发变得简单而强大 ✨
staran-1.0.3/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # Staran v1.0.3 - 企业级多功能工具库
2
+
3
+ [![Python Version](https://img.shields.io/badge/python-3.7%2B-blue.svg)](https://python.org)
4
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
5
+ [![Test Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](#测试)
6
+
7
+ 一个现代化的Python多功能工具库,为企业应用提供一系列高质量、零依赖的解决方案。
8
+
9
+ ## 🚀 核心理念
10
+
11
+ `staran` 旨在成为一个可扩展的工具库,包含多个独立的、高质量的模块。每个模块都专注于解决特定领域的问题,并遵循统一的设计标准。
12
+
13
+ ### 当前模块
14
+ - **`date`**: 企业级日期处理工具 (v1.0.3)
15
+
16
+ ### 未来模块
17
+ - `file`: 文件处理工具
18
+ - `crypto`: 加解密工具
19
+ - ...
20
+
21
+ ## 📁 项目结构
22
+
23
+ ```
24
+ staran/
25
+ ├── __init__.py # 主包入口,未来可集成更多工具
26
+ └── date/ # 日期工具模块
27
+ ├── __init__.py # date模块入口
28
+ ├── core.py # 核心Date类
29
+ ├── tests/ # date模块的测试
30
+ ├── utils/ # date模块的工具函数
31
+ └── examples/ # date模块的示例
32
+ ```
33
+
34
+ ---
35
+
36
+ ## ✨ `date` 模块 - 企业级日期处理
37
+
38
+ `date` 模块提供了强大的日期处理功能,具有统一API、智能格式记忆和企业级日志等特性。
39
+
40
+ ### 快速开始
41
+
42
+ #### 安装
43
+
44
+ ```bash
45
+ pip install staran
46
+ ```
47
+
48
+ #### 基本用法
49
+
50
+ ```python
51
+ from staran.date import Date, today
52
+
53
+ # 快速创建日期
54
+ today_date = today()
55
+ print(today_date) # 2025-07-29
56
+
57
+ # 从字符串创建
58
+ date = Date.from_string("20250415")
59
+ print(date.format_chinese()) # 2025年04月15日
60
+
61
+ # 日期运算(保持格式)
62
+ future = date.add_months(3)
63
+ print(future) # 20250715
64
+ ```
65
+
66
+ ### 📚 `date` 模块详细文档
67
+
68
+ #### 1. 创建日期对象
69
+
70
+ ```python
71
+ from staran.date import Date
72
+
73
+ # 多种创建方式
74
+ d1 = Date(2025, 4, 15) # 从参数
75
+ d2 = Date.from_string("202504") # 从字符串(智能解析)
76
+ d3 = Date.from_string("20250415") # 完整格式
77
+ d4 = Date.from_string("2025") # 年份格式
78
+ d5 = Date.today() # 今日
79
+ ```
80
+
81
+ #### 2. 智能格式记忆
82
+
83
+ `date` 模块会记住输入格式,并在运算后保持相同格式:
84
+
85
+ ```python
86
+ year_date = Date.from_string("2025")
87
+ print(year_date.add_years(1)) # 2026
88
+
89
+ month_date = Date.from_string("202504")
90
+ print(month_date.add_months(2)) # 202506
91
+
92
+ full_date = Date.from_string("20250415")
93
+ print(full_date.add_days(10)) # 20250425
94
+ ```
95
+
96
+ #### 3. 统一API命名
97
+
98
+ `date` 模块遵循统一的API命名规范,如 `from_*`, `to_*`, `get_*`, `is_*`, `add_*/subtract_*` 等,具体请参考 `staran/date/examples/basic_usage.py`。
99
+
100
+ #### 4. 异常处理
101
+
102
+ `date` 模块提供了一套清晰的异常类,以便更好地处理错误:
103
+
104
+ - `DateError`: 所有日期相关错误的基类。
105
+ - `InvalidDateFormatError`: 当输入字符串格式不正确时抛出。
106
+ - `InvalidDateValueError`: 当日期值无效时(如月份为13)抛出。
107
+
108
+ **示例:**
109
+ ```python
110
+ from staran.date import Date, InvalidDateValueError, InvalidDateFormatError
111
+
112
+ try:
113
+ Date("2025", 13, 1)
114
+ except InvalidDateValueError as e:
115
+ print(e)
116
+
117
+ try:
118
+ Date("invalid-date")
119
+ except InvalidDateFormatError as e:
120
+ print(e)
121
+ ```
122
+
123
+ ## 🧪 测试
124
+
125
+ 运行 `date` 模块的完整测试套件:
126
+
127
+ ```bash
128
+ # 彩色测试输出
129
+ python -m staran.date.tests.run_tests
130
+
131
+ # 标准unittest
132
+ python -m unittest staran.date.tests.test_core
133
+ ```
134
+
135
+ 测试覆盖率:**100%**(64项测试,涵盖所有功能模块)
136
+
137
+ ## 📄 许可证
138
+
139
+ MIT License - 详见 [LICENSE](LICENSE) 文件
140
+
141
+ ## 🤝 贡献
142
+
143
+ 欢迎为 `staran` 贡献新的工具模块或改进现有模块!
144
+
145
+ 1. Fork 本项目
146
+ 2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
147
+ 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
148
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
149
+ 5. 开启Pull Request
150
+
151
+ ## 📞 支持
152
+
153
+ - 📧 Email: team@staran.dev
154
+ - 📖 文档: https://staran.readthedocs.io/
155
+ - 🐛 问题报告: https://github.com/starlxa/staran/issues
156
+
157
+ ---
158
+
159
+ **Staran v1.0.3** - 让工具开发变得简单而强大 ✨
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="staran",
5
- version="1.0.0",
5
+ version="1.0.3",
6
6
  description="staran - 轻量级Python日期工具库",
7
7
  long_description=open("README.md", encoding="utf-8").read(),
8
8
  long_description_content_type="text/markdown",
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ Staran - 企业级多功能工具库
6
+ ==========================
7
+
8
+ 一个现代化的Python多功能工具库,为企业应用提供一系列高质量、零依赖的解决方案。
9
+
10
+ 当前模块:
11
+ - **date**: 企业级日期处理 (v1.0.2)
12
+
13
+ 未来模块:
14
+ - file: 文件处理工具
15
+ - crypto: 加解密工具
16
+ - ...
17
+
18
+ 快速开始 (日期处理):
19
+ >>> from staran.date import Date
20
+ >>>
21
+ >>> today = Date.today()
22
+ >>> print(today)
23
+ 20250729
24
+
25
+ >>> date = Date.from_string("20250415")
26
+ >>> print(date.format_chinese())
27
+ 2025年04月15日
28
+ """
29
+
30
+ __version__ = "1.0.3"
31
+ __author__ = "Staran Team"
32
+ __email__ = "team@staran.dev"
33
+ __license__ = "MIT"
34
+
35
+ # 导入核心模块
36
+ from .date import (
37
+ Date,
38
+ DateLogger,
39
+ today,
40
+ from_string,
41
+ DateError,
42
+ InvalidDateFormatError,
43
+ InvalidDateValueError
44
+ )
45
+
46
+ # 定义公共API
47
+ __all__ = [
48
+ # Date 模块
49
+ 'Date',
50
+ 'DateLogger',
51
+ 'today',
52
+ 'from_string',
53
+ 'DateError',
54
+ 'InvalidDateFormatError',
55
+ 'InvalidDateValueError',
56
+
57
+ # 元数据
58
+ '__version__',
59
+ '__author__',
60
+ '__email__',
61
+ '__license__'
62
+ ]
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ Staran Date 模块
6
+ ================
7
+
8
+ 提供企业级日期处理功能。
9
+ """
10
+
11
+ __version__ = "1.0.2"
12
+ __author__ = "Staran Team"
13
+ __email__ = "team@staran.dev"
14
+
15
+ # 导入核心类和功能
16
+ from .core import Date, DateLogger
17
+
18
+ # 导出便捷函数
19
+ def today() -> Date:
20
+ """
21
+ 创建今日的Date对象
22
+ """
23
+ return Date.today()
24
+
25
+ def from_string(date_string: str) -> Date:
26
+ """
27
+ 从字符串创建Date对象
28
+ """
29
+ return Date.from_string(date_string)
30
+
31
+ # 定义公共API
32
+ __all__ = [
33
+ 'Date',
34
+ 'DateLogger',
35
+ 'today',
36
+ 'from_string'
37
+ ]