Skip to main content

xinops

营销数据运维一体化工具库(原 Functions_d + feishu_to_excel 合并重构版),Windows / Mac 通用

与旧库的关系

  • Functions_d(1.46)与 feishu_to_excel(0.0.5)保留为备份,不再更新
  • 本库为新库名下的持续维护版本,DataProcessingAndMessaging 类的方法名与 Functions_d 1.46 完全一致
  • 业务脚本迁移只需改一行 import:
# 旧写法
import Functions_d
ux = Functions_d.DataProcessingAndMessaging()

# 新写法
import xinops
ux = xinops.DataProcessingAndMessaging()

安装

pip install xinops          # 核心功能(Windows/Mac 通用)

# 可选功能按需加装:
pip install "xinops[excel_win]"   # writer_excel_data / screen(xlwings 操作本机 Excel,仅 Windows)
pip install "xinops[browser]"     # init_edge_driver(Selenium Edge 自动化)
pip install "xinops[pinyin]"      # name_to_pinyin / car_task_transfer
pip install "xinops[all]"         # 全部装上(等同旧版 Functions_d 的安装效果)

Mac 用户注意:writer_excel_data(xlwings)与 screen(Excel 截图)依赖 Windows 上的本机 Excel, Mac 上请使用跨平台的 writer_excel_data_new(openpyxl 方案,无需安装 Excel)。 xlwings/pythoncom 均为方法内延迟导入,Mac 上未安装不影响库的导入与其他功能。

密钥配置文件(必须)

本库不再在代码中硬编码任何密码。首次使用前,创建 xinops_secrets.yaml

# 企业微信消息
wecom_corpid: "wxd4e113eb4c0136b9"
wecom_corpsecret: "你的secret"
wecom_agentid: "1000026"

# 企业微信文档
wecom_doc_corpid: "wxd4e113eb4c0136b9"
wecom_doc_corpsecret: "你的secret"

# 邮件 SMTP
smtp_sender: "cc_yingxiao@xin.com"
smtp_pwd: "你的密码"
smtp_host: "smtp.exmail.qq.com"
smtp_port: 465

# Hive 连接
hive_host: "172.20.2.190"
hive_port: 10023
hive_user: "cc_yingxiao"
hive_pwd: "你的密码"

查找顺序(找到即用):

  1. 环境变量 XINOPS_CONFIG(或旧名 PYPI_KU_CONFIG)指定的路径
  2. 业务脚本所在目录及其上层目录(最多向上 3 层)——推荐放在脚本目录的上层,多台机器迁移时随脚本目录一起拷贝
  3. 用户主目录

所有配置项也支持同名环境变量覆盖(如 WECOM_CORPSECRETSMTP_PWDHIVE_PWD)。 配置文件含敏感信息,切勿提交 git、切勿放进本仓库目录(仓库 .gitignore 已加双保险)。

模块结构

模块 功能
_core.py 日志初始化、密钥配置加载、脚本生命周期、日期时间与通用工具
_wecom.py 企业微信消息 + 企微智能表格文档
_email.py 邮件发送(旧版 yagmail / 新版 smtplib 带重试)
_hive.py Hive SQL 执行(dml/dmls/dql/dqls)与错误提取
_excel.py Excel 模板写入(xlwings/openpyxl 双方案)、截图、格式化导出
_export.py Parquet / CSV 导出
_misc.py Edge 驱动、数据量检查、拼音转换、车辆任务、内网文件服务器上传
_feishu.py 飞书表格上传器 FeishuSheetUploader(原 feishu_to_excel)

使用示例

import xinops

# 主工具类(用法与 Functions_d 完全一致)
ux = xinops.DataProcessingAndMessaging()
ux.Start_Get_filepath_and_filename()

data = ux.run_sql(ux.path, "xxx.sql")
ux.writer_excel_data_new(path=ux.path, filename="muban.xlsx",
                         send_file=ux.path + "result.xlsx",
                         sheet_data=[{"data": data, "sheet_name": "明细",
                                      "clear_range": "A2:U1000000", "date_range": "A1"}],
                         headers=True)
ux.uxin_wx("dongyang", "处理完成")

# 飞书表格上传(原 feishu_to_excel 功能)
uploader = xinops.FeishuSheetUploader(app_id="cli_xxx", app_secret="xxx")
token = uploader.create_spreadsheet(title="日报")
uploader.upload_to_sheet(token, "汇总", data, start_cell="A1")

ux.End_operation()

Release files for xinops 1.0.7

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

Source distribution (sdist)

Source distribution for xinops 1.0.7
File Size Uploaded
xinops-1.0.7.tar.gz 43.7 kB Details

Built distribution (wheel)

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

Total release size:89.5 kB

Release files / xinops-1.0.7.tar.gz

Download URL xinops-1.0.7.tar.gz
Size 43.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0afc7a660a8196248d3149f024b790a084a0f68192787e3144baf5474d9c47b1
BLAKE2b-256 checksum
How to use checksums
c84b5d76e2b455ffe2134afb7403e560e65b7bf5e0a4b6422de9be676ce0536a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / xinops-1.0.7-py3-none-any.whl

Download URL xinops-1.0.7-py3-none-any.whl
Size 45.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa9606ad1e81950ce09c73ce86a2a95b68031599ebce62422de3d8d7cf497d92
BLAKE2b-256 checksum
How to use checksums
91ff6d966bc25dc56d9258c369236c59cd275c390283f69c64d883c3cd1cf21e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release history Release notifications | RSS feed

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

This release

1.0.7 This release

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

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