changeset 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
files flys-backend/contrib/shpimporter/shpimporter.py
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/shpimporter.py	Wed Feb 13 18:35:37 2013 +0100
+++ b/flys-backend/contrib/shpimporter/shpimporter.py	Wed Feb 13 19:11:34 2013 +0100
@@ -231,14 +231,10 @@
         if not config.skip_dgm:
             dgmfilename = os.path.join(
                     config.directory, "..", "DGMs.csv")
-            try:
-                dgmfile = open(dgmfilename, "r")
-                dgmfile.close()
-            except IOError:
-                INFO("Could not find DGM file: %s \n"
+            if not os.access(dgmfilename, os.R_OK):
+                INFO("Could not find or access DGM file: %s \n"
                      "Skipping DGM import." % dgmfilename)
-                dgmfilename=None
-            if dgmfilename:
+            else:
                 INFO("Inserting DGM meta information in 'dem' table.")
                 insertRiverDgm(dbconn_raw, dgmfilename, river_name, config.dry_run)
 

http://dive4elements.wald.intevation.org