~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to django/contrib/gis/gdal/datasource.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2014-09-17 14:15:11 UTC
  • mfrom: (1.3.17) (6.2.18 experimental)
  • Revision ID: package-import@ubuntu.com-20140917141511-icneokthe9ww5sk4
Tags: 1.7-2
* Release to unstable.
* Add a migrate-south sample script to help users apply their South
  migrations. Thanks to Brian May.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
from django.utils import six
50
50
from django.utils.six.moves import xrange
51
51
 
 
52
 
52
53
# For more information, see the OGR C API source code:
53
54
#  http://www.gdal.org/ogr/ogr__api_8h.html
54
55
#
86
87
        else:
87
88
            raise OGRException('Invalid data source input type: %s' % type(ds_input))
88
89
 
89
 
        if bool(ds):
 
90
        if ds:
90
91
            self.ptr = ds
91
92
            self.driver = Driver(ds_driver)
92
93
        else:
95
96
 
96
97
    def __del__(self):
97
98
        "Destroys this DataStructure object."
98
 
        if self._ptr: capi.destroy_ds(self._ptr)
 
99
        if self._ptr:
 
100
            capi.destroy_ds(self._ptr)
99
101
 
100
102
    def __iter__(self):
101
103
        "Allows for iteration over the layers in a data source."
106
108
        "Allows use of the index [] operator to get a layer at the index."
107
109
        if isinstance(index, six.string_types):
108
110
            l = capi.get_layer_by_name(self.ptr, force_bytes(index))
109
 
            if not l: raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
 
111
            if not l:
 
112
                raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
110
113
        elif isinstance(index, int):
111
114
            if index < 0 or index >= self.layer_count:
112
115
                raise OGRIndexError('index out of range')