File: MatlabOctaveImport.py

package info (click to toggle)
xmds2 2.2.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 53,384 kB
  • ctags: 7,223
  • sloc: python: 54,076; cpp: 3,929; ansic: 1,463; makefile: 135; sh: 20
file content (686 lines) | stat: -rw-r--r-- 33,259 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
#!/usr/bin/env python




##################################################
## DEPENDENCIES
import sys
import os
import os.path
try:
    import builtins as builtin
except ImportError:
    import __builtin__ as builtin
from os.path import getmtime, exists
import time
import types
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import *
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers

##################################################
## MODULE CONSTANTS
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.4.4'
__CHEETAH_versionTuple__ = (2, 4, 4, 'development', 0)
__CHEETAH_genTime__ = 1413234541.385449
__CHEETAH_genTimestamp__ = 'Tue Oct 14 08:09:01 2014'
__CHEETAH_src__ = '/Users/graham/Library/XMDS/src/xmds2/admin/staging/xmds-2.2.2/xpdeint/xsil2graphics2/MatlabOctaveImport.tmpl'
__CHEETAH_srcLastModified__ = 'Thu Nov 21 19:01:13 2013'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'

if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
    raise AssertionError(
      'This template was compiled with Cheetah version'
      ' %s. Templates compiled before version %s must be recompiled.'%(
         __CHEETAH_version__, RequiredCheetahVersion))

##################################################
## CLASSES

class MatlabOctaveImport(Template):

    ##################################################
    ## CHEETAH GENERATED METHODS


    def __init__(self, *args, **KWs):

        super(MatlabOctaveImport, self).__init__(*args, **KWs)
        if not self._CHEETAH__instanceInitialized:
            cheetahKWArgs = {}
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
            for k,v in KWs.items():
                if k in allowedKWs: cheetahKWArgs[k] = v
            self._initCheetahInstance(**cheetahKWArgs)
        

    def description(self, **KWS):



        ## Generated from @def description: Creates text to import data from XSIL files into Matlab or Octave (where they are identical). at line 24, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write(u'''Creates text to import data from XSIL files into Matlab or Octave (where they are identical).''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def printMatlabListOrElement(self, listOrElement, currentDepth, **KWS):



        ## CHEETAH: generated from @def printMatlabListOrElement(listOrElement, currentDepth) at line 30, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        #  This is a function to turn an array into a Matlab list.  Called recursively, and assumes the elements are floats or lists.
        if isinstance(listOrElement,float): # generated from line 32, col 3
            _v = VFFSL(SL,"format",False)(float(listOrElement),VFFSL(SL,"stringFormat",True)) # u'${format(float(listOrElement),$stringFormat)}' on line 33, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'${format(float(listOrElement),$stringFormat)}')) # from line 33, col 1.
        else: # generated from line 34, col 3
            write(u'''cat(''')
            _v = VFFSL(SL,"currentDepth",True) # u'$currentDepth' on line 35, col 5
            if _v is not None: write(_filter(_v, rawExpr=u'$currentDepth')) # from line 35, col 5.
            write(u''', ''')
            _v = ', '.join([VFFSL(SL,"printMatlabListOrElement",False)(element, currentDepth - 1) for element in listOrElement]) # u"${', '.join([$printMatlabListOrElement(element, currentDepth - 1) for element in listOrElement])}" on line 35, col 20
            if _v is not None: write(_filter(_v, rawExpr=u"${', '.join([$printMatlabListOrElement(element, currentDepth - 1) for element in listOrElement])}")) # from line 35, col 20.
            write(u''')''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def permuteDimensionsOfMATLABVariable(self, varName, **KWS):



        ## CHEETAH: generated from @def permuteDimensionsOfMATLABVariable(varName) at line 39, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        _v = VFFSL(SL,"varName",True) # u'${varName}' on line 40, col 1
        if _v is not None: write(_filter(_v, rawExpr=u'${varName}')) # from line 40, col 1.
        write(u''' = permute(''')
        _v = VFFSL(SL,"varName",True) # u'${varName}' on line 40, col 22
        if _v is not None: write(_filter(_v, rawExpr=u'${varName}')) # from line 40, col 22.
        write(u''', ndims(''')
        _v = VFFSL(SL,"varName",True) # u'${varName}' on line 40, col 40
        if _v is not None: write(_filter(_v, rawExpr=u'${varName}')) # from line 40, col 40.
        write(u'''):-1:1);
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def generateVariableName(self, xsilVariable, xsilObjectNumber, **KWS):



        ## CHEETAH: generated from @def generateVariableName(xsilVariable, xsilObjectNumber) at line 43, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        return ''.join([str(VFFSL(SL,"xsilVariable.name",True)),u'_',str(VFFSL(SL,"xsilObjectNumber",True)+1)])
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def loadXSILFile(self, xsilFile, **KWS):



        ## CHEETAH: generated from @def loadXSILFile($xsilFile) at line 47, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        for objectNum, xsilObject in enumerate(xsilFile.xsilObjects): # generated from line 48, col 3
            if xsilObject.data.format == 'ascii': # generated from line 49, col 5
                _v = VFFSL(SL,"handleASCIIXSILObject",False)(objectNum, xsilObject) # u'${handleASCIIXSILObject(objectNum, xsilObject)}' on line 50, col 1
                if _v is not None: write(_filter(_v, rawExpr=u'${handleASCIIXSILObject(objectNum, xsilObject)}')) # from line 50, col 1.
            elif xsilObject.data.format == 'binary': # generated from line 51, col 5
                _v = VFFSL(SL,"handleBinaryXSILObject",False)(objectNum, xsilObject) # u'${handleBinaryXSILObject(objectNum, xsilObject)}' on line 52, col 1
                if _v is not None: write(_filter(_v, rawExpr=u'${handleBinaryXSILObject(objectNum, xsilObject)}')) # from line 52, col 1.
            elif xsilObject.data.format == 'hdf5': # generated from line 53, col 5
                _v = VFFSL(SL,"handleHDF5XSILObject",False)(objectNum, xsilObject) # u'${handleHDF5XSILObject(objectNum, xsilObject)}' on line 54, col 1
                if _v is not None: write(_filter(_v, rawExpr=u'${handleHDF5XSILObject(objectNum, xsilObject)}')) # from line 54, col 1.
            else: # generated from line 55, col 5
                raise Exception("No support for Matlab/Octave output for XSIL format '%s'." % xsilObject.data.format)
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def handleASCIIXSILObject(self, objectNum, xsilObject, **KWS):



        ## CHEETAH: generated from @def handleASCIIXSILObject(objectNum, xsilObject) at line 61, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        nIndepVar = len(xsilObject.independentVariables)
        for var in xsilObject.independentVariables: # generated from line 63, col 3
            varName = VFFSL(SL,"generateVariableName",False)(var, objectNum)
            write(u'''clear ''')
            _v = VFFSL(SL,"varName",True) # u'$varName' on line 65, col 7
            if _v is not None: write(_filter(_v, rawExpr=u'$varName')) # from line 65, col 7.
            write(u'''
''')
            _v = VFFSL(SL,"varName",True) # u'$varName' on line 66, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'$varName')) # from line 66, col 1.
            write(u''' = [''')
            _v = ', '.join([format(float(e),VFFSL(SL,"stringFormat",True)) for e in var["array"]]) # u'${\', \'.join([format(float(e),$stringFormat) for e in var["array"]])}' on line 66, col 13
            if _v is not None: write(_filter(_v, rawExpr=u'${\', \'.join([format(float(e),$stringFormat) for e in var["array"]])}')) # from line 66, col 13.
            write(u'''];
''')
        for var in xsilObject.dependentVariables: # generated from line 68, col 3
            varName = VFFSL(SL,"generateVariableName",False)(var, objectNum)
            write(u'''clear ''')
            _v = VFFSL(SL,"varName",True) # u'$varName' on line 70, col 7
            if _v is not None: write(_filter(_v, rawExpr=u'$varName')) # from line 70, col 7.
            write(u'''
''')
            if nIndepVar == 1: # generated from line 71, col 5
                _v = VFFSL(SL,"varName",True) # u'$varName' on line 72, col 1
                if _v is not None: write(_filter(_v, rawExpr=u'$varName')) # from line 72, col 1.
                write(u''' = [''')
                _v = ', '.join([format(float(e), VFFSL(SL,"stringFormat",True)) for e in var["array"]]) # u'${\', \'.join([format(float(e), $stringFormat) for e in var["array"]])}' on line 72, col 13
                if _v is not None: write(_filter(_v, rawExpr=u'${\', \'.join([format(float(e), $stringFormat) for e in var["array"]])}')) # from line 72, col 13.
                write(u'''];
''')
            elif nIndepVar == 2: # generated from line 73, col 5
                _v = VFFSL(SL,"varName",True) # u'$varName' on line 74, col 1
                if _v is not None: write(_filter(_v, rawExpr=u'$varName')) # from line 74, col 1.
                write(u''' = [''')
                _v = ';'.join([(','.join([format(float(val), VFFSL(SL,"stringFormat",True)) for val in subArray])) for subArray in var["array"]]) # u'${\';\'.join([(\',\'.join([format(float(val), $stringFormat) for val in subArray])) for subArray in var["array"]])}' on line 74, col 13
                if _v is not None: write(_filter(_v, rawExpr=u'${\';\'.join([(\',\'.join([format(float(val), $stringFormat) for val in subArray])) for subArray in var["array"]])}')) # from line 74, col 13.
                write(u'''];
''')
            else: # generated from line 75, col 5
                _v = VFFSL(SL,"varName",True) # u'$varName' on line 76, col 1
                if _v is not None: write(_filter(_v, rawExpr=u'$varName')) # from line 76, col 1.
                write(u''' = ''')
                _v = VFFSL(SL,"printMatlabListOrElement",False)(VFFSL(SL,"var",True)["array"], VFFSL(SL,"nIndepVar",True)) # u'$printMatlabListOrElement($var["array"], $nIndepVar)' on line 76, col 12
                if _v is not None: write(_filter(_v, rawExpr=u'$printMatlabListOrElement($var["array"], $nIndepVar)')) # from line 76, col 12.
                write(u''';
''')
            _v = VFFSL(SL,"permuteDimensionsOfMATLABVariable",False)(varName) # u'${permuteDimensionsOfMATLABVariable(varName)}' on line 78, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'${permuteDimensionsOfMATLABVariable(varName)}')) # from line 78, col 1.
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def handleBinaryXSILObject(self, objectNum, xsilObject, **KWS):



        ## CHEETAH: generated from @def handleBinaryXSILObject(objectNum, xsilObject) at line 82, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        variablesToClear = ['fpDat', 'xmds_variableShape']
        nIndepVar = len(xsilObject.independentVariables)
        machineFormat = {'BigEndian': 'ieee-be', 'LittleEndian': 'ieee-le'}.get(xsilObject.data.encoding, 'native')
        uLongFormat = {'uint32': 'uint32', 'uint64': 'uint64'}.get(xsilObject.data.uLong, 'uint64')
        outputPrecision = {'single': 'single', 'double': 'double'}.get(xsilObject.data.precision, 'double')
        write(u"""fpDat = fopen('""")
        _v = VFFSL(SL,"xsilObject.data.filename",True) # u'$xsilObject.data.filename' on line 88, col 16
        if _v is not None: write(_filter(_v, rawExpr=u'$xsilObject.data.filename')) # from line 88, col 16.
        write(u"""','r', '""")
        _v = VFFSL(SL,"machineFormat",True) # u'$machineFormat' on line 88, col 49
        if _v is not None: write(_filter(_v, rawExpr=u'$machineFormat')) # from line 88, col 49.
        write(u"""');
if (fpDat < 0)
  disp('Cannot open binary data file: """)
        _v = VFFSL(SL,"xsilObject.data.filename",True) # u'${xsilObject.data.filename}' on line 90, col 39
        if _v is not None: write(_filter(_v, rawExpr=u'${xsilObject.data.filename}')) # from line 90, col 39.
        write(u"""');
  return;
end
xmds_variableShape = [];
""")
        for var in xsilObject.independentVariables: # generated from line 94, col 3
            varName = VFFSL(SL,"generateVariableName",False)(var, objectNum)
            variablesToClear.append(''.join([str(VFFSL(SL,"varName",True)),u'Len']))
            _v = VFFSL(SL,"varName",True) # u'$(varName)' on line 97, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'$(varName)')) # from line 97, col 1.
            write(u"""Len = fread(fpDat, 1, '""")
            _v = VFFSL(SL,"uLongFormat",True) # u'$uLongFormat' on line 97, col 34
            if _v is not None: write(_filter(_v, rawExpr=u'$uLongFormat')) # from line 97, col 34.
            write(u"""');
""")
            _v = VFFSL(SL,"varName",True) # u'$(varName)' on line 98, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'$(varName)')) # from line 98, col 1.
            write(u''' = fread(fpDat, ''')
            _v = VFFSL(SL,"varName",True) # u'$(varName)' on line 98, col 27
            if _v is not None: write(_filter(_v, rawExpr=u'$(varName)')) # from line 98, col 27.
            write(u"""Len, '""")
            _v = VFFSL(SL,"outputPrecision",True) # u'$outputPrecision' on line 98, col 43
            if _v is not None: write(_filter(_v, rawExpr=u'$outputPrecision')) # from line 98, col 43.
            write(u"""');
xmds_variableShape = [""")
            _v = VFFSL(SL,"varName",True) # u'${varName}' on line 99, col 23
            if _v is not None: write(_filter(_v, rawExpr=u'${varName}')) # from line 99, col 23.
            write(u'''Len xmds_variableShape];
''')
        write(u'''if (length(xmds_variableShape) == 0)
  xmds_variableShape = [1 1];
elseif (length(xmds_variableShape) == 1)
  xmds_variableShape(end+1) = 1;
end
''')
        for varD in xsilObject.dependentVariables: # generated from line 106, col 3
            varName = VFFSL(SL,"generateVariableName",False)(varD, objectNum)
            variablesToClear.append(''.join([str(VFFSL(SL,"varName",True)),u'Len']))
            _v = VFFSL(SL,"varName",True) # u'$(varName)' on line 109, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'$(varName)')) # from line 109, col 1.
            write(u"""Len = fread(fpDat, 1, '""")
            _v = VFFSL(SL,"uLongFormat",True) # u'$uLongFormat' on line 109, col 34
            if _v is not None: write(_filter(_v, rawExpr=u'$uLongFormat')) # from line 109, col 34.
            write(u"""', 0, '""")
            _v = VFFSL(SL,"machineFormat",True) # u'$machineFormat' on line 109, col 53
            if _v is not None: write(_filter(_v, rawExpr=u'$machineFormat')) # from line 109, col 53.
            write(u"""');
""")
            _v = VFFSL(SL,"varName",True) # u'$varName' on line 110, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'$varName')) # from line 110, col 1.
            write(u''' = fread(fpDat, ''')
            _v = VFFSL(SL,"varName",True) # u'$(varName)' on line 110, col 25
            if _v is not None: write(_filter(_v, rawExpr=u'$(varName)')) # from line 110, col 25.
            write(u"""Len, '""")
            _v = VFFSL(SL,"outputPrecision",True) # u'$outputPrecision' on line 110, col 41
            if _v is not None: write(_filter(_v, rawExpr=u'$outputPrecision')) # from line 110, col 41.
            write(u"""');
""")
            _v = VFFSL(SL,"varName",True) # u'$varName' on line 111, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'$varName')) # from line 111, col 1.
            write(u''' = reshape(''')
            _v = VFFSL(SL,"varName",True) # u'$varName' on line 111, col 20
            if _v is not None: write(_filter(_v, rawExpr=u'$varName')) # from line 111, col 20.
            write(u''', xmds_variableShape);
''')
            _v = VFFSL(SL,"permuteDimensionsOfMATLABVariable",False)(varName) # u'${permuteDimensionsOfMATLABVariable(varName)}' on line 112, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'${permuteDimensionsOfMATLABVariable(varName)}')) # from line 112, col 1.
        write(u'''fclose(fpDat);
clear ''')
        _v = ' '.join(variablesToClear) # u"${' '.join(variablesToClear)}" on line 115, col 7
        if _v is not None: write(_filter(_v, rawExpr=u"${' '.join(variablesToClear)}")) # from line 115, col 7.
        write(u'''
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def handleHDF5XSILObject(self, objectNum, xsilObject, **KWS):



        ## CHEETAH: generated from @def handleHDF5XSILObject(objectNum, xsilObject) at line 118, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write(u"""if (exist('OCTAVE_VERSION', 'builtin')) % Octave
  """)
        _v = VFFSL(SL,"handleHDF5XSILObjectForOctave",False)(objectNum, xsilObject) # u'${handleHDF5XSILObjectForOctave(objectNum, xsilObject), autoIndent=True}' on line 120, col 3
        if _v is not None: write(_filter(_v, autoIndent=True, rawExpr=u'${handleHDF5XSILObjectForOctave(objectNum, xsilObject), autoIndent=True}')) # from line 120, col 3.
        write(u'''else % MATLAB
  ''')
        _v = VFFSL(SL,"handleHDF5XSILObjectForMATLAB",False)(objectNum, xsilObject) # u'${handleHDF5XSILObjectForMATLAB(objectNum, xsilObject), autoIndent=True}' on line 122, col 3
        if _v is not None: write(_filter(_v, autoIndent=True, rawExpr=u'${handleHDF5XSILObjectForMATLAB(objectNum, xsilObject), autoIndent=True}')) # from line 122, col 3.
        write(u'''end
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def handleHDF5XSILObjectForMATLAB(self, objectNum, xsilObject, **KWS):



        ## CHEETAH: generated from @def handleHDF5XSILObjectForMATLAB(objectNum, xsilObject) at line 127, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        filename = xsilObject.data.filename
        groupName = xsilObject.data.groupName
        for var in xsilObject.independentVariables: # generated from line 130, col 3
            outName = VFFSL(SL,"generateVariableName",False)(var, objectNum)
            _v = VFFSL(SL,"outName",True) # u'${outName}' on line 132, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'${outName}')) # from line 132, col 1.
            write(u""" = hdf5read('""")
            _v = VFFSL(SL,"filename",True) # u'${filename}' on line 132, col 24
            if _v is not None: write(_filter(_v, rawExpr=u'${filename}')) # from line 132, col 24.
            write(u"""', '""")
            _v = VFFSL(SL,"groupName",True) # u'${groupName}' on line 132, col 39
            if _v is not None: write(_filter(_v, rawExpr=u'${groupName}')) # from line 132, col 39.
            write(u'''/''')
            _v = VFFSL(SL,"var.name",True) # u'${var.name}' on line 132, col 52
            if _v is not None: write(_filter(_v, rawExpr=u'${var.name}')) # from line 132, col 52.
            write(u"""');
""")
        for var in xsilObject.dependentVariables: # generated from line 134, col 3
            outName = VFFSL(SL,"generateVariableName",False)(var, objectNum)
            _v = VFFSL(SL,"outName",True) # u'${outName}' on line 136, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'${outName}')) # from line 136, col 1.
            write(u""" = hdf5read('""")
            _v = VFFSL(SL,"filename",True) # u'${filename}' on line 136, col 24
            if _v is not None: write(_filter(_v, rawExpr=u'${filename}')) # from line 136, col 24.
            write(u"""', '""")
            _v = VFFSL(SL,"groupName",True) # u'${groupName}' on line 136, col 39
            if _v is not None: write(_filter(_v, rawExpr=u'${groupName}')) # from line 136, col 39.
            write(u'''/''')
            _v = VFFSL(SL,"var.name",True) # u'${var.name}' on line 136, col 52
            if _v is not None: write(_filter(_v, rawExpr=u'${var.name}')) # from line 136, col 52.
            write(u"""');
""")
            _v = VFFSL(SL,"permuteDimensionsOfMATLABVariable",False)(outName) # u'${permuteDimensionsOfMATLABVariable(outName)}' on line 137, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'${permuteDimensionsOfMATLABVariable(outName)}')) # from line 137, col 1.
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def handleHDF5XSILObjectForOctave(self, objectNum, xsilObject, **KWS):



        ## CHEETAH: generated from @def handleHDF5XSILObjectForOctave(objectNum, xsilObject) at line 141, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        filename = xsilObject.data.filename
        variables = xsilObject.independentVariables[:]
        write(u'''load ''')
        _v = VFFSL(SL,"filename",True) # u'${filename}' on line 144, col 6
        if _v is not None: write(_filter(_v, rawExpr=u'${filename}')) # from line 144, col 6.
        write(u'''
''')
        for var in xsilObject.independentVariables: # generated from line 145, col 3
            outName = VFFSL(SL,"generateVariableName",False)(var, objectNum)
            #  We have to do an eval here because variables with leading underscores are not valid in MATLAB
            #  (although accepted by Octave), and the MATLAB parser dies if there are expressions with leading underscores.
            _v = VFFSL(SL,"outName",True) # u'${outName}' on line 149, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'${outName}')) # from line 149, col 1.
            write(u""" = eval('_""")
            _v = VFFSL(SL,"objectNum",True)+1 # u'${objectNum+1}' on line 149, col 21
            if _v is not None: write(_filter(_v, rawExpr=u'${objectNum+1}')) # from line 149, col 21.
            write(u'''.''')
            _v = VFFSL(SL,"var.name",True) # u'${var.name}' on line 149, col 36
            if _v is not None: write(_filter(_v, rawExpr=u'${var.name}')) # from line 149, col 36.
            write(u"""');
""")
        for var in xsilObject.dependentVariables: # generated from line 151, col 3
            outName = VFFSL(SL,"generateVariableName",False)(var, objectNum)
            _v = VFFSL(SL,"outName",True) # u'${outName}' on line 153, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'${outName}')) # from line 153, col 1.
            write(u""" = eval('_""")
            _v = VFFSL(SL,"objectNum",True)+1 # u'${objectNum+1}' on line 153, col 21
            if _v is not None: write(_filter(_v, rawExpr=u'${objectNum+1}')) # from line 153, col 21.
            write(u'''.''')
            _v = VFFSL(SL,"var.name",True) # u'${var.name}' on line 153, col 36
            if _v is not None: write(_filter(_v, rawExpr=u'${var.name}')) # from line 153, col 36.
            write(u"""');
""")
            _v = VFFSL(SL,"permuteDimensionsOfMATLABVariable",False)(outName) # u'${permuteDimensionsOfMATLABVariable(outName)}' on line 154, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'${permuteDimensionsOfMATLABVariable(outName)}')) # from line 154, col 1.
        write(u'''clear _''')
        _v = VFFSL(SL,"objectNum",True)+1 # u'${objectNum+1}' on line 156, col 8
        if _v is not None: write(_filter(_v, rawExpr=u'${objectNum+1}')) # from line 156, col 8.
        write(u''';
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def respond(self, trans=None):



        ## CHEETAH: main method generated for this template
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        # 
        # MatlabOctaveImport.tmpl
        # 
        # Created by Joe Hope on 2009-01-07.
        # Modified by Gregory Bogomiagkov and Liam Madge on 2013-07-18.
        # 
        # Copyright (c) 2009-2013, Joe Hope and Graham Dennis
        # 
        # This program is free software: you can redistribute it and/or modify
        # it under the terms of the GNU General Public License as published by
        # the Free Software Foundation, either version 2 of the License, or
        # (at your option) any later version.
        # 
        # This program is distributed in the hope that it will be useful,
        # but WITHOUT ANY WARRANTY; without even the implied warranty of
        # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        # GNU General Public License for more details.
        # 
        # You should have received a copy of the GNU General Public License
        # along with this program.  If not, see <http://www.gnu.org/licenses/>.
        # 
        write(u'''












''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        
    ##################################################
    ## CHEETAH GENERATED ATTRIBUTES


    _CHEETAH__instanceInitialized = False

    _CHEETAH_version = __CHEETAH_version__

    _CHEETAH_versionTuple = __CHEETAH_versionTuple__

    _CHEETAH_genTime = __CHEETAH_genTime__

    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__

    _CHEETAH_src = __CHEETAH_src__

    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__

    defaultExtension = 'm'

    stringFormat = '.12e'

    name = 'MATLAB/Octave'

    _mainCheetahMethod_for_MatlabOctaveImport= 'respond'

## END CLASS DEFINITION

if not hasattr(MatlabOctaveImport, '_initCheetahAttributes'):
    templateAPIClass = getattr(MatlabOctaveImport, '_CHEETAH_templateClass', Template)
    templateAPIClass._addCheetahPlumbingCodeToClass(MatlabOctaveImport)


# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/

##################################################
## if run from command line:
if __name__ == '__main__':
    from Cheetah.TemplateCmdLineIface import CmdLineIface
    CmdLineIface(templateObj=MatlabOctaveImport()).run()