summaryrefslogtreecommitdiff
path: root/chimere/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/utils.py')
-rw-r--r--chimere/utils.py25
1 files changed, 8 insertions, 17 deletions
diff --git a/chimere/utils.py b/chimere/utils.py
index 4cd6f45..4ecf3c4 100644
--- a/chimere/utils.py
+++ b/chimere/utils.py
@@ -138,8 +138,9 @@ class ImportManager:
files.append(None)
return files
- def get_source_file(self, source, suffixes, dest_dir=None,
+ def get_source_file(self, suffixes, dest_dir=None,
extra_url=None):
+ source = self.importer_instance.source_file
if not hasattr(source, 'read'):
if not source:
source = self.importer_instance.source \
@@ -182,12 +183,9 @@ class KMLManager(ImportManager):
self.importer_instance = importer_instance
self.ns = ns
- def get(self, source=None):
+ def get(self):
u"""
Get data from the source
- Args:
- - source (None): input file if not provided get it from the distant
- source provided in the importer instance.
Return a tuple with:
- number of new item ;
@@ -196,7 +194,7 @@ class KMLManager(ImportManager):
"""
from models import Marker
new_item, updated_item, msg = 0, 0, ''
- source, msg = self.get_source_file(source, ['.kml'])
+ source, msg = self.get_source_file(['.kml'])
if msg:
return (0, 0, msg)
doc = source
@@ -277,12 +275,9 @@ class ShapefileManager(ImportManager):
u"""
Shapefile importer
"""
- def get(self, source=None):
+ def get(self):
u"""
Get data from the source
- Args:
- - source (None): input file if not provided get it from the distant
- source provided in the importer instance.
Return a tuple with:
- number of new item ;
@@ -292,8 +287,7 @@ class ShapefileManager(ImportManager):
from models import Marker, Route
new_item, updated_item, msg = 0, 0, ''
tmpdir = tempfile.mkdtemp()
- sources, msg = self.get_source_file(source,
- ['.shp', '.dbf', '.prj', '.shx'],
+ sources, msg = self.get_source_file(['.shp', '.dbf', '.prj', '.shx'],
dest_dir=tmpdir)
if msg:
return (0, 0, msg)
@@ -483,19 +477,16 @@ class OSMManager(ImportManager):
"""
default_source = settings.CHIMERE_XAPI_URL
- def get(self, source=None):
+ def get(self):
u"""
Get data from the source
- Args:
- - source (None): input file if not provided get it from the distant
- source provided in the importer instance.
Return a tuple with:
- new items;
- updated items;
- error detail on error.
"""
- source, msg = self.get_source_file(source, ['.osm'],
+ source, msg = self.get_source_file(['.osm'],
extra_url=self.importer_instance.filtr)
if not source:
return (0, 0, msg)