261 |
return normalized |
return normalized |
262 |
|
|
263 |
def open_shapefile(self, filename): |
def open_shapefile(self, filename): |
264 |
"""Open shapefile, eventually with alternative path.""" |
"""Open shapefile, with alternative path handling. |
265 |
|
|
266 |
|
If a shapefile cannot be opened and an IOError is raised, check for |
267 |
|
an alternative. This alternative can be specified interactively by |
268 |
|
the user or taken from a list of (potential) locations, depending on |
269 |
|
the callback implementation. |
270 |
|
|
271 |
|
The alternative is rechecked. If taken from a list the user |
272 |
|
has to confirm the alternative. |
273 |
|
""" |
274 |
|
|
275 |
|
# Flag if the alternative path was specified interactively / from list. |
276 |
from_list = 0 |
from_list = 0 |
277 |
while 1: |
while 1: |
278 |
try: |
try: |
279 |
store = self.theSession.OpenShapefile(filename) |
store = self.theSession.OpenShapefile(filename) |
280 |
if from_list: |
if from_list: |
281 |
# The correct? path has been guessed from a list |
# A valid path has been guessed from a list |
282 |
# Let the user confirm - or select an alternative. |
# Let the user confirm - or select an alternative. |
283 |
filename, from_list = self.shapefile_callback( |
filename, from_list = self.shapefile_callback( |
284 |
filename, "check") |
filename, "check") |
301 |
second_try = from_list) |
second_try = from_list) |
302 |
if filename is None: |
if filename is None: |
303 |
raise LoadCancelled |
raise LoadCancelled |
|
print filename |
|
304 |
else: |
else: |
305 |
raise |
raise |
306 |
return store |
return store |