def print_debug_info(qs, file=None):
 opts = qs.model._mptt_meta
 writer = csv.writer((sys.stdout if (file is None) else file))
 header = (u'pk', opts.level_attr, (u'%s_id' % opts.parent_attr), opts.tree_id_attr, opts.left_attr, opts.right_attr, u'pretty')
 writer.writerow(header)
 for n in qs.order_by(u'tree_id', u'lft'):
  level = getattr(n, opts.level_attr)
  row = []
  for field in header[:(-1)]:
   row.append(getattr(n, field))
  row.append((u'%s%s' % ((u'- ' * level), text_type(n).encode(u'utf-8'))))
  writer.writerow(row)

def print_debug_info ( qs , file = None ) : opts = qs . model . _mptt_meta writer = csv . writer ( ( sys . stdout if ( file is None ) else file ) ) header = ( u'pk' , opts . level_attr , ( u'%s_id' % opts . parent_attr ) , opts . tree_id_attr , opts . left_attr , opts . right_attr , u'pretty' ) writer . writerow ( header ) for n in qs . order_by ( u'tree_id' , u'lft' ) : level = getattr ( n , opts . level_attr ) row = [ ] for field in header [ : ( - 1 ) ] : row . append ( getattr ( n , field ) ) row . append ( ( u'%s%s' % ( ( u'- ' * level ) , text_type ( n ) . encode ( u'utf-8' ) ) ) ) writer . writerow ( row )
given an mptt queryset .