def list_categories(args): imgsrc = ImgSrc(username, password) categories = imgsrc.get_categories() for i in categories: if int(i['parent_id']) == 0: print "+ %s : %s" % (i['id'], i['name']) for j in categories: if int(j['parent_id']) == int(i['id']): print " + %s : %s" % (j['id'], j['name'])