Skip to content

Commit d6a4b90

Browse files
committed
move from base with deprecation the load_template method
1 parent 6676d22 commit d6a4b90

File tree

2 files changed

+38
-25
lines changed

2 files changed

+38
-25
lines changed

nipype/interfaces/base.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import os
2020
import re
2121
import platform
22-
from string import Template
2322
import select
2423
import subprocess as sp
2524
import sys
@@ -65,29 +64,6 @@ def __str__(self):
6564
return '{}'.format(self.value)
6665

6766

68-
69-
70-
def load_template(name):
71-
"""Load a template from the script_templates directory
72-
73-
Parameters
74-
----------
75-
name : str
76-
The name of the file to load
77-
78-
Returns
79-
-------
80-
template : string.Template
81-
82-
"""
83-
full_fname = os.path.join(os.path.dirname(__file__),
84-
'script_templates', name)
85-
template_file = open(full_fname)
86-
template = Template(template_file.read())
87-
template_file.close()
88-
return template
89-
90-
9167
class Bunch(object):
9268
"""Dictionary-like class that provides attribute-style access to it's items.
9369
@@ -2050,3 +2026,17 @@ class InputMultiPath(MultiPath):
20502026
20512027
"""
20522028
pass
2029+
2030+
2031+
def load_template(name):
2032+
"""
2033+
Deprecated stub for backwards compatibility,
2034+
please use nipype.interfaces.fsl.model.load_template
2035+
2036+
"""
2037+
from .fsl.model import load_template
2038+
iflogger.warning(
2039+
'Deprecated in 1.0.0, and will be removed in 1.1.0, '
2040+
'please use nipype.interfaces.fsl.model.load_template instead.'
2041+
)
2042+
return load_template(name)

nipype/interfaces/fsl/model.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
from glob import glob
1919
from shutil import rmtree
20+
from string import Template
2021

2122
import numpy as np
2223
from nibabel import load
@@ -25,12 +26,13 @@
2526
from ...utils.filemanip import list_to_filename, filename_to_list
2627
from ...utils.misc import human_order_sorted
2728
from ...external.due import BibTeX
28-
from ..base import (load_template, File, traits, isdefined,
29+
from ..base import (File, traits, isdefined,
2930
TraitedSpec, BaseInterface, Directory,
3031
InputMultiPath, OutputMultiPath,
3132
BaseInterfaceInputSpec)
3233
from .base import FSLCommand, FSLCommandInputSpec, Info
3334

35+
3436
class Level1DesignInputSpec(BaseInterfaceInputSpec):
3537
interscan_interval = traits.Float(mandatory=True,
3638
desc='Interscan interval (in secs)')
@@ -2168,3 +2170,24 @@ def _list_outputs(self):
21682170
self.inputs.out_vnscales_name)
21692171

21702172
return outputs
2173+
2174+
2175+
def load_template(name):
2176+
"""Load a template from the script_templates directory
2177+
2178+
Parameters
2179+
----------
2180+
name : str
2181+
The name of the file to load
2182+
2183+
Returns
2184+
-------
2185+
template : string.Template
2186+
2187+
"""
2188+
full_fname = os.path.join(os.path.dirname(__file__),
2189+
'script_templates', name)
2190+
template_file = open(full_fname)
2191+
template = Template(template_file.read())
2192+
template_file.close()
2193+
return template

0 commit comments

Comments
 (0)