A tool to extract source code for China Software Copyright application.
Project description
Copyright Code Extractor
A tool to automatically extract source code from a project into the source-program identification material (程序鉴别材料) required for a China Software Copyright (软著) registration.
It scans a project directory, finds source files by extension, strips comments and blank lines, and writes an A4 DOCX with exactly 50 code lines per page, a header carrying the software name + version, and an automatic page number — matching the CPCC (中国版权保护中心) filing requirements.
Compliance checklist
Official basis: Article 10 of the Measures for the Registration of Computer Software Copyright (《计算机软件著作权登记办法》第十条, NCAC Order No. 1) — a copy is included at docs/计算机软件著作权登记办法.pdf (source).
| CPCC requirement | How it is handled |
|---|---|
| First 30 + last 30 consecutive pages (60 pages total); submit everything if shorter | --all keeps the first/last 1500 lines automatically |
| At least 50 lines per page | Exactly 50 lines per page; long lines are hard-wrapped so pagination never drifts |
| Header shows software name + version, identical to the application form | --name / --soft-version (or config); centred in the page header |
| Page number at the top right | Word PAGE field, numbered continuously from 1 |
| No large blank areas / blank lines | Blank lines and comments are stripped |
| PDF upload | Built-in: --pdf exports a PDF next to the DOCX, or -o file.pdf for PDF only |
The header text must match the registration form character-for-character. If
--nameis omitted the project directory name is used and a warning is logged.
Installation
Quick run — no install, no clone (recommended for AI agents):
# uv downloads, caches and runs the published CLI in one step
uvx copyright-code-extractor /path/to/project --all --name "某某系统" --soft-version V1.0 --pdf -o 源代码.docx
# pipx works the same way
pipx run copyright-code-extractor --help
Standalone binaries (no Python required): download from
GitHub Releases —
linux-x86_64 / linux-arm64 / macos-arm64 / macos-x86_64 / windows-x86_64.
curl -LO https://github.com/kirklin/copyright-code-extractor/releases/latest/download/copyright-code-extractor-macos-arm64
chmod +x copyright-code-extractor-macos-arm64 && ./copyright-code-extractor-macos-arm64 --help
From source:
uv sync # development
pip install -e . # or any environment
Usage
# Typical filing: first 30 + last 30 pages, proper header, DOCX + PDF
uv run copyright-code-extractor /path/to/your/project \
--all \
--name "某某管理系统" \
--soft-version V1.0 \
--pdf \
-o 源代码.docx
Options:
-n, --name TEXT: Software name for the page header (must match the application form).--soft-version TEXT: Software version for the page header (default:V1.0).--all: Extract everything, then apply the first 30 + last 30 pages rule.--pdf: Also export a PDF next to the DOCX (embeds a system CJK font, auto-detected; override withpdf_font_pathin the config).-o, --output FILE_PATH: Output DOCX path.-l, --lines NUM_LINES: Total number of lines to extract when not using--all(default: 3000).-c, --config CONFIG_FILE: Path to a custom configuration file.-v, --verbose: Verbose logging.--version: Show the tool version and exit.
Configuration
Create a .copyright-extractor.json in the root of the project being analyzed.
Command-line options override the config file.
{
"software_name": "某某管理系统",
"software_version": "V1.0",
"output_file": "源代码.docx",
"extract_all": true,
"source_root": "src",
"ignore_patterns": ["tests", "docs", "*.min.js"],
"include_extensions": [".py", ".ts", ".tsx", ".vue", ".go"]
}
Useful defaults you can override:
lines_per_page(50),keep_pages_head/keep_pages_tail(30 / 30)max_line_width(90) — wrap display width (CJK counts as 2) that keeps one code line = one printed linepdf_font_path— TTF/TTC with CJK glyphs to embed in the PDF when auto-detection failsignore_patterns— already covers.git,node_modules,dist,build,.next,.nuxt,.output,.turbo,coverage, minified assets, etc.
See src/copyright_code_extractor/config.py for the full list.
Notes
- ~100 source extensions are extracted by default, covering every major language
family — C/C++/Java/Kotlin/Go/Rust/Swift/JS/TS/Python/C#/F#/VB/PHP/Ruby/Lua/
SQL/Haskell/OCaml/Erlang/Elixir/Fortran/Pascal/PowerShell/assembly/Verilog/VHDL
and more — each with its own comment syntax (e.g.
--for SQL,{- -}for Haskell,<# #>for PowerShell). Unknown extensions can be added viainclude_extensionsand fall back to string-aware//,#,/* */stripping. - Comment stripping is string-aware: URLs or
#fffinside string literals survive. Known limitation: an unescaped//inside a JS regex literal is treated as a comment. - The generated DOCX uses Consolas 9pt (SimSun for CJK), single spacing, A4 with 2 cm margins, widow/orphan control disabled — so 50 lines per page is exact.
License
This project is licensed under the GNU General Public License v3.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file copyright_code_extractor-0.2.0.tar.gz.
File metadata
- Download URL: copyright_code_extractor-0.2.0.tar.gz
- Upload date:
- Size: 300.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed2951149c4e47fa22321e30c392a2b4c67ead69707a3bdf61fedadc0685a7af
|
|
| MD5 |
9052caf9639c7ad1c7d745dac1dae61f
|
|
| BLAKE2b-256 |
b466ab4b3ff74a436310239cbf6c0a757ff0a0906dad355da6af5617a1f84225
|
File details
Details for the file copyright_code_extractor-0.2.0-py3-none-any.whl.
File metadata
- Download URL: copyright_code_extractor-0.2.0-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
248f703cbea537591224b2cde37e1784a2bf17a1e58bbfdc5ed8c0da574f3c80
|
|
| MD5 |
eaabdf01c4e643cd391657fb6856dbc9
|
|
| BLAKE2b-256 |
e1a26382b9e0512e8a59773960ce0c28e678c858709d5e5c1cb93bb27799e356
|