"""Common util functions (e.g. missing in Python)."""
import collections
from pathlib import Path


def update(d: dict, u: dict) -> dict:
    """ Recursively update a dict.

    Args:
        d: Dictionary to update.
        u: Dictionary with values to use.

    Returns:
        The merged dictionary.
    """
    for k, v in u.items():
        if isinstance(v, collections.Mapping):
            d[k] = update(d.get(k, {}), v)
        else:
            d[k] = v
    return d


def _copy(self, target):
    """Monkeypatch for pathlib

    Args:
        self:
        target:

    Returns:

    """
    import shutil

    assert self.is_file()
    shutil.copy(str(self), str(target))  # str() only there for Python < (3, 6)


Path.copy = _copy

"""Common util functions (e.g. missing in Python)."""
import collections
from pathlib import Path


def update(d: dict, u: dict) -> dict:
    """ Recursively update a dict.

    Args:
        d: Dictionary to update.
        u: Dictionary with values to use.

    Returns:
        The merged dictionary.
    """
    for k, v in u.items():
        if isinstance(v, collections.Mapping):
            d[k] = update(d.get(k, {}), v)
        else:
            d[k] = v
    return d


def _copy(self, target):
    """Monkeypatch for pathlib

    Args:
        self:
        target:

    Returns:

    """
    import shutil

    assert self.is_file()
    shutil.copy(str(self), str(target))  # str() only there for Python < (3, 6)


Path.copy = _copy

Common util functions (e.g. missing in Python). Recursively update a dict.      Args:         d: Dictionary to update.         u: Dictionary with values to use.      Returns:         The merged dictionary. Monkeypatch for pathlib      Args:         self:         target:      Returns: # str() only there for Python < (3, 6)