#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pretty print
import pprint
pp = pprint.PrettyPrinter(indent=2)
import Bookmark

def getPath(item):
  if 'path' in item:
    return item['path']
  return ''

def collect_list(parentPath, current):
  # このフォルダのパスと子供一覧をリストに追加
  children = Bookmark.gatherUrlOrHash(current)
  folder = {
    'path': parentPath,
    'children': children
  }
  outlist = [folder]
  # 子フォルダから再帰的にパスと子供一覧を集める
  child_list = filter(Bookmark.isFolder, Bookmark.getChildren(current))
  def collect_child(child):
    newPath = parentPath + '/' + Bookmark.getTitle(child)
    children = collect_list(newPath, child)
    outlist.extend(children)
  map(collect_child, child_list)
  return outlist

def collect(root):
  # フォルダの一覧を得る
  list = collect_list('', root)
  return list

@@ -132,62 +132,231 @@
  get
-Path(item):%0A  if 'path' in item:%0A    return item%5B'path
+Depth(item):%0A  if 'depth' in item:%0A    return item%5B'depth'%5D%0A  return ''%0A%0Adef getPath(item):%0A  if 'path' in item:%0A    return item%5B'path'%5D%0A  return ''%0A%0Adef getChildren(item):%0A  if 'children' in item:%0A    return item%5B'children
 '%5D%0A 
@@ -390,20 +390,16 @@
 t(parent
-Path
 , curren

add getter depth and children for folder