summaryrefslogtreecommitdiff
path: root/squaredeal
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 /squaredeal
parentd333b72014bae8872a1e36caa542082adf60dcea (diff)
Moving argument validator/type parser to target namespace
Diffstat (limited to 'squaredeal')
-rw-r--r--squaredeal/__init__.py13
1 files changed, 13 insertions, 0 deletions
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)