Skip to main content

pyerz:计算机软件著作权程序鉴别材料(即源代码)生成器

目录

安装

pip install pyerz

背景

工作中需要申请软件著作权,软件著作权需要提供以下材料:

  1. 申请表:可以在官网通过网页生成
  2. 身份证明:企业的话一般就是营业执照
  3. 程序鉴别材料:一般就是源代码整理出的PDF文件
  4. 文档鉴别材料:一般就是该软件的操作手册

申请表身份证明比较好准备,文档鉴别材料则必须手写,pyerz则用于生成程序鉴别材料。目前支持如下功能:

  1. 指定多个源代码目录
  2. 指定多中注释风格
  3. 指定字体、字号、段前间距、段后间距、行距
  4. 排除特定文件、文件夹

使用

程序鉴别材料要求

  1. 每页至少50行
  2. 不能含有注释、空行
  3. 页眉部分必须包含软件名称、版本号、页码(软件名+版本号居中,页码右侧对齐)

如何实现每页50行

上述3点,第2、3两点比较好实现,第1点我通过测试发现,当:

  1. 字号为10.5pt
  2. 行间距为10.5pt
  3. 段前间距为0
  4. 段后间距为2.3pt

时,刚好实现每页50行。

参数

Usage: pyerz [OPTIONS]

Options:
  -t, --title TEXT            软件名称+版本号,默认为软件著作权程序鉴别材料生成器V1.0,此名称用于生成页眉
  -i, --indir PATH            源码所在文件夹,可以指定多个,默认为当前目录
  -e, --ext TEXT              源代码后缀,可以指定多个,默认为Python源代码
  -c, --comment-char TEXT     注释字符串,可以指定多个,默认为#、//
  --font-name TEXT            字体,默认为宋体
  --font-size FLOAT RANGE     字号,默认为五号,即10.5号
  --space-before FLOAT RANGE  段前间距,默认为0
  --space-after FLOAT RANGE   段后间距,默认为2.3
  --line-spacing FLOAT RANGE  行距,默认为固定值10.5
  --exclude PATH              需要排除的文件或路径,可以指定多个
  -o, --outfile PATH          输出文件(docx格式),默认为当前目录的code.docx
  -v, --verbose               打印调试信息
  --help                      Show this message and exit.

示例

下面以django-guardian项目为例来说明pyerz的用法。

克隆代码

git clone git@github.com:django-guardian/django-guardian.git

生成文档

pyerz -i django-guardian -o django-guardian.docx

常见问题

如何指定页眉?

pyerz -i django-guardian -t django-guardian -o django-guardian.docx

如何添加其他格式的代码?

上述方法只能识别Python源码,如果需要识别html、css、js代码,可以指定-e参数。

pyerz -i django-guardian \
    -t django-guardian \
    -e py -e html -e js \
    -o django-guardian.docx

如何排除指定文件或文件夹?

pyerz -i django-guardian \
    -t django-guardian \
    --exclude django-guardian/contrib/ \
    --exclude django-guardian/docs/ \
    --exclude django-guardian/benchmarks/ \
    --exclude django-guardian/example_project/ \
    -o django-guardian.docx

如何调整默认的注释风格?

默认情况下,pyerz把以#、//开头的行作为注释行删除,例如我想删除以"""开头的行(Python另一种注释风格):

pyerz -i django-guardian \
    -t django-guardian \
    -c '#' -c '//' -c '"""' \
    -o django-guardian.docx

注意,pyerz目前不支持删除多行注释。

如何调整字体?

pyerz默认使用宋体,如果需要调整可以使用--font-name参数。

pyerz -i django-guardian \
    -t django-guardian \
    --font-name menlo \
    -o django-guardian.docx

虽然我知道默认的字体、字号、段前间距、段后间距、行间距可以实现每页50行,但是我还是想调整,怎么办?

pyerz -i django-guardian \
    -t django-guardian \
    --font-name menlo \
    --font-size 12 \
    --space-before 1 \
    --space-after 5 \
    --line-spacing 12 \
    -o django-guardian.docx

能不能输出查找文件的详细过程呢?

pyerz -i django-guardian -o django-guardian.docx -v
...
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/posts/templates/posts目录下找到0个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/posts/templates目录下找到0个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/posts目录下找到8个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/core/migrations目录下找到3个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/core目录下找到7个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/articles/migrations目录下找到3个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/articles/templates/articles目录下找到0个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/articles/templates目录下找到0个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/articles目录下找到10个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/static/css目录下找到0个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/static/js目录下找到0个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/static/img目录下找到0个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/static目录下找到0个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project/templates目录下找到0个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian/example_project目录下找到29个代码文件.
DEBUG:pyerz.pyerz:在/Users/dev/Temp/django-guardian目录下找到94个代码文件.

Metadata

Release files for pyerz 1.0.2

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

Source distribution (sdist)

Source distribution for pyerz 1.0.2
File Size Uploaded Provenance Actions
pyerz-1.0.2.tar.gz 8.0 kB Without provenance Details for pyerz-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyerz 1.0.2
File Interpreter ABI Platform Actions
pyerz-1.0.2-py3-none-any.whl Python 3 none any Details for pyerz-1.0.2-py3-none-any.whl

Total release size: 28.1 kB

Release files / pyerz-1.0.2.tar.gz

Download URL pyerz-1.0.2.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ca6cce97975cca456c217af51a90c39914d3ae1f4442849dfe0dc25b31b89ae9
BLAKE2b-256 checksum
How to use checksums
716aba6c671e4cf186701683ca5a39f8bf2906ac3583cda9babd9da71d3b3c44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / pyerz-1.0.2-py3-none-any.whl

Download URL pyerz-1.0.2-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1ebdd37bae7bcb701ca1751fc7ffd005623fae535fa6a0f7c4f423b62b0375c
BLAKE2b-256 checksum
How to use checksums
19456c745bfac615d9b2756bcd42442a83f68281d6e4ad28e32a56872067d8fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Security for pyerz 1.0.2

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.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

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