Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit e40d1e1

Browse files
authored
Merge pull request #246 from girder/improve-warnings
Improve warnings
2 parents 5f825e1 + e47d4b6 commit e40d1e1

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

slicer_cli_web/ctk_cli_adjustment.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def parse(cls, elementTree): # noqa
114114
if self.index is not None:
115115
self.index = int(self.index)
116116

117-
if self.default:
117+
if self.default is not None:
118118
try:
119119
self.default = self.parseValue(self.default)
120120
except ValueError as e:
@@ -124,7 +124,7 @@ def parse(cls, elementTree): # noqa
124124
not self.isVector() and not self.isExternalType() and
125125
self.channel != 'output'):
126126
ctk_cli.module.logger.warning(
127-
'No <default> provided for element of type <%s>', self.typ)
127+
'No <default> provided for element of type <%s> (%s)', self.typ, self.name)
128128

129129
if self.typ.endswith('-enumeration'):
130130
try:
@@ -158,6 +158,26 @@ def _ctkCliParse(cls, elementTree): # noqa
158158

159159
ctk_cli.module.CLIParameters.parse = _ctkCliParse
160160

161+
_orig_CLIModule_init = ctk_cli.CLIModule.__init__
162+
163+
164+
def _CLIModule_init(self, path=None, env=None, stream=None):
165+
ret = _orig_CLIModule_init(self, path, env, stream)
166+
indices = set()
167+
for param in self.parameters():
168+
if param.index is not None:
169+
idx = int(param.index)
170+
if idx in indices:
171+
ctk_cli.module.logger.warning('Parameter index %d used multiple times', idx)
172+
indices.add(idx)
173+
if len(indices) and (min(indices) < 0 or max(indices) >= len(indices)):
174+
ctk_cli.module.logger.warning('Parameter indices are not continuous from 0 upwards')
175+
176+
return ret
177+
178+
179+
ctk_cli.CLIModule.__init__ = _CLIModule_init
161180
CLIModule = ctk_cli.CLIModule
162181

182+
163183
__all__ = ['CLIModule']

0 commit comments

Comments
 (0)