Advertisement
homer512

Recursion by list stack

Jul 27th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def svn_report(report, url, maxdepth=-1):
  2.     dirstack = [(url, 0)]
  3.     while dirstack:
  4.         url, curdepth = dirstack.pop()
  5.         content = getcontent(url)
  6.         for file in content.files:
  7.             report.add(file)
  8.         if curdepth == maxdepth:
  9.             continue
  10.         nextdepth = curdepth + 1
  11.         for directory in content.directories:
  12.             nexturl = url + "/" + directory.href
  13.             dirstack.append((nexturl, nextdepth))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement