Created
January 16, 2012 04:58
-
-
Save drhodes/1619145 to your computer and use it in GitHub Desktop.
mirrors .map file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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