Skip to content
Snippets Groups Projects
Commit 3eea3b25 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Record: allow customization of kwargs used in Record.copy

parent 13e00fd5
No related branches found
No related tags found
No related merge requests found
......@@ -138,14 +138,17 @@ class RecordWithoutPickling(object):
fields.add(key)
setattr(self, key, value)
def copy(self, **kwargs):
def get_copy_kwargs(self, **kwargs):
for f in self.__class__.fields:
if f not in kwargs:
try:
kwargs[f] = getattr(self, f)
except AttributeError:
pass
return self.__class__(**kwargs)
return kwargs
def copy(self, **kwargs):
return self.__class__(**self.get_copy_kwargs(**kwargs))
def __repr__(self):
return "%s(%s)" % (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment