(ctx, mib_files, interactive)
Validate MIB file names. Frameworks used to load mib files expect MIB file names to match
    MIB name.
Validate MIB file names. Frameworks used to load mib files expect MIB file names to match
    MIB name.
Validate MIB file names . Frameworks used to load mib files expect MIB file names to match MIB name .
def validate_mib_filenames(ctx, mib_files, interactive):
    """
    Validate MIB file names. Frameworks used to load mib files expect MIB file names to match
    MIB name.
    """
    # filter files
    mib_files = [f for f in mib_files if os.path.isfile(f)]
    # ensure at least one mib file is provided
    if len(mib_files) == 0:
        echo_warning('🙄 no mib file provided, need at least one mib file to validate them')
        return

    mibs = []
    # build profile
    index = 1
    for mib_file in mib_files:
        if not os.path.isfile(mib_file):
            continue
        mib_name = _load_and_extract_mib_name(mib_file)

        base_filename = os.path.basename(mib_file)
        mibs.append(
            MibFile(
                index,
                folder=os.path.dirname(os.path.realpath(mib_file)),
                base_filename=base_filename,
                name=mib_name,
                is_valid=mib_name and mib_name == base_filename.split('.')[0],
            )
        )
        index += 1

    option = '*'
    if interactive:
        echo_info(
            tabulate(
                [[mib.index, mib.base_filename, mib.name, mib.is_valid] for mib in mibs],
                headers=['Index', 'File', 'Name', "Valid"],
            )
        )
        option = click.prompt(
            text='🤖 Which files do you want to rename? (* for all, 1 for single, 1-3:5-7 for range(s))',
            default=OPTION_ALL,
        )

    _rename_mib_files([mib for mib in mibs if not mib.is_valid], option)
def validate_mib_filenames ( ctx , mib_files , interactive ) : # filter files mib_files = [ f for f in mib_files if os . path . isfile ( f ) ] # ensure at least one mib file is provided if len ( mib_files ) == 0 : echo_warning ( '🙄 no mib file provided, need at least one mib file to validate them') return mibs = [ ] # build profile index = 1 for mib_file in mib_files : if not os . path . isfile ( mib_file ) : continue mib_name = _load_and_extract_mib_name ( mib_file ) base_filename = os . path . basename ( mib_file ) mibs . append ( MibFile ( index , folder = os . path . dirname ( os . path . realpath ( mib_file ) ) , base_filename = base_filename , name = mib_name , is_valid = mib_name and mib_name == base_filename . split ( '.' ) [ 0 ] , ) ) index += 1 option = '*' if interactive : echo_info ( tabulate ( [ [ mib . index , mib . base_filename , mib . name , mib . is_valid ] for mib in mibs ] , headers = [ 'Index' , 'File' , 'Name' , "Valid" ] , ) ) option = click . prompt ( text = '🤖 Which files do you want to rename? (* for all, 1 for single, 1-3:5-7 for range(s))', default = OPTION_ALL , ) _rename_mib_files ( [ mib for mib in mibs if not mib . is_valid ] , option )