File: copying.py

package info (click to toggle)
python-graphviz 0.20.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,188 kB
  • sloc: python: 4,098; makefile: 13
file content (20 lines) | stat: -rw-r--r-- 565 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Create new instance copies with cooperative ``super()`` calls."""

__all__ = ['CopyBase']


class CopyBase:
    """Create new instance copies with cooperative ``super()`` calls."""

    def copy(self):
        """Return a copied instance of the object.

        Returns:
            An independent copy of the current object.
        """
        kwargs = self._copy_kwargs()
        return self.__class__(**kwargs)

    def _copy_kwargs(self, **kwargs):
        """Return the kwargs to create a copy of the instance."""
        return kwargs