def fromfile(file_h):
 if isinstance(file_h, str):
  with open(file_h, 'rb') as file_h:
   buf = file_h.read()
 else:
  buf = file_h.read()
 if isinstance(buf, bytes):
  try:
   decoded = buf.decode()
   if (wkt_regex.match(decoded) or hex_regex.match(decoded)):
    return GEOSGeometry(decoded)
  except UnicodeDecodeError:
   pass
 else:
  return GEOSGeometry(buf)
 return GEOSGeometry(memoryview(buf))

def fromfile ( file_h ) : if isinstance ( file_h , str ) : with open ( file_h , 'rb' ) as file_h : buf = file_h . read ( ) else : buf = file_h . read ( ) if isinstance ( buf , bytes ) : try : decoded = buf . decode ( ) if ( wkt_regex . match ( decoded ) or hex_regex . match ( decoded ) ) : return GEOSGeometry ( decoded ) except UnicodeDecodeError : pass else : return GEOSGeometry ( buf ) return GEOSGeometry ( memoryview ( buf ) )
parse patch file .