Skip to content

Commit f3c91a7

Browse files
authored
Merge pull request #39 from TomoATT/devel
Enhance str2val function to support boolean list conversion
2 parents eb347ed + b3d1499 commit f3c91a7

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

pytomoatt/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.12'
1+
__version__ = '0.2.13'

pytomoatt/utils/common.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ def str2val(str_val):
199199
except ValueError:
200200
pass
201201

202+
if str_val.lower() in ['true', 'false', 'yes', 'no']:
203+
return str_val.lower() in ['true', 'yes']
204+
205+
# return list of boolean
206+
try:
207+
items = [v.strip() for v in str_val.strip('[]').split(',')]
208+
if all(v.lower() in ['true', 'false', 'yes', 'no'] for v in items):
209+
return [v.lower() in ['true', 'yes'] for v in items]
210+
except Exception:
211+
pass
212+
202213
return str_val
203214

204215

0 commit comments

Comments
 (0)