def fileobj_mode(f):
 if (hasattr(f, 'fileobj') and hasattr(f.fileobj, 'mode')):
  fileobj = f.fileobj
 elif hasattr(f, 'fileobj_mode'):
  return f.fileobj_mode
 elif (hasattr(f, 'fp') and hasattr(f.fp, 'mode')):
  fileobj = f.fp
 elif hasattr(f, 'mode'):
  fileobj = f
 else:
  return None
 return _fileobj_normalize_mode(fileobj)

def fileobj_mode ( f ) : if ( hasattr ( f , 'fileobj' ) and hasattr ( f . fileobj , 'mode' ) ) : fileobj = f . fileobj elif hasattr ( f , 'fileobj_mode' ) : return f . fileobj_mode elif ( hasattr ( f , 'fp' ) and hasattr ( f . fp , 'mode' ) ) : fileobj = f . fp elif hasattr ( f , 'mode' ) : fileobj = f else : return None return _fileobj_normalize_mode ( fileobj )
returns the mode string of a file-like object if such a thing exists .