
v^                 @   s8   d  d l  m Z m Z m Z d d   Z d d   Z d S)    )GEOSGeometry	hex_regex	wkt_regexc             C   s   t  |  t  r7 t |  d   }  |  j   } Wd QRXn |  j   } t  | t  r y | j   } Wn t k
 rv Yq Xt j |  s t	 j |  r t
 |  Sn
 t
 |  St
 t |   S)zf
    Given a string file name, returns a GEOSGeometry. The file may contain WKB,
    WKT, or HEX.
    rbN)
isinstancestropenreadbytesdecodeUnicodeDecodeErrorr   matchr   r   
memoryview)Zfile_hbufdecoded r   A/tmp/pip-build-8lau8j11/django/django/contrib/gis/geos/factory.pyfromfile   s    
r   c             K   s   t  |  |  S)z3Given a string value, return a GEOSGeometry object.)r   )stringkwargsr   r   r   fromstr   s    r   N)Z django.contrib.gis.geos.geometryr   r   r   r   r   r   r   r   r   <module>   s   