homer512 icon

Recursion by list stack

homer512 | PRO | 07/27/15 07:58:41 PM UTC | 0 ⭐ | 630 👁️ | Never ⏰ | []
Python |

460 B

|

None

|

0 👍

/

0 👎

def svn_report(report, url, maxdepth=-1):
    dirstack = [(url, 0)]
    while dirstack:
        url, curdepth = dirstack.pop()
        content = getcontent(url)
        for file in content.files:
            report.add(file)
        if curdepth == maxdepth:
            continue
        nextdepth = curdepth + 1
        for directory in content.directories:
            nexturl = url + "/" + directory.href
            dirstack.append((nexturl, nextdepth))

Comments