summaryrefslogtreecommitdiff
path: root/pysquaredeal.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2024-01-22 01:13:28 +0100
committeremkael <emkael@tlen.pl>2024-01-22 01:13:28 +0100
commit9dc375039c7e7f56bdcaa799b2e983c450c840c0 (patch)
tree7574262792c4540c4aeb766cf5832c8447e51f88 /pysquaredeal.py
parentd333b72014bae8872a1e36caa542082adf60dcea (diff)
Moving argument validator/type parser to target namespace
Diffstat (limited to 'pysquaredeal.py')
-rw-r--r--pysquaredeal.py18
1 files changed, 3 insertions, 15 deletions
diff --git a/pysquaredeal.py b/pysquaredeal.py
index b8632ce..cd4f20a 100644
--- a/pysquaredeal.py
+++ b/pysquaredeal.py
@@ -1,19 +1,7 @@
import argparse, os, re, sys
-from squaredeal import SquareDealError
-from squaredeal.sqd import SQD, SQDPhase, generate_session_key, validate_board_range_str
-
-
-def board_range(arg_str):
- ranges = []
- for range_str in arg_str.split(','):
- range_match = re.match(r'^([0-9]+)x([0-9]+)$', range_str)
- if range_match:
- subrange_count = int(range_match.group(2))
- ranges += ['%d-%d' % (i*subrange_count+1, (i+1)*subrange_count) for i in range(0, int(range_match.group(1)))]
- continue
- ranges += [validate_board_range_str(range_str)]
- return ','.join(ranges)
+from squaredeal import SquareDealError, squaredeal_board_range
+from squaredeal.sqd import SQD, SQDPhase, generate_session_key
argparser = argparse.ArgumentParser(prog='pysquaredeal.py')
@@ -37,7 +25,7 @@ argparser_di.add_argument('delayed_information', metavar='DELAYED_INFO', help='d
argparser_phase = subparsers.add_parser('add_phase', help='add event phase')
argparser_phase.add_argument('sessions', metavar='NO_SESSIONS', help='number of sessions in phase', type=int)
-argparser_phase.add_argument('boards', metavar='NO_BOARDS', help='number of boards in each session, also accepts syntax like "1-10,11-20,21-30", "3x7" is expanded to "1-7,8-14,15-21"', type=board_range)
+argparser_phase.add_argument('boards', metavar='NO_BOARDS', help='number of boards in each session, also accepts syntax like "1-10,11-20,21-30", "3x7" is expanded to "1-7,8-14,15-21"', type=squaredeal_board_range)
argparser_phase.add_argument('prefix', metavar='PREFIX', help='ouput file prefix ("#" will be replaced by session number)')
argparser_phase.add_argument('description', nargs='?', metavar='DESCRIPTION', help='phase description')