35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
"""Self-contained archive exporter inputs for the Windows build."""
|
|
import argparse
|
|
import ast
|
|
import os
|
|
from pathlib import Path
|
|
|
|
EXPORTER_FILES = (
|
|
"wxwork_export_final.py", "wxwork_export_media.py",
|
|
"wxwork_voice2text.py", "wxwork_crypto.py",
|
|
)
|
|
|
|
|
|
def exporter_data_files(project_root: Path, override: str | None = None) -> list[tuple[str, str]]:
|
|
if override is None:
|
|
override = os.environ.get("WECOM_BUILD_EXPORTER_DIR", "")
|
|
root = Path(override.strip()).expanduser().resolve() if override.strip() else Path(project_root).resolve() / "archive_exporter"
|
|
files = [root / name for name in EXPORTER_FILES]
|
|
missing = [str(path) for path in files if not path.is_file()]
|
|
if missing:
|
|
raise FileNotFoundError(
|
|
"Archive exporter source missing: " + ", ".join(missing)
|
|
+ ". Restore the project's archive_exporter directory, or correct WECOM_BUILD_EXPORTER_DIR."
|
|
)
|
|
for path in files:
|
|
ast.parse(path.read_text(encoding="utf-8-sig"), filename=str(path))
|
|
return [(str(path), "archive_exporter") for path in files]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--project-root", type=Path, default=Path(__file__).resolve().parent)
|
|
args = parser.parse_args()
|
|
for source, destination in exporter_data_files(args.project_root):
|
|
print(f"Archive source verified: {source} -> {destination}")
|