Skip to content

Commit

Permalink
rename testcase help to tools
Browse files Browse the repository at this point in the history
  • Loading branch information
X3nom committed Dec 10, 2024
1 parent 6ba213a commit 4a2cd6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## usage
```
usage: testcase-help.py [-h] [-V] [-r] [-f] [-g CMD] [-v CMD] [-z] [-n NAME] PATH
usage: testcase-tools.py [-h] [-V] [-r] [-f] [-g CMD] [-v CMD] [-z] [-n NAME] PATH
positional arguments:
PATH Path to a file or directory
Expand Down
27 changes: 22 additions & 5 deletions src/testcase-help.py → src/testcase-tools.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/python3
import argparse
import os
import glob
Expand Down Expand Up @@ -82,7 +83,7 @@ def gen_check_res(args :argparse.Namespace, gen=True):
verb_print(f"TASK: {(lambda: "generating" if gen else "verifying")()} results")

test_i = 1
for in_file in glob.glob(f"**/*in*", root_dir=args.path, recursive=True):
for in_file in glob.glob(f"**/*in*", root_dir=args.path, recursive=args.recursive):

in_file_path = f"{args.path}/{in_file}"

Expand Down Expand Up @@ -148,10 +149,14 @@ def make_import_zip(args :argparse.Namespace):
zipf.mkdir("data")
zipf.mkdir("data/secret")

zipf.writestr("problem.yaml", f"# autogenerated by testcase-help.py\nname: '{args.name}'")
zipf.writestr("problem.yaml", f"# autogenerated by testcase-tools.py\nname: '{args.name}'")
zipf.writestr("domjudge-problem.ini", f"# autogenerated by testcase-tools.py\ntimelimit='{args.timelimit}'")
if args.problem_pdf is not None:
zipf.write(args.problem_pdf, "problem.pdf")


test_i = 1
for in_file in glob.glob(f"**/*in*", root_dir=args.path, recursive=True):
for in_file in glob.glob(f"**/*in*", root_dir=args.path, recursive=args.recursive):

dir_path = f"{args.path}/{os.path.dirname(in_file)}"
dir_name = os.path.basename(dir_path)
Expand Down Expand Up @@ -182,7 +187,7 @@ def make_import_zip(args :argparse.Namespace):
def main():
global VERBOSE
arg_parser = argparse.ArgumentParser()

# Basic ===============================
arg_parser.add_argument(
"path",
metavar="PATH",
Expand All @@ -198,11 +203,13 @@ def main():
action="store_true",
help="process directories recursively"
)
# Encoding ============================
arg_parser.add_argument(
"-f", "--fix-encoding",
action="store_true",
help="fix encoding of file(s) to UTF-8 LF"
)
# Answers =============================
arg_parser.add_argument(
"-g", "--generate-answers",
metavar="CMD",
Expand All @@ -213,6 +220,7 @@ def main():
metavar="CMD",
help="run CMD for in.txt and verify correctness of out.txt"
)
# Zip =================================
arg_parser.add_argument(
"-z", "--make-zip",
action="store_true",
Expand All @@ -221,7 +229,16 @@ def main():
arg_parser.add_argument(
"-n", "--name",
default="unnamed",
help="specify name for zip"
help="specify problem name"
)
arg_parser.add_argument(
"-tl", "--timelimit",
default=10,
help="specify problem timelimit"
)
arg_parser.add_argument(
"-pdf", "--problem-pdf",
help="specify problem timelimit"
)

args = arg_parser.parse_args()
Expand Down

0 comments on commit 4a2cd6a

Please sign in to comment.