def _edit_name(name, code, add_code=None, delete_end=False):
    """
    Helping function for creating file names in .SAFE format

    :param name: initial string
    :type name: str
    :param code:
    :type code: str
    :param add_code:
    :type add_code: str or None
    :param delete_end:
    :type delete_end: bool
    :return: edited string
    :rtype: str
    """
    info = name.split('_')
    info[2] = code
    if add_code is not None:
        info[3] = add_code
    if delete_end:
        info.pop()
    return '_'.join(info)
def _edit_name ( name , code , add_code = None , delete_end = False ) : info = name . split ( '_' ) info [ 2 ] = code if add_code is not None : info [ 3 ] = add_code if delete_end : info . pop ( ) return '_' . join ( info )
Helping function for creating file names in .SAFE format

    :param name: initial string
    :type name: str
    :param code:
    :type code: str
    :param add_code:
    :type add_code: str or None
    :param delete_end:
    :type delete_end: bool
    :return: edited string
    :rtype: str