<s> """<STR_LIT>""" <EOL> from django . contrib . gis . gdal import DataSource <EOL> from django . contrib . gis . gdal . geometries import GEO_CLASSES <EOL> def ogrinfo ( data_source , num_features = <NUM_LIT:10> ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( data_source , str ) : <EOL> data_source = DataSource ( data_source ) <EOL> elif isinstance ( data_source , DataSource ) : <EOL> pass <EOL> else : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> for i , layer in enumerate ( data_source ) : <EOL> print "<STR_LIT>" % data_source . name <EOL> print "<STR_LIT>" % i <EOL> print "<STR_LIT>" % GEO_CLASSES [ layer . geom_type . num ] . __name__ <EOL> print "<STR_LIT>" % len ( layer ) <EOL> print "<STR_LIT>" % layer . srs <EOL> extent_tup = layer . extent . tuple <EOL> print "<STR_LIT>" % ( extent_tup [ <NUM_LIT:0> : <NUM_LIT:2> ] , extent_tup [ <NUM_LIT:2> : <NUM_LIT:4> ] ) <EOL> print "<STR_LIT>" % num_features <EOL> width = max ( * map ( len , layer . fields ) ) <EOL> fmt = "<STR_LIT>" % width <EOL> for j , feature in enumerate ( layer [ : num_features ] ) : <EOL> print "<STR_LIT>" % j <EOL> for fld_name in layer . fields : <EOL> type_name = feature [ fld_name ] . type_name <EOL> output = fmt % ( fld_name , type_name ) <EOL> val = feature . get ( fld_name ) <EOL> if val : <EOL> if isinstance ( val , str ) : <EOL> val_fmt = '<STR_LIT>' <EOL> else : <EOL> val_fmt = '<STR_LIT>' <EOL> output += val_fmt % val <EOL> else : <EOL> output += '<STR_LIT>' <EOL> print output <EOL> sample = ogrinfo </s>
