Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/utils.py @ 5006:769593a84606 dami
Importer: Behold, Logging!
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 15 Feb 2013 16:22:13 +0100 |
parents | 998b29c8d2fd |
children | d6860fca89e4 |
comparison
equal
deleted
inserted
replaced
5005:eb2d6609387c | 5006:769593a84606 |
---|---|
1 import os | 1 import os |
2 import sys | 2 import sys |
3 from shpimporter import DEBUG, INFO, ERROR | 3 import logging |
4 | |
4 try: | 5 try: |
5 from osgeo import ogr | 6 from osgeo import ogr |
6 except ImportErrror: | 7 except ImportErrror: |
7 import ogr | 8 import ogr |
9 | |
10 logger = logging.getLogger("utils") | |
8 | 11 |
9 SHP='.shp' | 12 SHP='.shp' |
10 SQL_SELECT_RIVER_ID="SELECT id FROM rivers WHERE name = %s" | 13 SQL_SELECT_RIVER_ID="SELECT id FROM rivers WHERE name = %s" |
11 | 14 |
12 def findShapefiles(path): | 15 def findShapefiles(path): |
14 | 17 |
15 for root, dirs, files in os.walk(path): | 18 for root, dirs, files in os.walk(path): |
16 if len(files) == 0: | 19 if len(files) == 0: |
17 continue | 20 continue |
18 | 21 |
19 DEBUG("Processing directory '%s' with %i files " % (root, len(files))) | 22 logger.debug("Processing directory '%s' with %i files " % (root, len(files))) |
20 | 23 |
21 for f in files: | 24 for f in files: |
22 idx = f.find(SHP) | 25 idx = f.find(SHP) |
23 if (idx+len(SHP)) == len(f): | 26 if (idx+len(SHP)) == len(f): |
24 shapes.append((f.replace(SHP, ''), root + "/" + f)) | 27 shapes.append((f.replace(SHP, ''), root + "/" + f)) |