def is_device(device_name, allow_virtual):
 device_name = re.sub('/', '!', device_name)
 if allow_virtual:
  devicename = (('/sys/block/' + device_name) + '/device')
 else:
  devicename = ('/sys/block/' + device_name)
 return os.access(devicename, os.F_OK)

def is_device ( device_name , allow_virtual ) : device_name = re . sub ( '/' , '!' , device_name ) if allow_virtual : devicename = ( ( '/sys/block/' + device_name ) + '/device' ) else : devicename = ( '/sys/block/' + device_name ) return os . access ( devicename , os . F_OK )
test whether given name is a device or a partition .