#NEWLINE# def load_datasource( datasource , where = None ) : #NEWLINE# #INDENT# '\n    Loads polygons from WKT text files or OGR datasources.\n\n    Returns a list of Shapely Polygons.\n    ' #NEWLINE# if os . path . exists ( os . path . abspath ( datasource ) ) : #NEWLINE# #INDENT# with open ( os . path . abspath ( datasource ) , 'r' ) as fp : #NEWLINE# #INDENT# data = fp . read ( 50 ) #NEWLINE# #UNINDENT# if data . lower ( ) . lstrip ( ) . startswith ( ( 'polygon' , 'multipolygon' ) ) : #NEWLINE# #INDENT# return load_polygons ( datasource ) #NEWLINE# #UNINDENT# #UNINDENT# return load_ogr_datasource ( datasource , where = where )