from datetime import datetime


def create_filename(filename,path=None,file_extension=None,append_timestamp=False):
    """ helper method to create a filename based on name, path , file extension and option
        to append a timestamp """

    if append_timestamp is True:              
        timestamp = "_"+datetime.now().strftime("%Y%m%d_%H%M%S")
    else:
        timestamp = ""    

    if file_extension is None:
        file_end = ""
    else:
        file_end = "." + file_extension
    
    if path is None:
        path_save = ""
    else:
        path_save = path+"\\"

    return path_save+filename+timestamp+file_end