twa: implement a copy_named_properties_of() method

It was noted in #470 that make_twa_graph did not copy named
properties.  Let's fix that.

* spot/twa/twa.hh, spot/twa/twa.cc (copy_named_properties_of): New
method.
* spot/twa/twagraph.hh (make_twa_graph): Add an extra argument to
call copy_named_properties_of() optionally.
* python/spot/__init__.py (twa_graph.__copy__): Use it.
* tests/python/twagraph.py: Test that.
* tests/sanity/namedprop.test: Ensure copy_named_properties_of copies
all known named properties.
This commit is contained in:
Alexandre Duret-Lutz 2021-07-08 10:30:19 +02:00
parent 0cf2d285b6
commit 31a681c285
6 changed files with 70 additions and 10 deletions

View file

@ -222,7 +222,7 @@ class twa_graph:
return SVG(_ostream_to_svg(ostr))
def __copy__(self):
return make_twa_graph(self, twa_prop_set.all())
return make_twa_graph(self, twa_prop_set.all(), True)
def make_twa_graph(*args):