Skip to main content

ustc-tools

中国科大校园工具的可复用业务库,要求 Python 3.11+,依赖独立的 ustc-sdk。 提供二课完整扫描、差异检测、搜索、筛选、报名与取消,以及学习空间预约预览、提交前复核和取消。

安装(发布后)

uv add ustc-tools
uv add "ustc-tools[monitor]"

第二条包含可选的 APScheduler 3.x 定时监控模块。

扫描与查询

import asyncio
import os

from ustc_sdk import CASClient, YoungClient
from ustc_tools import ActivityService, SQLiteStore


async def main():
    username = os.environ["USTC_USERNAME"]
    async with CASClient(username, os.environ["USTC_PASSWORD"]) as cas:
        async with YoungClient(cas) as young, SQLiteStore("state.sqlite3") as store:
            service = ActivityService(young, store, user_id=username)
            result = await service.scan()
            print("baseline:", result.baseline)
            print("changes:", len(result.changes))
            print([activity.id for activity in await service.search("讲座")])


asyncio.run(main())

首次完整扫描建立基线。后续扫描返回结构化变化;读取失败时保留上一次完整快照。 ActivityPreferences 支持感兴趣/忽略标记、已报名过滤、固定忙时与周重复忙时。 select(predicate=...) 可接入调用方的异步内容或 AI 判断函数。

ustc_tools.spaces.SpaceService 提供空间预约预览、成员和时段校验、提交前重新读取占用及稳定标识取消。 ustc_tools.monitor.Monitor 由调用方显式启动和停止,通过异步回调返回扫描结果。

SQLite 存储位置和用户标识由应用提供。MemoryStore 用于临时脚本,ActivityStore 可替换为应用自己的存储。 公开模型使用 Pydantic;MCP、网页和机器人适配由外部应用实现。

来源与许可

GPL-3.0-only。二课工作流参考 NextArc, 空间工作流参考 xtcli。 包附带 LICENSE、LICENSE-MIT 和 NOTICE;SDK 单独采用 MIT 许可。

源码与完整文档

Metadata

Release files for ustc-tools 0.1.0

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

Source distribution (sdist)

Source distribution for ustc-tools 0.1.0
File Size Uploaded Provenance Actions
ustc_tools-0.1.0.tar.gz 29.6 kB Without provenance Details for ustc_tools-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ustc-tools 0.1.0
File Interpreter ABI Platform Actions
ustc_tools-0.1.0-py3-none-any.whl Python 3 none any Details for ustc_tools-0.1.0-py3-none-any.whl

Total release size: 60.7 kB

Release files / ustc_tools-0.1.0.tar.gz

Download URL ustc_tools-0.1.0.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e99b03868acb794b6cf9e6d34bc8cc1524f4bc44fc0896ea6f9a88109e358fa6
BLAKE2b-256 checksum
How to use checksums
937989b1f73253cce98d81d701a047fdbd7cd0b92339477dfdc89dd38ddea3ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ustc_tools-0.1.0-py3-none-any.whl

Download URL ustc_tools-0.1.0-py3-none-any.whl
Size 31.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97202c3c8ae27f04d4de7906c7477665e6ea7d43b8eead0f0b504e64a672f4f1
BLAKE2b-256 checksum
How to use checksums
688eabe56b1663e6398153879633723d38c1d2744dbe9c028c54a022eefb1630
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ustc-tools 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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