Improve ModelStorage.copy

* Allow callable in copy default
* Support dotted notation in copy default
* Use setdefault in copy
* Copy default when needed
* Do not set default state in copy
* Use callable and dotted notation in copy default

issue5576
issue7648
review72291002
This commit is contained in:
Cédric Krier
2018-09-01 01:02:03 +02:00
parent 32f98367e7
commit 2864441dc7
+2 -1
View File
@@ -171,7 +171,8 @@ class Move(metaclass=PoolMeta):
def copy(cls, moves, default=None):
if default is None:
default = {}
default = default.copy()
else:
default = default.copy()
for prefix in ('in_', 'out_'):
default.setdefault(prefix + 'anglo_saxon_quantity',
getattr(cls, 'default_%sanglo_saxon_quantity' % prefix)())