def calc_path_and_create_folders(folder, import_path):
    """ calculate the path and create the needed folders """
    file_path = abspath(path_join(folder, import_path[:import_path.rfind(".")].replace(".", folder_seperator) + ".py"))
    mkdir_p(dirname(file_path))
    return file_path