import pathlib


def fname_timestamp(fname, tstamp):
    """
    Given a filename and a timestamp string return the filename with the
    timestamp embedded.

    Args:
        fname: Filename to embed timestamp into
        tstamp: Timestamp string

    Returns:
        fname with tstamp embedded

    Examples:
        x = fname_timestamp("test.txt", "20180626.034516")
        print(x)  # test.20180626.034516.txt

        y = fname_timestamp("test.tar.gz", "20180626.034516")
        print(y)  # test.20180626.034516.tar.gz
    """
    p = pathlib.Path(fname)
    return "{}.{}{}".format(p.stem, tstamp, "".join(p.suffixes))