// Author: DosX
// E-Mail: collab@kay-software.ru
// GitHub: https://github.com/DosX-dev
// Telegram: @DosX_dev

function getPythonVersionByDll(dllFileName) { // python = 💩
    var version = "";

    var startIndex = dllFileName.indexOf("python");
    if (startIndex !== -1) {
        startIndex += 6;
        var endIndex = dllFileName.indexOf(".", startIndex);
        if (endIndex === -1) {
            endIndex = dllFileName.length;
        }
        version = dllFileName.substring(startIndex, endIndex);
    }

    if (version !== "") {
        if (version.length === 1) {
            return version + ".0";
        } else if (version.length === 2) {
            return version[0] + "." + version[1];
        } else {
            return version[0] + "." + version.substring(1);
        }
    } else {
        return null;
    }
}