staran 0.6.1__py3-none-any.whl → 1.0.0__py3-none-any.whl

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/__init__.py CHANGED
@@ -0,0 +1,10 @@
1
+ """
2
+ Staran - 轻量级Python日期工具库
3
+
4
+ 提供智能的日期处理功能,支持多种日期格式和便捷的日期运算。
5
+ """
6
+
7
+ from .tools.date import Date
8
+
9
+ __version__ = "1.0.0"
10
+ __all__ = ["Date"]
staran/tools/__init__.py CHANGED
@@ -2,10 +2,10 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  """
5
- Staran Tools - 工具集合模块
6
- ==========================
5
+ Staran Tools - 日期工具模块
6
+ ========================
7
7
 
8
- 提供各种实用工具类和函数:
8
+ 提供智能的日期处理功能。
9
9
 
10
10
  Date类 - 智能日期处理:
11
11
  - 格式记忆:根据输入自动设置默认格式
@@ -39,5 +39,5 @@ __all__ = [
39
39
 
40
40
  # 模块信息
41
41
  __version__ = '1.0.0'
42
- __author__ = 'Staran Team'
43
- __description__ = 'Staran utilities with smart format memory'
42
+ __author__ = 'StarAn'
43
+ __description__ = 'Lightweight Python date utilities with smart format memory'
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.4
2
+ Name: staran
3
+ Version: 1.0.0
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.0 - 轻量级Python日期工具库
41
+
42
+ - 🔧 **完善的包管理** - 优化setup.py配置,专注核心日期功能
43
+ - 🗓️ **智能日期处理** - 支持多种日期格式,自动格式记忆
44
+ - 📅 **灵活日期运算** - 便捷的日期加减运算,保持原格式
45
+ - 🎯 **简洁易用** - 专注日期处理,轻量级设计
46
+ - 🔄 **格式转换** - 支持多种日期格式输出
47
+ - 📦 **零依赖** - 只使用Python标准库,无外部依赖
48
+
49
+ ## 🎯 专为日期处理设计的Python工具库
50
+
51
+ Staran是一个轻量级的日期处理工具库,提供智能的日期格式记忆和便捷的日期运算功能。特别适合需要处理多种日期格式的应用场景。
52
+
53
+ ## ✨ v1.0.0 新特性
54
+
55
+ 🎉 **稳定版本发布** - 核心功能完备,API稳定
56
+
57
+ - 🔧 **完善的包管理** - 优化setup.py配置,专注核心功能
58
+ - 📦 **轻量化重构** - 移除非核心模块,专注日期处理
59
+ - 🗓️ **智能格式记忆** - 根据输入自动记住日期格式
60
+ - 📅 **丰富的运算功能** - 支持天数和月数的加减运算
61
+ - 🎯 **零外部依赖** - 只使用Python标准库
62
+ - 🔄 **多种输出格式** - 支持中文、ISO等多种格式输出
63
+
64
+ ## 🚧 v1.1.0 计划中的企业级优化
65
+
66
+ > **注意:** 当前v1.0.0版本具备完整的核心功能,但在企业工程化标准方面还有提升空间。
67
+ > 我们将在v1.1.0版本中完成以下企业级优化:
68
+
69
+ ### 🔬 **代码质量提升**
70
+ - ✅ **类型注解** - 完整的typing支持和类型检查
71
+ - ✅ **单元测试** - 100%代码覆盖率的测试套件
72
+ - ✅ **文档规范** - 完善的docstring和API文档
73
+ - ✅ **异常处理** - 标准化的异常体系和错误码
74
+
75
+ ### 🏗️ **架构优化**
76
+ - ✅ **性能优化** - 缓存机制和延迟计算
77
+ - ✅ **配置管理** - 支持配置文件和环境变量
78
+ - ✅ **日志系统** - 结构化日志和调试支持
79
+ - ✅ **插件架构** - 可扩展的格式化器和验证器
80
+
81
+ ### 🛡️ **企业级特性**
82
+ - ✅ **输入验证** - 严格的数据验证和清洗
83
+ - ✅ **国际化支持** - 多语言和时区处理
84
+ - ✅ **向后兼容** - API版本管理和迁移指南
85
+ - ✅ **安全考虑** - 输入安全和数据保护
86
+
87
+ ### 📊 **开发体验**
88
+ - ✅ **IDE支持** - 完整的代码提示和自动完成
89
+ - ✅ **调试工具** - 丰富的调试信息和工具
90
+ - ✅ **基准测试** - 性能基准和监控
91
+ - ✅ **CI/CD集成** - 自动化测试和发布流程
92
+
93
+ ## ⚠️ 当前版本限制
94
+
95
+ v1.0.0是一个功能完备的稳定版本,但请注意以下企业级使用的限制:
96
+
97
+ ### 📝 **代码质量**
98
+ - **类型检查**: 当前缺少typing注解,IDE代码提示可能不完整
99
+ - **测试覆盖**: 没有自动化测试套件,建议在生产环境使用前进行充分测试
100
+ - **异常处理**: 异常信息可能不够详细,调试时需要注意
101
+
102
+ ### 🏗️ **架构限制**
103
+ - **性能**: 没有缓存机制,频繁计算可能影响性能
104
+ - **配置**: 不支持配置文件,所有设置需要在代码中硬编码
105
+ - **日志**: 没有内置日志系统,调试信息有限
106
+
107
+ ### 🛡️ **企业特性**
108
+ - **验证**: 输入验证相对简单,复杂场景可能需要额外验证
109
+ - **国际化**: 目前只支持基本的中文格式,缺少完整的i18n支持
110
+ - **安全**: 没有特殊的安全考虑,输入数据请自行验证
111
+
112
+ > 💡 **建议**: 如果您需要在企业级生产环境中使用,建议等待v1.1.0版本,或者基于当前版本进行二次开发。
113
+
114
+ ## 🚀 快速开始
115
+
116
+ ### 安装
117
+ ```bash
118
+ pip install staran
119
+ ```
120
+
121
+ ### 基础用法 - 智能日期处理
122
+
123
+ ```python
124
+ from staran import Date
125
+
126
+ # 创建日期 - 智能格式记忆
127
+ date1 = Date('202504') # 输出: 202504 (记住年月格式)
128
+ date2 = Date('20250415') # 输出: 20250415 (记住完整格式)
129
+ date3 = Date(2025, 4, 15) # 输出: 2025-04-15
130
+
131
+ # 日期运算保持格式
132
+ new_date = date1.add_months(2) # 输出: 202506 (保持YYYYMM格式)
133
+
134
+ # 多种格式输出
135
+ print(date2.format_chinese()) # 输出: 2025年04月15日
136
+ print(date2.format_iso()) # 输出: 2025-04-15
137
+ ```
138
+
139
+ ## 📚 核心功能
140
+
141
+ ### 🗓️ Date类 - 智能日期处理
142
+
143
+ #### 创建日期对象
144
+
145
+ ```python
146
+ from staran import Date
147
+
148
+ # 字符串格式(自动识别)
149
+ date1 = Date('2025') # 年份
150
+ date2 = Date('202504') # 年月
151
+ date3 = Date('20250415') # 年月日
152
+
153
+ # 参数格式
154
+ date4 = Date(2025, 4, 15) # 年, 月, 日
155
+ date5 = Date(year=2025, month=4, day=15)
156
+
157
+ # 从datetime对象
158
+ from datetime import datetime
159
+ date6 = Date(datetime.now())
160
+ ```
161
+
162
+ #### 日期运算
163
+
164
+ ```python
165
+ # 加减天数
166
+ tomorrow = date.add_days(1)
167
+ yesterday = date.add_days(-1)
168
+
169
+ # 加减月数
170
+ next_month = date.add_months(1)
171
+ last_month = date.add_months(-1)
172
+
173
+ # 月末日期
174
+ month_end = date.month_end()
175
+
176
+ # 月初日期
177
+ month_start = date.month_start()
178
+ ```
179
+
180
+ #### 格式化输出
181
+
182
+ ```python
183
+ date = Date('20250415')
184
+
185
+ print(date) # 20250415 (保持原格式)
186
+ print(date.format_iso()) # 2025-04-15
187
+ print(date.format_chinese()) # 2025年04月15日
188
+ print(date.format_slash()) # 2025/04/15
189
+ print(date.format_dot()) # 2025.04.15
190
+ ```
191
+
192
+ #### 日期比较
193
+
194
+ ```python
195
+ date1 = Date('20250415')
196
+ date2 = Date('20250416')
197
+
198
+ print(date1 < date2) # True
199
+ print(date1 == date2) # False
200
+ print(date1 > date2) # False
201
+ ```
202
+
203
+ ## 🎯 特色功能
204
+
205
+ ### 智能格式记忆
206
+
207
+ Date类会根据输入格式自动选择默认输出格式:
208
+
209
+ ```python
210
+ # 年月格式 - 输出保持YYYYMM
211
+ date_ym = Date('202504')
212
+ print(date_ym) # 202504
213
+ print(date_ym.add_months(1)) # 202505
214
+
215
+ # 完整格式 - 输出保持YYYYMMDD
216
+ date_full = Date('20250415')
217
+ print(date_full) # 20250415
218
+ print(date_full.add_days(1)) # 20250416
219
+ ```
220
+
221
+ ### 灵活的日期运算
222
+
223
+ ```python
224
+ date = Date('202504')
225
+
226
+ # 月份运算
227
+ print(date.add_months(3)) # 202507
228
+ print(date.add_months(-2)) # 202502
229
+
230
+ # 季度运算
231
+ print(date.add_months(3)) # 下一季度
232
+
233
+ # 年份运算
234
+ print(date.add_months(12)) # 明年同月
235
+ ```
236
+
237
+ ## 🛠️ 高级用法
238
+
239
+ ### 批量日期处理
240
+
241
+ ```python
242
+ from staran import Date
243
+
244
+ # 生成日期序列
245
+ start_date = Date('202501')
246
+ dates = []
247
+ for i in range(12):
248
+ dates.append(start_date.add_months(i))
249
+
250
+ print(dates) # ['202501', '202502', ..., '202512']
251
+ ```
252
+
253
+ ### 与datetime互操作
254
+
255
+ ```python
256
+ from staran import Date
257
+ from datetime import datetime
258
+
259
+ # Date转datetime
260
+ date = Date('20250415')
261
+ dt = date.to_datetime()
262
+
263
+ # datetime转Date
264
+ dt = datetime.now()
265
+ date = Date(dt)
266
+ ```
267
+
268
+ ## 📋 API参考
269
+
270
+ ### Date类方法
271
+
272
+ | 方法 | 描述 | 示例 |
273
+ |------|------|------|
274
+ | `Date(input)` | 创建日期对象 | `Date('202504')` |
275
+ | `add_days(n)` | 加减天数 | `date.add_days(7)` |
276
+ | `add_months(n)` | 加减月数 | `date.add_months(2)` |
277
+ | `month_start()` | 获取月初 | `date.month_start()` |
278
+ | `month_end()` | 获取月末 | `date.month_end()` |
279
+ | `format_iso()` | ISO格式 | `date.format_iso()` |
280
+ | `format_chinese()` | 中文格式 | `date.format_chinese()` |
281
+ | `format_slash()` | 斜杠格式 | `date.format_slash()` |
282
+ | `format_dot()` | 点分格式 | `date.format_dot()` |
283
+ | `to_datetime()` | 转datetime | `date.to_datetime()` |
284
+
285
+ ## 🤝 贡献
286
+
287
+ 欢迎提交Issues和Pull Requests!
288
+
289
+ ## 📄 许可证
290
+
291
+ MIT License - 详见 [LICENSE](LICENSE) 文件。
292
+
293
+ ## 🔗 链接
294
+
295
+ - [GitHub仓库](https://github.com/starlxa/staran)
296
+ - [PyPI包页面](https://pypi.org/project/staran/)
297
+ - [问题反馈](https://github.com/starlxa/staran/issues)
298
+
299
+ ---
300
+
301
+ **Staran** - 让日期处理变得简单而优雅 ✨
@@ -0,0 +1,8 @@
1
+ staran/__init__.py,sha256=G8Kfqho5-4yN_2WS7xkRa63C0AdDS4OQTWRMLtVnypw,208
2
+ staran/tools/__init__.py,sha256=4R2WpIlVtR0_QZL2eB5AcwlKffNc0z1V-YIg1lk8xYA,1061
3
+ staran/tools/date.py,sha256=-QyEMWVx6czMuOIwcV7kR3gBMRVOwb5qevo7GEFSJKE,10488
4
+ staran-1.0.0.dist-info/licenses/LICENSE,sha256=2EmsBIyDCono4iVXNpv5_px9qt2b7hfPq1WuyGVMNP4,1361
5
+ staran-1.0.0.dist-info/METADATA,sha256=bnl3wnJe3bVEpCfEC6SwBv7-1BRicwIgf9RTFUCqdOw,8862
6
+ staran-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ staran-1.0.0.dist-info/top_level.txt,sha256=NOUZtXSh5oSIEjHrC0lQ9WmoKtD010Q00dghWyag-Zs,7
8
+ staran-1.0.0.dist-info/RECORD,,
staran/banks/__init__.py DELETED
@@ -1,30 +0,0 @@
1
- """
2
- staran.banks - 银行配置模块
3
-
4
- 该模块包含不同银行的特定配置,包括:
5
- - 数据库连接配置
6
- - 表结构定义
7
- - 业务规则设置
8
- - 模型配置
9
-
10
- 支持的银行:
11
- - xinjiang_icbc: 新疆工行配置
12
-
13
- 版本: 0.6.0
14
- """
15
-
16
- from .xinjiang_icbc import (
17
- XinjiangICBCConfig,
18
- get_xinjiang_icbc_tables,
19
- get_xinjiang_icbc_models,
20
- xinjiang_icbc_config
21
- )
22
-
23
- __all__ = [
24
- 'XinjiangICBCConfig',
25
- 'xinjiang_icbc_config',
26
- 'get_xinjiang_icbc_tables',
27
- 'get_xinjiang_icbc_models'
28
- ]
29
-
30
- __version__ = "0.6.0"
@@ -1,90 +0,0 @@
1
- """
2
- 新疆工行银行配置模块
3
-
4
- 专门针对新疆工行代发长尾客户的配置:
5
- - 数据库表结构定义(代发长尾客户专用)
6
- - 业务规则配置
7
- - 模型配置(提升模型和防流失模型)
8
-
9
- 数据库: xinjiang_icbc_daifa_longtail
10
- 业务范围: 代发长尾客户
11
- """
12
-
13
- from dataclasses import dataclass
14
- from typing import Dict, List, Optional
15
- from datetime import datetime
16
-
17
-
18
- @dataclass
19
- class XinjiangICBCConfig:
20
- """新疆工行配置类"""
21
-
22
- # 数据库配置
23
- database_name: str = "xinjiang_icbc_daifa_longtail"
24
- schema_name: str = "daifa_longtail"
25
-
26
- # 业务配置
27
- business_domain: str = "代发长尾客户"
28
- customer_segment: str = "代发长尾"
29
-
30
- # 模型配置
31
- available_models: List[str] = None
32
-
33
- # 业务规则
34
- longtail_asset_min: float = 10000 # 长尾客户最小资产
35
- longtail_asset_max: float = 100000 # 长尾客户最大资产
36
- upgrade_target: float = 3000 # 提升目标金额
37
- churn_threshold: float = 1500 # 流失阈值金额
38
-
39
- def __post_init__(self):
40
- if self.available_models is None:
41
- self.available_models = [
42
- "daifa_longtail_upgrade_3k", # 代发长尾提升3k模型
43
- "daifa_longtail_churn_1_5k" # 代发长尾防流失1.5k模型
44
- ]
45
-
46
-
47
- def get_xinjiang_icbc_tables() -> Dict[str, str]:
48
- """获取新疆工行代发长尾客户表配置"""
49
- return {
50
- # 代发长尾客户行为表
51
- "daifa_longtail_behavior": "xinjiang_icbc_daifa_hlwj_dfcw_f1_f4_wy",
52
-
53
- # 代发长尾客户资产平均表
54
- "daifa_longtail_asset_avg": "xinjiang_icbc_daifa_hlwj_zi_chan_avg_wy",
55
-
56
- # 代发长尾客户资产配置表
57
- "daifa_longtail_asset_config": "xinjiang_icbc_daifa_hlwj_zi_chan_config_wy",
58
-
59
- # 代发长尾客户月度统计表
60
- "daifa_longtail_monthly_stat": "xinjiang_icbc_daifa_hlwj_monthly_stat_wy"
61
- }
62
-
63
-
64
- def get_xinjiang_icbc_models() -> Dict[str, Dict]:
65
- """获取新疆工行代发长尾客户模型配置"""
66
- return {
67
- "daifa_longtail_upgrade_3k": {
68
- "name": "代发长尾客户提升3k预测模型",
69
- "description": "预测下个月代发长尾客户资产提升3000元的概率",
70
- "target": "upgrade_3k_next_month",
71
- "model_type": "binary_classification",
72
- "business_objective": "识别有潜力提升资产的代发长尾客户",
73
- "target_threshold": 3000,
74
- "prediction_window": "1_month"
75
- },
76
-
77
- "daifa_longtail_churn_1_5k": {
78
- "name": "代发长尾客户防流失1.5k预测模型",
79
- "description": "预测下个月代发长尾客户流失1500元资产的风险",
80
- "target": "churn_1_5k_next_month",
81
- "model_type": "binary_classification",
82
- "business_objective": "识别有流失风险的代发长尾客户",
83
- "target_threshold": 1500,
84
- "prediction_window": "1_month"
85
- }
86
- }
87
-
88
-
89
- # 创建默认配置实例
90
- xinjiang_icbc_config = XinjiangICBCConfig()
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- 数据库引擎模块
6
- 提供统一的数据库引擎接口
7
- """
8
-
9
- # 基础组件
10
- from .base import BaseEngine, DatabaseType
11
-
12
- # 具体引擎实现
13
- from .spark import SparkEngine
14
- from .hive import HiveEngine
15
-
16
- # 图灵平台引擎 (可选导入)
17
- try:
18
- from .turing import TuringEngine, create_turing_engine
19
- _TURING_AVAILABLE = True
20
- except ImportError:
21
- TuringEngine = None
22
- create_turing_engine = None
23
- _TURING_AVAILABLE = False
24
-
25
- # 便捷创建函数
26
- def create_engine(engine_type: str, database_name: str, **kwargs) -> BaseEngine:
27
- """
28
- 创建数据库引擎的便捷函数
29
-
30
- Args:
31
- engine_type: 引擎类型 ('spark', 'hive', 'turing')
32
- database_name: 数据库名称
33
- **kwargs: 其他参数
34
-
35
- Returns:
36
- 数据库引擎实例
37
- """
38
- engine_type = engine_type.lower()
39
-
40
- if engine_type == 'spark':
41
- return SparkEngine(database_name, **kwargs)
42
- elif engine_type == 'hive':
43
- return HiveEngine(database_name, **kwargs)
44
- elif engine_type == 'turing':
45
- if not _TURING_AVAILABLE:
46
- raise ImportError("TuringEngine不可用,请确保turingPythonLib已安装")
47
- return TuringEngine(database_name, **kwargs)
48
- else:
49
- raise ValueError(f"不支持的引擎类型: {engine_type}")
50
-
51
- # 主要导出
52
- __all__ = [
53
- 'BaseEngine',
54
- 'DatabaseType',
55
- 'SparkEngine',
56
- 'HiveEngine',
57
- 'create_engine'
58
- ]
59
-
60
- # 如果图灵引擎可用,添加到导出
61
- if _TURING_AVAILABLE:
62
- __all__.extend([
63
- 'TuringEngine',
64
- 'create_turing_engine'
65
- ])