From cde39b465aad7d3db2bac44e0eae8ef0d98e9e2b Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Thu, 1 Mar 2018 21:37:01 +0000
Subject: [PATCH] Renamed RETURN to LOAD

---
 fsl/wrappers/__init__.py     |  2 +-
 fsl/wrappers/wrapperutils.py | 25 ++++++++++++-------------
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/fsl/wrappers/__init__.py b/fsl/wrappers/__init__.py
index 8d50b77ad..55a3b14dd 100644
--- a/fsl/wrappers/__init__.py
+++ b/fsl/wrappers/__init__.py
@@ -12,7 +12,7 @@ from .wrapperutils import (applyArgStyle,   # noqa
                            required,
                            fileOrImage,
                            fileOrArray,
-                           RETURN,
+                           LOAD,
                            SHOW_IF_TRUE,
                            HIDE_IF_TRUE)
 from .bet          import (bet,)            # noqa
diff --git a/fsl/wrappers/wrapperutils.py b/fsl/wrappers/wrapperutils.py
index aae73d463..bab950609 100644
--- a/fsl/wrappers/wrapperutils.py
+++ b/fsl/wrappers/wrapperutils.py
@@ -220,7 +220,7 @@ def argsToKwargs(func, args):
     return kwargs
 
 
-RETURN = object()
+LOAD = object()
 """Constant used by the :class:`_FileOrThing` class to indicate that an output
 file should be loaded into memory and returned as a Python object.
 """
@@ -252,11 +252,11 @@ class _FileOrThing(object):
     **Outputs**
 
 
-    If an argument is given the special :data:`RETURN` value, it is assumed
+    If an argument is given the special :data:`LOAD` value, it is assumed
     to be an output argument. In this case, it is replaced with a temporary
     file name then, after the function has completed, that file is loaded
     into memory, and the value returned (along with the function's output,
-    and any other arguments with a value of ``RETURN``).
+    and any other arguments with a value of ``LOAD``).
 
 
     **Return value**
@@ -265,9 +265,8 @@ class _FileOrThing(object):
     Functions decorated with a ``_FileOrThing`` decorator will always return a
     tuple, where the first element is the function's actual return value. The
     remainder of the tuple will contain any arguments that were given the
-    special ``RETURN`` value. ``None`` is returned for any ``RETURN``
-    arguments corresponded to output files that were not generated by the
-    function.
+    special ``LOAD`` value. ``None`` is returned for any ``LOAD`` arguments
+    corresponded to output files that were not generated by the function.
 
 
     **Example**
@@ -304,12 +303,12 @@ class _FileOrThing(object):
         # The output is returned as a numpy
         # array (in a tuple with the concat
         # function's return value)
-        atoc = concat('atob.txt', 'btoc.txt', RETURN)[1]
+        atoc = concat('atob.txt', 'btoc.txt', LOAD)[1]
 
         # The inputs are saved to temporary
         # files, and those file names are
         # passed to the concat function.
-        atoc = concat(np.diag([2, 2, 2, 0]), np.diag([3, 3, 3, 3]), RETURN)[1]
+        atoc = concat(np.diag([2, 2, 2, 0]), np.diag([3, 3, 3, 3]), LOAD)[1]
     """
 
 
@@ -318,7 +317,7 @@ class _FileOrThing(object):
 
         :arg prepareThing: Function which
         :arg loadThing:    Function which is called for arguments that
-                           were set to :data:`RETURN`.
+                           were set to :data:`LOAD`.
 
         :arg things:
         """
@@ -343,7 +342,7 @@ class _FileOrThing(object):
     def __wrapper(self, func, isFileOrThing, *args, **kwargs):
         """Function which wraps ``func``, ensuring that any arguments of
         type ``Thing`` are saved to temporary files, and any arguments
-        with the value :data:`RETURN` are loaded and returned.
+        with the value :data:`LOAD` are loaded and returned.
 
         :arg func:          The func being wrapped.
 
@@ -368,9 +367,9 @@ class _FileOrThing(object):
             result = func(**kwargs)
 
             # Load the output things that
-            # were specified as RETURN
             outthings = []
             for of in outfiles:
+            # were specified as LOAD
 
                 # output file didn't get created
                 if not op.exists(of):
@@ -456,7 +455,7 @@ def fileOrImage(*imgargs):
         # caller has requested that it be
         # returned from the function call
         # as an in-memory image.
-        elif val == RETURN:
+        elif val == LOAD:
             newval  = op.join(workdir, '{}.nii.gz'.format(name))
             outfile = newval
 
@@ -498,7 +497,7 @@ def fileOrArray(*arrargs):
         # This is an output, and the caller has
         # requested that it be returned from the
         # function call as an in-memory array.
-        elif val == RETURN:
+        elif val == LOAD:
             newval  = op.join(workdir, '{}.txt'.format(name))
             outfile = newval
 
-- 
GitLab