Skip to content

Instantly share code, notes, and snippets.

@ambv
Created July 23, 2010 11:07
Show Gist options
  • Save ambv/487293 to your computer and use it in GitHub Desktop.
Save ambv/487293 to your computer and use it in GitHub Desktop.
import os
import re
import stat
import sys
if sys.version_info < (3, 1):
sys.stderr.write("Python 3.1+ required. Sorry.")
sys.exit(0)
READ_WRITE = re.compile(b"svn\+ssh://pythondev@svn\.python\.org")
ANONYMOUS = b"http://svn.python.org/projects"
def change_entries(directory):
entries_file = os.path.join(directory, 'entries')
print(entries_file)
if os.path.isfile(entries_file):
with open(entries_file, "br") as old_entries:
entries = old_entries.read()
os.chmod(entries_file, stat.S_IREAD | stat.S_IWRITE |
stat.S_IRGRP | stat.S_IROTH)
with open(entries_file, "bw") as new_entries:
entries = READ_WRITE.sub(ANONYMOUS, entries)
new_entries.write(entries)
os.chmod(entries_file, stat.S_IREAD | stat.S_IRGRP |
stat.S_IROTH)
def walk(directory):
for d in os.listdir(directory):
full_path = os.path.join(directory, d)
if os.path.isdir(full_path):
if d.lower() in ('.svn', '_svn'):
change_entries(full_path)
walk(full_path)
if __name__ == '__main__':
walk('.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment