Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/shpimporter.py @ 4978:b5ac7588cf4d dami
Use os.access instead of try/except open
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 13 Feb 2013 19:11:34 +0100 |
parents | ee908e4946cd |
children | f4d61ac84b76 |
comparison
equal
deleted
inserted
replaced
4977:ee908e4946cd | 4978:b5ac7588cf4d |
---|---|
229 DEBUG("%i x geometry type %s" % (types[key], key)) | 229 DEBUG("%i x geometry type %s" % (types[key], key)) |
230 | 230 |
231 if not config.skip_dgm: | 231 if not config.skip_dgm: |
232 dgmfilename = os.path.join( | 232 dgmfilename = os.path.join( |
233 config.directory, "..", "DGMs.csv") | 233 config.directory, "..", "DGMs.csv") |
234 try: | 234 if not os.access(dgmfilename, os.R_OK): |
235 dgmfile = open(dgmfilename, "r") | 235 INFO("Could not find or access DGM file: %s \n" |
236 dgmfile.close() | |
237 except IOError: | |
238 INFO("Could not find DGM file: %s \n" | |
239 "Skipping DGM import." % dgmfilename) | 236 "Skipping DGM import." % dgmfilename) |
240 dgmfilename=None | 237 else: |
241 if dgmfilename: | |
242 INFO("Inserting DGM meta information in 'dem' table.") | 238 INFO("Inserting DGM meta information in 'dem' table.") |
243 insertRiverDgm(dbconn_raw, dgmfilename, river_name, config.dry_run) | 239 insertRiverDgm(dbconn_raw, dgmfilename, river_name, config.dry_run) |
244 | 240 |
245 if __name__ == '__main__': | 241 if __name__ == '__main__': |
246 main() | 242 main() |