def _get_static_info(interface):
    '''
    Return information about an interface from config file.

    :param interface: interface label
    '''
    data = {
        'connectionid': interface.name,
        'label': interface.name,
        'hwaddr': interface.hwaddr[:-1],
        'up': False,
        'ipv4': {
            'supportedrequestmodes': ['static', 'dhcp_linklocal', 'disabled'],
            'requestmode': 'static'
        },
        'wireless': False
    }
    hwaddr_section_number = ''.join(data['hwaddr'].split(':'))
    if os.path.exists(INTERFACES_CONFIG):
        information = _load_config(hwaddr_section_number, ['IPv4', 'Nameservers'], filename=INTERFACES_CONFIG)
        if information['IPv4'] != '':
            ipv4_information = information['IPv4'].split('/')
            data['ipv4']['address'] = ipv4_information[0]
            data['ipv4']['dns'] = information['Nameservers'].split(',')
            data['ipv4']['netmask'] = ipv4_information[1]
            data['ipv4']['gateway'] = ipv4_information[2]
    return data
def _get_static_info ( interface ) : data = { 'connectionid' : interface . name , 'label' : interface . name , 'hwaddr' : interface . hwaddr [ : - 1 ] , 'up' : False , 'ipv4' : { 'supportedrequestmodes' : [ 'static' , 'dhcp_linklocal' , 'disabled' ] , 'requestmode' : 'static' } , 'wireless' : False } hwaddr_section_number = '' . join ( data [ 'hwaddr' ] . split ( ':' ) ) if os . path . exists ( INTERFACES_CONFIG ) : information = _load_config ( hwaddr_section_number , [ 'IPv4' , 'Nameservers' ] , filename = INTERFACES_CONFIG ) if information [ 'IPv4' ] != '' : ipv4_information = information [ 'IPv4' ] . split ( '/' ) data [ 'ipv4' ] [ 'address' ] = ipv4_information [ 0 ] data [ 'ipv4' ] [ 'dns' ] = information [ 'Nameservers' ] . split ( ',' ) data [ 'ipv4' ] [ 'netmask' ] = ipv4_information [ 1 ] data [ 'ipv4' ] [ 'gateway' ] = ipv4_information [ 2 ] return data
Return information about an interface from config file.

    :param interface: interface label