Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
e9d71e92
Commit
e9d71e92
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Small refactor to _FileOrThing to iron out some bugs
parent
d082cef9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/wrappers/wrapperutils.py
+10
-15
10 additions, 15 deletions
fsl/wrappers/wrapperutils.py
with
10 additions
and
15 deletions
fsl/wrappers/wrapperutils.py
+
10
−
15
View file @
e9d71e92
...
...
@@ -456,26 +456,21 @@ class _FileOrThing(object):
self
.
__func
=
None
def
__call__
(
self
,
func
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
"""
Creates and returns the decorated function.
"""
self
.
__func
=
func
# the first call will be our decorated
# function getting passed in.
if
self
.
__func
is
None
:
func
=
args
[
0
]
self
.
__func
=
func
return
self
# Wrap the wrapper because update_wrapper
# will raise an error if we pass it
# self.__wrapper. This is because it is
# not possible to set attributes on bound
# methods.
def
wrapper
(
*
args
,
**
kwargs
):
# Subsequent calls will be calls
# to the decorated function.
else
:
return
self
.
__wrapper
(
*
args
,
**
kwargs
)
# We replace this __call__ method
# with the decorated function, so
# this instance is the decorator,
# and __get__ will work as intended.
self
.
__call__
=
_update_wrapper
(
wrapper
,
func
)
return
self
def
__get__
(
self
,
instance
,
owner
):
"""
Called when this ``_FileOrThing`` has been used to decorate a method
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment