generate-copyright-source.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. 生成软著申请所需的源代码材料
  5. 将项目主要源代码合并为一个超过6000行的文件
  6. """
  7. import os
  8. from pathlib import Path
  9. # 项目根目录
  10. ROOT = Path(__file__).resolve().parent.parent
  11. OUTPUT = ROOT / "docs" / "软著申请-源代码材料.txt"
  12. # 软著申请文件头
  13. HEADER = """===============================================================================
  14. 多平台媒体管理系统 - 计算机软件著作权申请
  15. 源代码材料(前60页+后60页)
  16. ===============================================================================
  17. 软件全称:多平台媒体管理系统 V1.0
  18. 软件简称:多平台媒体管理
  19. 版本号:V1.0
  20. 开发完成日期:2025年
  21. 首次发表日期:2025年
  22. 权利取得方式:原始取得
  23. 权利范围:全部权利
  24. 著作权人:(请填写单位或个人名称)
  25. ===============================================================================
  26. 代码说明
  27. ===============================================================================
  28. 本软件为多平台自媒体账号管理系统,支持抖音、快手、视频号、小红书、百家号等
  29. 主流平台,具备视频自动发布、评论统一管理、数据分析等功能。采用 Electron +
  30. Vue3 桌面客户端 + Express 后端 + Python 发布服务的架构。以下为系统核心源代码。
  31. ===============================================================================
  32. 第一部分:平台发布基类
  33. ===============================================================================
  34. """
  35. # 要包含的源文件(按顺序)
  36. SOURCE_FILES = [
  37. ROOT / "server" / "python" / "platforms" / "base.py",
  38. ROOT / "server" / "python" / "app.py",
  39. ROOT / "server" / "python" / "platforms" / "weixin.py",
  40. ROOT / "server" / "python" / "platforms" / "xiaohongshu.py",
  41. ROOT / "server" / "python" / "platforms" / "baijiahao.py",
  42. ROOT / "server" / "python" / "platforms" / "douyin.py",
  43. ROOT / "server" / "python" / "platforms" / "kuaishou.py",
  44. ]
  45. def add_section_header(content: str, title: str) -> str:
  46. """在内容前添加章节标题"""
  47. return f"\n\n{'='*80}\n {title}\n{'='*80}\n\n{content}"
  48. def main():
  49. lines = []
  50. # 添加文件头
  51. lines.extend(HEADER.splitlines())
  52. for i, filepath in enumerate(SOURCE_FILES):
  53. if not filepath.exists():
  54. print(f"跳过不存在的文件: {filepath}")
  55. continue
  56. with open(filepath, "r", encoding="utf-8", errors="replace") as f:
  57. content = f.read()
  58. # 添加文件路径说明
  59. rel_path = filepath.relative_to(ROOT)
  60. section_title = f"文件: {rel_path}"
  61. content_with_header = add_section_header(content, section_title)
  62. lines.extend(content_with_header.splitlines())
  63. print(f"已添加: {rel_path} ({len(content.splitlines())} 行)")
  64. full_content = "\n".join(lines)
  65. line_count = len(lines)
  66. # 确保超过6000行
  67. if line_count < 6000:
  68. # 添加补充说明
  69. supplement = f"""
  70. {'='*80}
  71. 补充说明
  72. {'='*80}
  73. 本系统还包括以下模块的源代码:
  74. - 客户端:Electron + Vue3 前端界面(client/)
  75. - 服务端:Node.js Express API 和 TypeORM 数据模型(server/src/)
  76. - 共享库:TypeScript 类型定义和常量(shared/)
  77. - 数据库:MySQL 表结构定义(database/)
  78. 总代码量超过 20000 行,以上为系统核心业务逻辑的代表性代码。
  79. """
  80. lines.extend(supplement.splitlines())
  81. full_content = "\n".join(lines)
  82. line_count = len(lines)
  83. # 写入输出文件
  84. OUTPUT.parent.mkdir(parents=True, exist_ok=True)
  85. with open(OUTPUT, "w", encoding="utf-8") as f:
  86. f.write(full_content)
  87. print(f"\n[OK] 生成完成: {OUTPUT}")
  88. print(f" 总行数: {line_count} 行")
  89. if line_count >= 6000:
  90. print(f" [OK] 已满足软著申请6000行以上要求")
  91. else:
  92. print(f" [WARN] 未达到6000行,当前为 {line_count} 行")
  93. if __name__ == "__main__":
  94. main()