skills/ppt-station-skill/ppt_station/connectors/base.py
wangyitong a65adcc2e5 Initial commit: merged, deduplicated, and vetted skill collection
Sources: extracted from two upstream archives (skill-repo, skills-main),
merged with the following policy:

- 15 broken symlinks (pointing to /Users/jameslee/.cc-switch/skills or
  ../../.agents/skills on a foreign machine) discarded
- 3 real name collisions with identical content (ai-pair, ifind-http-api,
  zhipu-websearch) kept as one copy
- Functional overlaps deduped keeping the strongest variant:
  - docx family: kept docx (official, full toolchain) + docx-cn
    (GB/T 9704 Chinese official-document constants),
    dropped docx_writer (no scripts, name collided with docx)
  - humanizer family: kept humanizer-zh (6 zh reference docs),
    dropped humanizer (en, redundant for CN workflow)
- Skills that only ran in a foreign environment removed:
  ablemind-ops, app-publish, hlb-design-system, openclaw-adj-skill,
  claude-driver
- alphapai excluded from this public repo because its SKILL.md hard-coded
  live credentials

Result: 25 skills, 572 files, ~7.5 MB.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 14:47:12 +08:00

44 lines
1.1 KiB
Python

"""
数据连接器基类和工厂
"""
from abc import ABC, abstractmethod
from typing import Dict
import pandas as pd
from ppt_station.models.job import DataSource
class BaseConnector(ABC):
"""数据连接器基类"""
@abstractmethod
def load(self, spec: DataSource) -> pd.DataFrame:
"""加载数据并返回 DataFrame"""
pass
class ConnectorFactory:
"""连接器工厂"""
_connectors: Dict[str, type[BaseConnector]] = {}
@classmethod
def register(cls, connector_type: str, connector_class: type[BaseConnector]):
"""注册连接器"""
cls._connectors[connector_type] = connector_class
@classmethod
def create(cls, connector_type: str) -> BaseConnector:
"""创建连接器实例"""
connector_class = cls._connectors.get(connector_type)
if not connector_class:
raise ValueError(f"Unknown connector type: {connector_type}")
return connector_class()
@classmethod
def load_data(cls, name: str, spec: DataSource) -> pd.DataFrame:
"""加载数据的便捷方法"""
connector = cls.create(spec.type)
return connector.load(spec)