Skip to content

Commit

Permalink
Add line number and eid to parsers progression
Browse files Browse the repository at this point in the history
  • Loading branch information
gutard committed Jul 27, 2015
1 parent a4ee149 commit a9e26cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions geotrek/common/management/commands/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ def handle(self, *args, **options):
if not Parser.filename and not Parser.url and len(args) < 2:
raise CommandError("File path missing")

def progress_cb(progress):
def progress_cb(progress, line, eid):
if verbosity >= 2:
self.stdout.write("{progress:02d}%".format(progress=int(100 * progress)))
self.stdout.write("{line:04d}: {eid: <10} ({progress:02d}%)".format(
line=line, eid=eid, progress=int(100 * progress)))

parser = Parser(progress_cb=progress_cb)

Expand Down
2 changes: 1 addition & 1 deletion geotrek/common/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def parse_row(self, row):
self.to_delete.discard(self.obj.pk)
self.nb_success += 1 # FIXME
if self.progress_cb:
self.progress_cb(float(self.line) / self.nb)
self.progress_cb(float(self.line) / self.nb, self.line, self.eid_val)

def report(self):
context = {
Expand Down
4 changes: 2 additions & 2 deletions geotrek/common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def import_datas(filename, class_name, module_name="bulkimport.parsers"):
raise ImportError("Failed to import parser class '{0}' from module '{1}'".format(
class_name, module_name))

def progress_cb(progress):
def progress_cb(progress, line, eid):
current_task.update_state(
state='PROGRESS',
meta={
Expand Down Expand Up @@ -52,7 +52,7 @@ def import_datas_from_web(class_name, module_name="bulkimport.parsers"):
raise ImportError("Failed to import parser class '{0}' from module '{1}'".format(
class_name, module_name))

def progress_cb(progress):
def progress_cb(progress, line, eid):
current_task.update_state(
state='PROGRESS',
meta={
Expand Down

0 comments on commit a9e26cc

Please sign in to comment.