def get_function_by_ifname(ifname):
 dev_path = ('/sys/class/net/%s/device' % ifname)
 sriov_totalvfs = 0
 if os.path.isdir(dev_path):
  try:
   with open(os.path.join(dev_path, _SRIOV_TOTALVFS)) as fd:
    sriov_totalvfs = int(fd.read())
    return (os.readlink(dev_path).strip('./'), (sriov_totalvfs > 0))
  except (IOError, ValueError):
   return (os.readlink(dev_path).strip('./'), False)
 return (None, False)

def get_function_by_ifname ( ifname ) : dev_path = ( '/sys/class/net/%s/device' % ifname ) sriov_totalvfs = 0 if os . path . isdir ( dev_path ) : try : with open ( os . path . join ( dev_path , _SRIOV_TOTALVFS ) ) as fd : sriov_totalvfs = int ( fd . read ( ) ) return ( os . readlink ( dev_path ) . strip ( './' ) , ( sriov_totalvfs > 0 ) ) except ( IOError , ValueError ) : return ( os . readlink ( dev_path ) . strip ( './' ) , False ) return ( None , False )
given the device name .