Skip to content

Instantly share code, notes, and snippets.

@drhodes
Created January 16, 2012 04:58
Show Gist options
  • Save drhodes/1619145 to your computer and use it in GitHub Desktop.
Save drhodes/1619145 to your computer and use it in GitHub Desktop.
mirrors .map file
#! /usr/bin/env python
import sys
class Mirror(object):
def __init__(self):
self.mappath = sys.argv[1]
self.infile = open(self.mappath)
self.outfile = open("tmp-mirror.map", 'w')
self.text = self.infile.read()
self.replace()
self.write()
def replace(self):
pairs = [("red", "blue"),
("target_position", "target_pozition"),
("team1", "team2")
]
for t1, t2 in pairs:
self.text = self.text.replace( t1, t2 )
self.text = self.text.replace( t1.capitalize(),
t2.capitalize())
self.text = self.text.replace( t1.upper(),
t2.upper())
def write(self):
self.outfile.write(self.text)
Mirror()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment