All pastes #640143 Raw Edit

changemaps

public text v1 · immutable
#640143 ·published 2007-07-31 03:38 UTC
rendered paste body
#!/usr/bin/python
import sys, os

maps = (m.strip() for m in sys.stdin)

mapline = "g_maplist "
for m in maps:
	mapline += "'"+m+"'"
if len(sys.argv) == 1:
	print mapline
else:
	lines = []
	foundline = False
	for line in file('server.cfg'):
		if line.startswith('g_maplist '):
			lines.append(False)
			foundline = True
		else:
			lines.append(line)
	out = file('server.cfg', 'w')
	for line in lines:
		if line is False:
			out.write(mapline+os.linesep)
		else:
			out.write(line)
	if not foundline:
		out.write(os.linesep+mapline+os.linesep)
	del out