Skip to content

Commit 1e05db7

Browse files
Added custom expansion support for repeated capabilities
1 parent d4f80d3 commit 1e05db7

File tree

4 files changed

+1098
-277
lines changed

4 files changed

+1098
-277
lines changed

build/templates/session.py.mako

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class _Lock(object):
8888
def __exit__(self, exc_type, exc_value, traceback):
8989
self._session.unlock()
9090

91-
9291
% endif
9392
% if len(config['repeated_capabilities']) > 0:
9493

@@ -205,6 +204,7 @@ class _NoChannel(object):
205204

206205
def __exit__(self, exc_type, exc_value, traceback):
207206
self._session._repeated_capability = self._repeated_capability_cache
207+
% endif
208208

209209

210210
% endif
@@ -216,6 +216,11 @@ class _SessionBase(object):
216216

217217
% for attribute in helper.sorted_attrs(helper.filter_codegen_attributes(attributes)):
218218
<%
219+
# Skip attributes with repeated capability expansion set to "custom"
220+
if 'repeated_capability_type' in attributes[attribute]:
221+
rep_cap_type = attributes[attribute]['repeated_capability_type']
222+
if any(rep_cap.get('python_name') == rep_cap_type and config['rep_cap_expansion'] == 'custom' for rep_cap in config['repeated_capabilities']):
223+
continue
219224
helper.add_attribute_rep_cap_tip(attributes[attribute], config)
220225
%>\
221226
%if attributes[attribute]['enum']:
@@ -257,9 +262,13 @@ constructor_params = helper.filter_parameters(init_function['parameters'], helpe
257262

258263
% if len(config['repeated_capabilities']) > 0:
259264
# Instantiate any repeated capability objects
260-
% for rep_cap in config['repeated_capabilities']:
265+
% for rep_cap in config['repeated_capabilities']:
266+
% if config['rep_cap_expansion'] == 'custom':
267+
self.${rep_cap['python_name']} = _RepCap${rep_cap['python_name'].capitalize()}(self, repeated_capability_list)
268+
% else:
261269
self.${rep_cap['python_name']} = _RepeatedCapabilities(self, '${rep_cap["prefix"]}', repeated_capability_list)
262-
% endfor
270+
% endif
271+
% endfor
263272

264273
% endif
265274
# Finally, set _is_frozen to True which is used to prevent clients from accidentally adding

generated/nidmm/nidmm/session.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def __enter__(self):
5050
def __exit__(self, exc_type, exc_value, traceback):
5151
self._session.unlock()
5252

53-
5453
class _SessionBase(object):
5554
'''Base class for all NI-DMM sessions.'''
5655

0 commit comments

Comments
 (0)