p2d


Namep2d JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/cn-xcpc-tools/Polygon2DOMjudge
SummarySimple python script converting polygon package to domjudge(kattis) package
upload_time2024-10-15 16:04:56
maintainercubercsl
docs_urlNone
authorcubercsl
requires_python<4.0,>=3.9
licenseMIT
keywords polygon domjudge kattis codeforces
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Polygon2DOMjudge

[![Test][gh-test-badge]][gh-test]
[![GitHub release][gh-release-badge]][gh-release]

[中文](README.cn.md)

## What is this

It is a simple python script converting polygon package to DOMjudge (kattis) package.

## Install

### From PyPI (stable release, has been used in some contests)

```bash
pipx install p2d
```

### From source (latest version, under development with new features)

```bash
pipx install git+https://github.com/cn-xcpc-tools/Polygon2DOMjudge
```

## CLI Example

First, you should build **full** package from Polygon and download the **Linux** package to your local.

> [!WARNING]
> If you download the standard package and then run `doall.sh` to build the full package by yourself, the linebreaks will be CRLF.
> Make sure you convert the linebreaks to LF before running the script because DOMjudge is running on Linux.

```bash
# Download the full package from Polygon to /path/to/polygon-package.zip
$ p2d --code A --color "#FF0000" -o /path/to/domjudge-package.zip /path/to/polygon-package.zip
```

Run this command to make a package from `/path/to/polygon-package.zip` to `/path/to/domjudge-package.zip` and set `code` and `color`.

You can omit the output path, and the default output path will be in the current working directory and named as `{{ code }}.zip`.

All available parameters are:

- `--code`: problem short name in DOMjudge contest.
- `--color`: problem color in DOMjudge.
- `--default`: force use the default output validator.
- `--validator-flags`: add some flags to the output validator, only works when `--default` is set.
- `--auto`: use the default output validator if the checker is defined in config and can be replaced by the default one.
- `--memory-limit`: override the memory limit for DOMjudge package (in MB), default is using the memory limit defined in polygon package.
- `--output-limit`: override the output limit for DOMjudge package (in MB), default is using the default output limit in DOMjudge setting.
- `--hide-sample`: hide the sample input and output from the problem statement, no sample data will be available for the contestants (force True if this is an interactive problem).
    When this is not set to True and the sample output is different from the main and correct solution (usually both are correct answers),
    the sample output will be replaced with the one shipped with problem statement.
    But the sample input will not be replaced because DOMjudge does not support different sample input from the one downloaded.
- `--external-id`: specify the external id of the problem in DOMjudge, default is using the problem short-name in polygon.
- `--with-statement`: include the pdf statement in the DOMjudge package.
- `--with-attachments`: include attachments (e.g. local testing tools for interactive problem) in the DOMjudge package.
- `--testset`: specify the testset to convert, must specify the testset name if the problem has multiple testsets.

### Convert the whole contest

You can use `p2d-contest` to get a script to convert all problems in a contest.

```bash
# Download the contest.xml from Polygon first
$ p2d-contest /path/to/contest.xml > convert.sh
```

## Config

In [config.toml](./p2d/asset/config.toml), you can change some special checker's validator's flags, which will be used to replace the checker with the default output validator when `--auto` is set.

> [!NOTE]
> You should not edit this file directly, instead, you should create a new file named `config.toml` or something else and pass it to the script with `--config` parameter. The script will merge the default config with your config.

## Environment Variable

Don't change them unless you know what you are doing.

- `CONFIG_PATH`
- `TESTLIB_PATH`

## API Example

> [!WARNING]
> The API is not stable and may change in the future.

This is an example to convert all problems in a contest defined in [`problems.yaml`](https://ccs-specs.icpc.io/draft/contest_package#problemsyaml) to DOMjudge package.

```python
import yaml
from pathlib import Path

from p2d import convert

polygon = Path('/path/to/polygon-packages')
domjudge = Path('/path/to/domjudge-packages')

with open(domjudge / 'problems.yaml') as f:
    problems = yaml.safe_load(f)

for problem in problems:
    prob_id = problem['id']
    convert(
        polygon / f'{prob_id}.zip',
        domjudge / f'{prob_id}.zip',
        short_name=problem['label'],
        color=problem['rgb'],
    )
```

## Known Issues

- For interactive problems, you must validate the output in the interactors, because DOMjudge cannot handle `tout` stream like Polygon.
- For multi-pass problems, you may need to call `tout.open(make_new_file_in_a_dir(argv[3], "nextpass.in"))` to get the next pass input file when there exists a next pass.

## Development

```bash
# install
poetry install

# build
poetry build

# run unittest
poetry run pytest

# release
./release.sh ${your version}
```

[gh-test-badge]: https://github.com/cn-xcpc-tools/Polygon2DOMjudge/actions/workflows/test.yml/badge.svg
[gh-test]: https://github.com/cn-xcpc-tools/Polygon2DOMjudge/actions/workflows/test.yml
[gh-release-badge]: https://img.shields.io/github/release/cn-xcpc-tools/Polygon2DOMjudge.svg
[gh-release]: https://GitHub.com/cn-xcpc-tools/Polygon2DOMjudge/releases/

# Polygon2DOMjudge

[![Test][gh-test-badge]][gh-test]
[![GitHub release][gh-release-badge]][gh-release]

## 这是什么

这是一个简单的将 polygon 题目包转换成 DOMjudge (kattis) 题目包的 python 脚本。

## 安装

### 从 PyPI(稳定版本, 已经在一些比赛中使用过)

```bash
pipx install p2d
```

### 从源码(最新版本,正在开发中,有新的特性)

```bash
pipx install git+https://github.com/cn-xcpc-tools/Polygon2DOMjudge
```

## 命令行使用示例

首先,你需要从 Polygon 构建 **完整的** 题目包并将 **Linux** 题目包下载到本地。

> [!WARNING]
> 如果你下载了标准的题目包并且运行 `doall.sh` 来构建完整的题目包,那么换行符将会是 CRLF。
> 在运行脚本之前,请确保将换行符转换为 LF,因为 DOMjudge 是在 Linux 上运行的。

```bash
# 首先从 Polygon 下载完整的 Linux 题目包到本地
$ ./bin/p2d --code A --color "#FF0000" -o /path/to/domjudge-package.zip /path/to/polygon-package.zip
```

运行此命令可以从 `/path/to/polygon-package.zip` 处题目包转换为 `/path/to/domjudge-package.zip`,并设置  `code` 和 `color` 属性。

你可以省略输出路径,输出路径将会在当前工作目录中,并命名为 `{{ code }}.zip`。

所有可用的命令行参数如下:

- `--code`: 题目在 DOMjudge 比赛中的 short name。
- `--color`: 题目在 DOMjudge 中的颜色。
- `--default`: 强制使用 DOMjudge 默认的输出校验器。
- `--validator-flags`: 为输出校验器添加一些命令行参数,仅在 `--default` 被设置时生效。
- `--auto`: 自动使用 DOMjudge 默认的输出校验器,即如果 checker 在配置文件中被定义,则使用默认的输出校验器与合适的命令行参数替代。
- `--memory-limit`: 覆盖 DOMjudge 题目包的内存限制,如果不设置,则使用 Polygon 题目包中的内存限制。
- `--output-limit`: 覆盖 DOMjudge 题目包的输出限制,如果不设置,则使用 DOMjudge 设置中默认的输出限制。
- `--hide-sample`: 隐藏题面中的样例输入输出,不会为选手提供样例数据(如果是交互题,则此参数强制为 True)。
    当此参数不设置为 True 且样例输出与标程的输出不同时 (通常两者都是符合要求的答案),
    样例输出将会被替换为题面中提供的样例输出。但是样例输入不会被替换,因为 DOMjudge 不支持下载的样例输入与实际使用的不同。
- `--external-id`: 指定题目在 DOMjudge 中的 external id,如果不设置,则使用 Polygon 中的题目 short-name。
- `--with-statement`: 在 DOMjudge 题目包中包含 pdf 题面。
- `--with-attachments`: 在 DOMjudge 题目包中包含附件(例如交互题的本地测试工具)。
- `--testset`: 指定要转换的测试点集,如果题目有多个测试点集,则必须指定测试点集的名称。

### 转换整个比赛

你可以使用 `p2d-contest` 来获取一个脚本来转换整个比赛中的题目。

```bash
# 首先从 Polygon 下载 contest.xml
$ ./bin/p2d-contest /path/to/contest.xml > convert.sh
```

## 配置

在 [config.toml](./p2d/asset/config.toml) 文件中,你可以设置一些特殊的 checker 的输出校验器参数,这会在 `--auto` 参数被设置时用来将 checker 替换为默认的输出校验器。

> [!NOTE]
> 你不应该直接编辑这个文件,而是应该创建一个新的文件,命名为 `config.toml` 或其他名称,并使用 `--config` 参数将其传递给脚本。脚本将会合并默认配置和你的配置。

## 环境变量

某些时候可能会有用。但如果你不知道你在干啥,请不要随便修改。

- `CONFIG_PATH`
- `TESTLIB_PATH`

## API 使用示例

> [!WARNING]
> API 不是稳定的,可能会在未来的版本中发生变化。

这是一个将 [`problems.yaml`](https://ccs-specs.icpc.io/draft/contest_package#problemsyaml) 中定义的比赛中的所有题目转换为 DOMjudge 题目包的示例。

```python
import yaml
from pathlib import Path

from p2d import convert

polygon = Path('/path/to/polygon-packages')
domjudge = Path('/path/to/domjudge-packages')

with open(domjudge / 'problems.yaml') as f:
    problems = yaml.safe_load(f)

for problem in problems:
    prob_id = problem['id']
    convert(
        polygon / f'{prob_id}.zip',
        domjudge / f'{prob_id}.zip',
        short_name=problem['label'],
        color=problem['rgb'],
    )
```

## 开发

```bash
# install
poetry install

# build
poetry build

# run unittest
poetry run pytest

# release
./release.sh ${your version}
```

[gh-test-badge]: https://github.com/cn-xcpc-tools/Polygon2DOMjudge/actions/workflows/test.yml/badge.svg
[gh-test]: https://github.com/cn-xcpc-tools/Polygon2DOMjudge/actions/workflows/test.yml
[gh-release-badge]: https://img.shields.io/github/release/cn-xcpc-tools/Polygon2DOMjudge.svg
[gh-release]: https://GitHub.com/cn-xcpc-tools/Polygon2DOMjudge/releases/


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cn-xcpc-tools/Polygon2DOMjudge",
    "name": "p2d",
    "maintainer": "cubercsl",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": "hi@cubercsl.site",
    "keywords": "Polygon, DOMjudge, Kattis, Codeforces",
    "author": "cubercsl",
    "author_email": "hi@cubercsl.site",
    "download_url": "https://files.pythonhosted.org/packages/90/db/a5dee074fc7a0f95569fe8e9d6340b041abbdeb82017fda7c92a250fe371/p2d-0.3.0.tar.gz",
    "platform": null,
    "description": "# Polygon2DOMjudge\n\n[![Test][gh-test-badge]][gh-test]\n[![GitHub release][gh-release-badge]][gh-release]\n\n[\u4e2d\u6587](README.cn.md)\n\n## What is this\n\nIt is a simple python script converting polygon package to DOMjudge (kattis) package.\n\n## Install\n\n### From PyPI (stable release, has been used in some contests)\n\n```bash\npipx install p2d\n```\n\n### From source (latest version, under development with new features)\n\n```bash\npipx install git+https://github.com/cn-xcpc-tools/Polygon2DOMjudge\n```\n\n## CLI Example\n\nFirst, you should build **full** package from Polygon and download the **Linux** package to your local.\n\n> [!WARNING]\n> If you download the standard package and then run `doall.sh` to build the full package by yourself, the linebreaks will be CRLF.\n> Make sure you convert the linebreaks to LF before running the script because DOMjudge is running on Linux.\n\n```bash\n# Download the full package from Polygon to /path/to/polygon-package.zip\n$ p2d --code A --color \"#FF0000\" -o /path/to/domjudge-package.zip /path/to/polygon-package.zip\n```\n\nRun this command to make a package from `/path/to/polygon-package.zip` to `/path/to/domjudge-package.zip` and set `code` and `color`.\n\nYou can omit the output path, and the default output path will be in the current working directory and named as `{{ code }}.zip`.\n\nAll available parameters are:\n\n- `--code`: problem short name in DOMjudge contest.\n- `--color`: problem color in DOMjudge.\n- `--default`: force use the default output validator.\n- `--validator-flags`: add some flags to the output validator, only works when `--default` is set.\n- `--auto`: use the default output validator if the checker is defined in config and can be replaced by the default one.\n- `--memory-limit`: override the memory limit for DOMjudge package (in MB), default is using the memory limit defined in polygon package.\n- `--output-limit`: override the output limit for DOMjudge package (in MB), default is using the default output limit in DOMjudge setting.\n- `--hide-sample`: hide the sample input and output from the problem statement, no sample data will be available for the contestants (force True if this is an interactive problem).\n    When this is not set to True and the sample output is different from the main and correct solution (usually both are correct answers),\n    the sample output will be replaced with the one shipped with problem statement.\n    But the sample input will not be replaced because DOMjudge does not support different sample input from the one downloaded.\n- `--external-id`: specify the external id of the problem in DOMjudge, default is using the problem short-name in polygon.\n- `--with-statement`: include the pdf statement in the DOMjudge package.\n- `--with-attachments`: include attachments (e.g. local testing tools for interactive problem) in the DOMjudge package.\n- `--testset`: specify the testset to convert, must specify the testset name if the problem has multiple testsets.\n\n### Convert the whole contest\n\nYou can use `p2d-contest` to get a script to convert all problems in a contest.\n\n```bash\n# Download the contest.xml from Polygon first\n$ p2d-contest /path/to/contest.xml > convert.sh\n```\n\n## Config\n\nIn [config.toml](./p2d/asset/config.toml), you can change some special checker's validator's flags, which will be used to replace the checker with the default output validator when `--auto` is set.\n\n> [!NOTE]\n> You should not edit this file directly, instead, you should create a new file named `config.toml` or something else and pass it to the script with `--config` parameter. The script will merge the default config with your config.\n\n## Environment Variable\n\nDon't change them unless you know what you are doing.\n\n- `CONFIG_PATH`\n- `TESTLIB_PATH`\n\n## API Example\n\n> [!WARNING]\n> The API is not stable and may change in the future.\n\nThis is an example to convert all problems in a contest defined in [`problems.yaml`](https://ccs-specs.icpc.io/draft/contest_package#problemsyaml) to DOMjudge package.\n\n```python\nimport yaml\nfrom pathlib import Path\n\nfrom p2d import convert\n\npolygon = Path('/path/to/polygon-packages')\ndomjudge = Path('/path/to/domjudge-packages')\n\nwith open(domjudge / 'problems.yaml') as f:\n    problems = yaml.safe_load(f)\n\nfor problem in problems:\n    prob_id = problem['id']\n    convert(\n        polygon / f'{prob_id}.zip',\n        domjudge / f'{prob_id}.zip',\n        short_name=problem['label'],\n        color=problem['rgb'],\n    )\n```\n\n## Known Issues\n\n- For interactive problems, you must validate the output in the interactors, because DOMjudge cannot handle `tout` stream like Polygon.\n- For multi-pass problems, you may need to call `tout.open(make_new_file_in_a_dir(argv[3], \"nextpass.in\"))` to get the next pass input file when there exists a next pass.\n\n## Development\n\n```bash\n# install\npoetry install\n\n# build\npoetry build\n\n# run unittest\npoetry run pytest\n\n# release\n./release.sh ${your version}\n```\n\n[gh-test-badge]: https://github.com/cn-xcpc-tools/Polygon2DOMjudge/actions/workflows/test.yml/badge.svg\n[gh-test]: https://github.com/cn-xcpc-tools/Polygon2DOMjudge/actions/workflows/test.yml\n[gh-release-badge]: https://img.shields.io/github/release/cn-xcpc-tools/Polygon2DOMjudge.svg\n[gh-release]: https://GitHub.com/cn-xcpc-tools/Polygon2DOMjudge/releases/\n\n# Polygon2DOMjudge\n\n[![Test][gh-test-badge]][gh-test]\n[![GitHub release][gh-release-badge]][gh-release]\n\n## \u8fd9\u662f\u4ec0\u4e48\n\n\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5c06 polygon \u9898\u76ee\u5305\u8f6c\u6362\u6210 DOMjudge (kattis) \u9898\u76ee\u5305\u7684 python \u811a\u672c\u3002\n\n## \u5b89\u88c5\n\n### \u4ece PyPI\uff08\u7a33\u5b9a\u7248\u672c, \u5df2\u7ecf\u5728\u4e00\u4e9b\u6bd4\u8d5b\u4e2d\u4f7f\u7528\u8fc7\uff09\n\n```bash\npipx install p2d\n```\n\n### \u4ece\u6e90\u7801\uff08\u6700\u65b0\u7248\u672c\uff0c\u6b63\u5728\u5f00\u53d1\u4e2d\uff0c\u6709\u65b0\u7684\u7279\u6027\uff09\n\n```bash\npipx install git+https://github.com/cn-xcpc-tools/Polygon2DOMjudge\n```\n\n## \u547d\u4ee4\u884c\u4f7f\u7528\u793a\u4f8b\n\n\u9996\u5148\uff0c\u4f60\u9700\u8981\u4ece Polygon \u6784\u5efa **\u5b8c\u6574\u7684** \u9898\u76ee\u5305\u5e76\u5c06 **Linux** \u9898\u76ee\u5305\u4e0b\u8f7d\u5230\u672c\u5730\u3002\n\n> [!WARNING]\n> \u5982\u679c\u4f60\u4e0b\u8f7d\u4e86\u6807\u51c6\u7684\u9898\u76ee\u5305\u5e76\u4e14\u8fd0\u884c `doall.sh` \u6765\u6784\u5efa\u5b8c\u6574\u7684\u9898\u76ee\u5305\uff0c\u90a3\u4e48\u6362\u884c\u7b26\u5c06\u4f1a\u662f CRLF\u3002\n> \u5728\u8fd0\u884c\u811a\u672c\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5c06\u6362\u884c\u7b26\u8f6c\u6362\u4e3a LF\uff0c\u56e0\u4e3a DOMjudge \u662f\u5728 Linux \u4e0a\u8fd0\u884c\u7684\u3002\n\n```bash\n# \u9996\u5148\u4ece Polygon \u4e0b\u8f7d\u5b8c\u6574\u7684 Linux \u9898\u76ee\u5305\u5230\u672c\u5730\n$ ./bin/p2d --code A --color \"#FF0000\" -o /path/to/domjudge-package.zip /path/to/polygon-package.zip\n```\n\n\u8fd0\u884c\u6b64\u547d\u4ee4\u53ef\u4ee5\u4ece `/path/to/polygon-package.zip` \u5904\u9898\u76ee\u5305\u8f6c\u6362\u4e3a `/path/to/domjudge-package.zip`\uff0c\u5e76\u8bbe\u7f6e  `code` \u548c `color` \u5c5e\u6027\u3002\n\n\u4f60\u53ef\u4ee5\u7701\u7565\u8f93\u51fa\u8def\u5f84\uff0c\u8f93\u51fa\u8def\u5f84\u5c06\u4f1a\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\uff0c\u5e76\u547d\u540d\u4e3a `{{ code }}.zip`\u3002\n\n\u6240\u6709\u53ef\u7528\u7684\u547d\u4ee4\u884c\u53c2\u6570\u5982\u4e0b\uff1a\n\n- `--code`: \u9898\u76ee\u5728 DOMjudge \u6bd4\u8d5b\u4e2d\u7684 short name\u3002\n- `--color`: \u9898\u76ee\u5728 DOMjudge \u4e2d\u7684\u989c\u8272\u3002\n- `--default`: \u5f3a\u5236\u4f7f\u7528 DOMjudge \u9ed8\u8ba4\u7684\u8f93\u51fa\u6821\u9a8c\u5668\u3002\n- `--validator-flags`: \u4e3a\u8f93\u51fa\u6821\u9a8c\u5668\u6dfb\u52a0\u4e00\u4e9b\u547d\u4ee4\u884c\u53c2\u6570\uff0c\u4ec5\u5728 `--default` \u88ab\u8bbe\u7f6e\u65f6\u751f\u6548\u3002\n- `--auto`: \u81ea\u52a8\u4f7f\u7528 DOMjudge \u9ed8\u8ba4\u7684\u8f93\u51fa\u6821\u9a8c\u5668\uff0c\u5373\u5982\u679c checker \u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u88ab\u5b9a\u4e49\uff0c\u5219\u4f7f\u7528\u9ed8\u8ba4\u7684\u8f93\u51fa\u6821\u9a8c\u5668\u4e0e\u5408\u9002\u7684\u547d\u4ee4\u884c\u53c2\u6570\u66ff\u4ee3\u3002\n- `--memory-limit`: \u8986\u76d6 DOMjudge \u9898\u76ee\u5305\u7684\u5185\u5b58\u9650\u5236\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6e\uff0c\u5219\u4f7f\u7528 Polygon \u9898\u76ee\u5305\u4e2d\u7684\u5185\u5b58\u9650\u5236\u3002\n- `--output-limit`: \u8986\u76d6 DOMjudge \u9898\u76ee\u5305\u7684\u8f93\u51fa\u9650\u5236\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6e\uff0c\u5219\u4f7f\u7528 DOMjudge \u8bbe\u7f6e\u4e2d\u9ed8\u8ba4\u7684\u8f93\u51fa\u9650\u5236\u3002\n- `--hide-sample`: \u9690\u85cf\u9898\u9762\u4e2d\u7684\u6837\u4f8b\u8f93\u5165\u8f93\u51fa\uff0c\u4e0d\u4f1a\u4e3a\u9009\u624b\u63d0\u4f9b\u6837\u4f8b\u6570\u636e\uff08\u5982\u679c\u662f\u4ea4\u4e92\u9898\uff0c\u5219\u6b64\u53c2\u6570\u5f3a\u5236\u4e3a True\uff09\u3002\n    \u5f53\u6b64\u53c2\u6570\u4e0d\u8bbe\u7f6e\u4e3a True \u4e14\u6837\u4f8b\u8f93\u51fa\u4e0e\u6807\u7a0b\u7684\u8f93\u51fa\u4e0d\u540c\u65f6 \uff08\u901a\u5e38\u4e24\u8005\u90fd\u662f\u7b26\u5408\u8981\u6c42\u7684\u7b54\u6848\uff09\uff0c\n    \u6837\u4f8b\u8f93\u51fa\u5c06\u4f1a\u88ab\u66ff\u6362\u4e3a\u9898\u9762\u4e2d\u63d0\u4f9b\u7684\u6837\u4f8b\u8f93\u51fa\u3002\u4f46\u662f\u6837\u4f8b\u8f93\u5165\u4e0d\u4f1a\u88ab\u66ff\u6362\uff0c\u56e0\u4e3a DOMjudge \u4e0d\u652f\u6301\u4e0b\u8f7d\u7684\u6837\u4f8b\u8f93\u5165\u4e0e\u5b9e\u9645\u4f7f\u7528\u7684\u4e0d\u540c\u3002\n- `--external-id`: \u6307\u5b9a\u9898\u76ee\u5728 DOMjudge \u4e2d\u7684 external id\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6e\uff0c\u5219\u4f7f\u7528 Polygon \u4e2d\u7684\u9898\u76ee short-name\u3002\n- `--with-statement`: \u5728 DOMjudge \u9898\u76ee\u5305\u4e2d\u5305\u542b pdf \u9898\u9762\u3002\n- `--with-attachments`: \u5728 DOMjudge \u9898\u76ee\u5305\u4e2d\u5305\u542b\u9644\u4ef6\uff08\u4f8b\u5982\u4ea4\u4e92\u9898\u7684\u672c\u5730\u6d4b\u8bd5\u5de5\u5177\uff09\u3002\n- `--testset`: \u6307\u5b9a\u8981\u8f6c\u6362\u7684\u6d4b\u8bd5\u70b9\u96c6\uff0c\u5982\u679c\u9898\u76ee\u6709\u591a\u4e2a\u6d4b\u8bd5\u70b9\u96c6\uff0c\u5219\u5fc5\u987b\u6307\u5b9a\u6d4b\u8bd5\u70b9\u96c6\u7684\u540d\u79f0\u3002\n\n### \u8f6c\u6362\u6574\u4e2a\u6bd4\u8d5b\n\n\u4f60\u53ef\u4ee5\u4f7f\u7528 `p2d-contest` \u6765\u83b7\u53d6\u4e00\u4e2a\u811a\u672c\u6765\u8f6c\u6362\u6574\u4e2a\u6bd4\u8d5b\u4e2d\u7684\u9898\u76ee\u3002\n\n```bash\n# \u9996\u5148\u4ece Polygon \u4e0b\u8f7d contest.xml\n$ ./bin/p2d-contest /path/to/contest.xml > convert.sh\n```\n\n## \u914d\u7f6e\n\n\u5728 [config.toml](./p2d/asset/config.toml) \u6587\u4ef6\u4e2d\uff0c\u4f60\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e9b\u7279\u6b8a\u7684 checker \u7684\u8f93\u51fa\u6821\u9a8c\u5668\u53c2\u6570\uff0c\u8fd9\u4f1a\u5728 `--auto` \u53c2\u6570\u88ab\u8bbe\u7f6e\u65f6\u7528\u6765\u5c06 checker \u66ff\u6362\u4e3a\u9ed8\u8ba4\u7684\u8f93\u51fa\u6821\u9a8c\u5668\u3002\n\n> [!NOTE]\n> \u4f60\u4e0d\u5e94\u8be5\u76f4\u63a5\u7f16\u8f91\u8fd9\u4e2a\u6587\u4ef6\uff0c\u800c\u662f\u5e94\u8be5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\uff0c\u547d\u540d\u4e3a `config.toml` \u6216\u5176\u4ed6\u540d\u79f0\uff0c\u5e76\u4f7f\u7528 `--config` \u53c2\u6570\u5c06\u5176\u4f20\u9012\u7ed9\u811a\u672c\u3002\u811a\u672c\u5c06\u4f1a\u5408\u5e76\u9ed8\u8ba4\u914d\u7f6e\u548c\u4f60\u7684\u914d\u7f6e\u3002\n\n## \u73af\u5883\u53d8\u91cf\n\n\u67d0\u4e9b\u65f6\u5019\u53ef\u80fd\u4f1a\u6709\u7528\u3002\u4f46\u5982\u679c\u4f60\u4e0d\u77e5\u9053\u4f60\u5728\u5e72\u5565\uff0c\u8bf7\u4e0d\u8981\u968f\u4fbf\u4fee\u6539\u3002\n\n- `CONFIG_PATH`\n- `TESTLIB_PATH`\n\n## API \u4f7f\u7528\u793a\u4f8b\n\n> [!WARNING]\n> API \u4e0d\u662f\u7a33\u5b9a\u7684\uff0c\u53ef\u80fd\u4f1a\u5728\u672a\u6765\u7684\u7248\u672c\u4e2d\u53d1\u751f\u53d8\u5316\u3002\n\n\u8fd9\u662f\u4e00\u4e2a\u5c06 [`problems.yaml`](https://ccs-specs.icpc.io/draft/contest_package#problemsyaml) \u4e2d\u5b9a\u4e49\u7684\u6bd4\u8d5b\u4e2d\u7684\u6240\u6709\u9898\u76ee\u8f6c\u6362\u4e3a DOMjudge \u9898\u76ee\u5305\u7684\u793a\u4f8b\u3002\n\n```python\nimport yaml\nfrom pathlib import Path\n\nfrom p2d import convert\n\npolygon = Path('/path/to/polygon-packages')\ndomjudge = Path('/path/to/domjudge-packages')\n\nwith open(domjudge / 'problems.yaml') as f:\n    problems = yaml.safe_load(f)\n\nfor problem in problems:\n    prob_id = problem['id']\n    convert(\n        polygon / f'{prob_id}.zip',\n        domjudge / f'{prob_id}.zip',\n        short_name=problem['label'],\n        color=problem['rgb'],\n    )\n```\n\n## \u5f00\u53d1\n\n```bash\n# install\npoetry install\n\n# build\npoetry build\n\n# run unittest\npoetry run pytest\n\n# release\n./release.sh ${your version}\n```\n\n[gh-test-badge]: https://github.com/cn-xcpc-tools/Polygon2DOMjudge/actions/workflows/test.yml/badge.svg\n[gh-test]: https://github.com/cn-xcpc-tools/Polygon2DOMjudge/actions/workflows/test.yml\n[gh-release-badge]: https://img.shields.io/github/release/cn-xcpc-tools/Polygon2DOMjudge.svg\n[gh-release]: https://GitHub.com/cn-xcpc-tools/Polygon2DOMjudge/releases/\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple python script converting polygon package to domjudge(kattis) package",
    "version": "0.3.0",
    "project_urls": {
        "Documentation": "https://github.com/cn-xcpc-tools/Polygon2DOMjudge",
        "Homepage": "https://github.com/cn-xcpc-tools/Polygon2DOMjudge",
        "Repository": "https://github.com/cn-xcpc-tools/Polygon2DOMjudge"
    },
    "split_keywords": [
        "polygon",
        " domjudge",
        " kattis",
        " codeforces"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b570f0454ba7e3db026b6519407122c88ad2f80d33ea22e4c396a3e51597b8b8",
                "md5": "4016c706d579a9c5d0600e244b047d0b",
                "sha256": "ba1d0753577645c6468817a91aaba58999713b9ab878d4a9a8938aec907524a4"
            },
            "downloads": -1,
            "filename": "p2d-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4016c706d579a9c5d0600e244b047d0b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 61330,
            "upload_time": "2024-10-15T16:04:55",
            "upload_time_iso_8601": "2024-10-15T16:04:55.046402Z",
            "url": "https://files.pythonhosted.org/packages/b5/70/f0454ba7e3db026b6519407122c88ad2f80d33ea22e4c396a3e51597b8b8/p2d-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90dba5dee074fc7a0f95569fe8e9d6340b041abbdeb82017fda7c92a250fe371",
                "md5": "6565e1093fe66cb9d540e490e151209e",
                "sha256": "d73864e678d175b7976e50f87afc5f9e84570835d50205490ed557bb0b21976c"
            },
            "downloads": -1,
            "filename": "p2d-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6565e1093fe66cb9d540e490e151209e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 60809,
            "upload_time": "2024-10-15T16:04:56",
            "upload_time_iso_8601": "2024-10-15T16:04:56.418950Z",
            "url": "https://files.pythonhosted.org/packages/90/db/a5dee074fc7a0f95569fe8e9d6340b041abbdeb82017fda7c92a250fe371/p2d-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-15 16:04:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cn-xcpc-tools",
    "github_project": "Polygon2DOMjudge",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "p2d"
}
        
Elapsed time: 0.34283s