from pathlib import Path
from typing import Dict


def _get_srcset_st(sources_dir: Path, hinames: Dict[float, Path]):
    """
    Create the srcset string for including on the md line.
    ie. sources_dir might be /home/sample-proj/source,
    hinames posix paths to
    0: /home/sample-proj/source/plot_types/images/img1.png,
    2.0: /home/sample-proj/source/plot_types/images/img1_2_0x.png,
    The result will be:
    '/plot_types/basic/images/mkd_glr_pie_001.png,
    /plot_types/basic/images/mkd_glr_pie_001_2_0x.png 2.0x'
    """
    srcst = ''
    for k in hinames.keys():
        path = hinames[k].relative_to(sources_dir).as_posix().lstrip('/')
        srcst += '../' + path
        if k == 0:
            srcst += ', '
        else:
            srcst += f' {k:1.1f}x, '
    if srcst[-2:] == ', ':
        srcst = srcst[:-2]
    srcst += ''

    return srcst