Skip to content

Commit

Permalink
Record() now passes None values for unavailable args to log().
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperVanDenBosch committed Feb 18, 2015
1 parent 3f37d40 commit 6d10e30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions niprov/recording.py
Expand Up @@ -10,7 +10,9 @@ def record(command, new=None, parents=None, transient=False, args=[], kwargs={},
"""Execute a command and log it as provenance for the newly created file.
Args:
command (list or str or callable): Commands to be executed
command (list or str or callable): Command to be executed. Either a
string of executable system code, a list of components thereof, or
a python function object.
new (str, optional): Override path to the new file, i.e. if it
cannot be parsed from the command.
parents (list, optional): Override paths to parent files, i.e. if they
Expand All @@ -37,7 +39,7 @@ def record(command, new=None, parents=None, transient=False, args=[], kwargs={},
_parents = [command[c+1]]
else:
transformation = command.func_name
code = ''
code = None

if parents is not None:
_parents = parents
Expand All @@ -50,7 +52,7 @@ def record(command, new=None, parents=None, transient=False, args=[], kwargs={},
output = result.output
else:
command(*args, **kwargs)
output = ''
output = None

return log(_new, transformation, _parents, code=code, transient=transient,
logtext=output)
2 changes: 1 addition & 1 deletion tests/recording.py
Expand Up @@ -62,7 +62,7 @@ def test_Python_code(self):
self.record(myfunc, args=args, kwargs=kwargs, new='new.f', parents=['old.f'])
myfunc.assert_called_with(*args, **kwargs)
self.log.assert_called_with('new.f',myfunc.func_name,['old.f'],
transient=False, code='', logtext='')
transient=False, code=None, logtext=None)
# myfunc.func_code.co_filename


Expand Down

0 comments on commit 6d10e30

Please sign in to comment.