Dmitri Lebedev  committed 5041b9f

load_callback will always get parent argument.

  • Participants
  • Parent commits 3ad8e0b
  • Branches default

Comments (0)

Files changed (1)

 If you want to save the elements into a custom storage, define a callback:
->>> def cb(current, parent=None):
+>>> def cb(current, parent):
         print current
 >>> load_osm(open('my_file.osm'), cb)
 	if not load_callback:
 		def load_callback(current, parent=None):
-			target = parent['children'] if parent else load_osm.elements
-			target.append(current)
+			parent['children'].append(current)
 	element_filter = element_filter or default_element_filter
 	def end_element(name):
 		if load_osm.current and element_filter(load_osm.current):
-			parent = load_osm.stack.pop() if load_osm.stack else None
+			parent = load_osm.stack.pop() if load_osm.stack else load_osm.elements
 			load_callback(load_osm.current, parent)
 			load_osm.current = parent