Skip to content

Instantly share code, notes, and snippets.

@akandratovich
Created March 27, 2012 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akandratovich/2213457 to your computer and use it in GitHub Desktop.
Save akandratovich/2213457 to your computer and use it in GitHub Desktop.
generates foldermap, used for dropbox public folder
import os
def write_to(path, content):
f = open(path, 'w')
f.write(content.encode('utf-8'))
f.close()
def make_page(names, pwd):
page = '<body><ul>'
page += '<li><span><a href="../page.html' + '">..</a></span></li>'
for name in names:
href = name
if os.path.isdir(os.path.join(pwd, name)):
href += '/page.html'
page += '<li><span><a href="' + href + '">' + name + '</a></span></li>'
page += '</ul></body>'
write_to(os.path.join(pwd, 'page.html'), page)
def visit(path, folder, names):
make_page(names, os.path.join(path, folder))
if __name__ == '__main__':
path = unicode('.')
os.path.walk(path, visit, path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment