Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/shpimporter.py @ 3655:8654e4480fc6
Shape importer: added command line option dry_run to supress database transactions.
flys-backend/trunk@5235 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 22 Aug 2012 13:04:05 +0000 |
parents | 59ca5dab2782 |
children | 890eaa0a5162 |
comparison
equal
deleted
inserted
replaced
3654:59ca5dab2782 | 3655:8654e4480fc6 |
---|---|
60 parser.add_option("--host", type="string") | 60 parser.add_option("--host", type="string") |
61 parser.add_option("--user", type="string") | 61 parser.add_option("--user", type="string") |
62 parser.add_option("--password", type="string") | 62 parser.add_option("--password", type="string") |
63 parser.add_option("--river_id", type="int") | 63 parser.add_option("--river_id", type="int") |
64 parser.add_option("--verbose", type="int", default=1) | 64 parser.add_option("--verbose", type="int", default=1) |
65 parser.add_option("--dry_run", type="int", default=0) | |
65 parser.add_option("--skip_axis", type="int") | 66 parser.add_option("--skip_axis", type="int") |
66 parser.add_option("--skip_hydr_boundaries", type="int") | 67 parser.add_option("--skip_hydr_boundaries", type="int") |
67 parser.add_option("--skip_buildings", type="int") | 68 parser.add_option("--skip_buildings", type="int") |
68 parser.add_option("--skip_crosssections", type="int") | 69 parser.add_option("--skip_crosssections", type="int") |
69 parser.add_option("--skip_lines", type="int") | 70 parser.add_option("--skip_lines", type="int") |
132 config = getConfig() | 133 config = getConfig() |
133 except: | 134 except: |
134 return | 135 return |
135 | 136 |
136 if config == None: | 137 if config == None: |
137 print "No Config" | |
138 ERROR("Unable to read config from command line!") | 138 ERROR("Unable to read config from command line!") |
139 return | 139 return |
140 | |
141 if config.dry_run > 0: | |
142 INFO("You enable 'dry_run'. No database transaction will take place!") | |
140 | 143 |
141 importers = getImporters(config) | 144 importers = getImporters(config) |
142 types = {} | 145 types = {} |
143 | 146 |
144 for importer in importers: | 147 for importer in importers: |
147 continue | 150 continue |
148 | 151 |
149 INFO("Start import of '%s'" % importer.getName()) | 152 INFO("Start import of '%s'" % importer.getName()) |
150 | 153 |
151 shapes = utils.findShapefiles(importer.getPath(config.directory)) | 154 shapes = utils.findShapefiles(importer.getPath(config.directory)) |
152 INFO("Found %i Shapefiles" % len(shapes)) | 155 DEBUG("Found %i Shapefiles" % len(shapes)) |
153 | 156 |
154 for shpTuple in shapes: | 157 for shpTuple in shapes: |
155 geomType = importer.walkOverShapes(shpTuple) | 158 geomType = importer.walkOverShapes(shpTuple) |
156 try: | 159 try: |
157 num = types[geomType] | 160 if geomType is not None: |
158 types[geomType] = num+1 | 161 num = types[geomType] |
162 types[geomType] = num+1 | |
159 except: | 163 except: |
160 types[geomType] = 1 | 164 types[geomType] = 1 |
161 | 165 |
162 for key in types: | 166 for key in types: |
163 DEBUG("%i x geometry type %s" % (types[key], key)) | 167 DEBUG("%i x geometry type %s" % (types[key], key)) |