diff options
-rw-r--r-- | pysquaredeal.py | 18 | ||||
-rw-r--r-- | squaredeal/__init__.py | 13 |
2 files changed, 16 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') diff --git a/squaredeal/__init__.py b/squaredeal/__init__.py index 163be72..c0ebd1a 100644 --- a/squaredeal/__init__.py +++ b/squaredeal/__init__.py @@ -1,2 +1,15 @@ class SquareDealError(Exception): pass + + +def squaredeal_board_range(arg_str): + from squaredeal.sqd import validate_board_range_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) |