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.1.1

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.1.1
File Size Uploaded
xinops-1.1.1.tar.gz 46.9 kB Details

Built distribution (wheel)

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

Total release size:95.7 kB

Release files / xinops-1.1.1.tar.gz

Download URL xinops-1.1.1.tar.gz
Size 46.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ac1495ff1aabc2ca4cdf525fd313ab685c6bcb54eeb657d7ce0adec3bdecb237
BLAKE2b-256 checksum
How to use checksums
23f05d4ab7ee56047c1c799c58f64c019af5f6f731af3909a5df029ced04b08e
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.1.1-py3-none-any.whl

Download URL xinops-1.1.1-py3-none-any.whl
Size 48.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d2727587170b1281b90bff5efb2472c88f0a06455984470e5b55be7e240bb75
BLAKE2b-256 checksum
How to use checksums
8ec8ef164594a59f1ebcb33998c611a66a77f8378950f5f0a51f2e596f3de481
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

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

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