Simple python script converting polygon package to domjudge(kattis) package
Project description
Polygon2DOMjudge
What is this
It is a simple python script converting polygon package to DOMjudge (kattis) package.
Install
pip install p2d
CLI Example
# Unzip your polygon-package to /path/to/polygon-package first
$ p2d --code A --color FF0000 -o /path/to/domjudge-package /path/to/polygon-package
Run this command to make a package from /path/to/polygon-package
to /path/to/domjudge-package.zip
and set code
and color
.
All available parameters are:
--code
: problem short name in DOMjudge.--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.--replace-sample
: replace the sample input and output with the one shipped with problem statement (e.g. prevent the sample output is different from the main and correct solution).--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).
Config
In 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 namedconfig.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
EXTENSION_FOR_DESC
API Example
import tempfile
from p2d import Polygon2DOMjudge
package_dir = '/path/to/polygon-package'
output_file = '/path/to/domjudge-package' # without '.zip' suffix
with tempfile.TemporaryDirectory() as temp_dir:
try:
Polygon2DOMjudge(package_dir, temp_dir, output_file).process()
except Exception as e:
# do something
pass
Development
# install
poetry install
# build
poetry build
# run unittest
poetry run pytest
# release
./release.sh ${your version}
Polygon2DOMjudge
这是什么
这是一个简单的将 polygon 题目包转换成 DOMjudge (kattis) 题目包的 python 脚本。
安装
pip install p2d -i https://pypi.tuna.tsinghua.edu.cn/simple/
命令行使用示例
# 首先把你的 polygon-package 解压到 /path/to/polygon-package 位置
$ ./bin/p2d --code A --color FF0000 -o /path/to/domjudge-package /path/to/polygon-package
运行此命令可以从 /path/to/polygon-package
处的转换题目包为 /path/to/domjudge-package.zip
,并设置 code
和 color
属性。
所有可用的命令行参数如下:
--code
: 题目在 DOMjudge 中的 short name。--color
: 题目在 DOMjudge 中的颜色。--default
: 强制使用 DOMjudge 默认的输出校验器。--validator-flags
: 为输出校验器添加一些命令行参数,仅在--default
被设置时生效。--auto
: 自动使用 DOMjudge 默认的输出校验器,即如果 checker 在配置文件中被定义,则使用默认的输出校验器与合适的命令行参数替代。--memory-limit
: 覆盖 DOMjudge 题目包的内存限制,如果不设置,则使用 Polygon 题目包中的内存限制。--output-limit
: 覆盖 DOMjudge 题目包的输出限制,如果不设置,则使用 DOMjudge 设置中默认的输出限制。--replace-sample
: 替换样例输入输出,如果样例输入输出与题面中的样例输入输出不同,则使用题面中的样例输入输出替换(例如防止样例输出与正确解答的输出不同)。--hide-sample
: 隐藏题面中的样例输入输出,不会为选手提供样例数据(如果是交互题,则此参数强制为 True)。
配置
在 config.toml 文件中,你可以设置一些特殊的 checker 的输出校验器参数,这会在 --auto
参数被设置时用来将 checker 替换为默认的输出校验器。
[!NOTE]
你不应该直接编辑这个文件,而是应该创建一个新的文件,命名为config.toml
或其他名称,并使用--config
参数将其传递给脚本。脚本将会合并默认配置和你的配置。
环境变量
某些时候可能会有用。但如果你不知道你在干啥,请不要随便修改。
CONFIG_PATH
TESTLIB_PATH
EXTENSION_FOR_DESC
API 使用示例
import tempfile
from p2d import Polygon2DOMjudge
package_dir = '/path/to/polygon-package'
output_file = '/path/to/domjudge-package' # without '.zip' suffix
with tempfile.TemporaryDirectory() as temp_dir:
try:
Polygon2DOMjudge(package_dir, temp_dir, output_file).process()
except Exception as e:
# do something
pass
开发
# install
poetry install
# build
poetry build
# run unittest
poetry run pytest
# release
./release.sh ${your version}
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
File details
Details for the file p2d-0.2.0.tar.gz
.
File metadata
- Download URL: p2d-0.2.0.tar.gz
- Upload date:
- Size: 55.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a98177a9c72fc43aeac3dbafa8f3d8bd4886fb36cde08246aa97affbee2d5d5a |
|
MD5 | cb254882f5907df9c5b9eb2a90ace800 |
|
BLAKE2b-256 | c4b44b8b1ab25b25c9e9ca5beda6d1e0b959c335950c514e2b444e04e0abb95f |
File details
Details for the file p2d-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: p2d-0.2.0-py3-none-any.whl
- Upload date:
- Size: 56.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d45b5ba5225a06e9ece5c04b13079061d4296daa3cee653541c8dd212f909357 |
|
MD5 | 880e765edc33fbe379c492a72a6e6bed |
|
BLAKE2b-256 | 6d7b8745b801c32472a2eeee20ab27c227fbb926fe9c17f8f46afe136004f7c0 |