Hey,
Since there was apparently no
"wikitizer application" I could find, I wrote one. I hope people use it in the future to update faster the wiki.
I just used it for NMRIH events.
Written in Python 3(.4)
Spoiler
Code:
#By RedSword :D
from tkinter import *
from tkinter.filedialog import askopenfilename
from tkinter.messagebox import showinfo
def get_path():
root = Tk()
root.withdraw()
file_path = askopenfilename(initialdir = "C:/Program Files (x86)/Steam/", title = "choose your file", filetypes = (("res files","*.res"),("all files","*.*")))
return file_path
filePath = get_path( );
if filePath == "" :
showinfo( "No input", "No file input specified. Terminating program." )
exit()
fileToRead = open( filePath, "r")
#showinfo( "Name of the file: ", fileToRead.name )
foundEvents = False
foundEventsLine = 0
depthLevel = 0
currentEvent = 0
currentEventArg = 0
lineCount = 0
eventList = []
argsList = []
while True :
lineCount += 1
line = fileToRead.readline()
if line == "" : #EOF
break
if foundEvents == False :
if line.startswith('"') and line.endswith('events"\n') :# \n needed
foundEvents = True
foundEventsLine = lineCount
else : #found events, we can start parsing
line = line.strip(" \t\r\n")
bracketIndex = line.find("{")
endBracketIndex = line.find("}")
commentIndex = line.find("//")
quoteIndex = line.find('"')
#opening bracket
if bracketIndex == 0 :
depthLevel += 1
elif endBracketIndex == 0 :
depthLevel -= 1
#event/arg name
elif quoteIndex == 0 :
secondQuoteIndex = line.find( '"', quoteIndex + 1 )
eventOrArgName = line[quoteIndex + 1:secondQuoteIndex]
comment = ""
if commentIndex != -1 :
comment = line[commentIndex:].lstrip("/ \t")
#print( eventOrArgName + " : " + comment )
#do something appropriate with event, arg
if depthLevel == 1 : #event; need to do sth w/ comment
#argsList.
eventList.append( ( eventOrArgName, [], comment ) ) #tuple : event : list of kv?
elif depthLevel == 2 : #arg; need to get type and do sth w/ comment
thirdQuoteIndex = line.find('"', secondQuoteIndex + 1)
fourthQuoteIndex = line.find('"', thirdQuoteIndex + 1)
if fourthQuoteIndex == -1 :
print ( "Unrecognized : %s" % line )
typeArg = line[thirdQuoteIndex + 1:fourthQuoteIndex]
event_args_comment = eventList[ - 1 ]
event_args_comment[ 1 ].append( ( eventOrArgName, typeArg, comment ) )
#print( "Adding %r=%r %r" % (eventOrArgName, typeArg, comment) )
else :
print( "Unrecognized : %s" % line )
print ( "Found %d events" % len( eventList ) )
fileToRead.close()
""" to print output to test
tmpCount = 0
for event in eventList :
tmpCount += 1
tmpStr = str( tmpCount )
tmpStr += event[ 0 ]
for arg in event[ 1 ] :
tmpStr += str( arg[0] )
tmpStr += "="
tmpStr += str ( arg[1] )
tmpStr += ";"
print( tmpStr )
"""
filePath += ".output"
fileToWrite = open( filePath, "w")
fileToWrite.write( ":''Refer back to [[Game Events (Source)]] for more events.''\n" )
fileToWrite.write( "\n\n\n" )
for event in eventList :
fileToWrite.write( "=== " + event[ 0 ] + " ===\n" )
fileToWrite.write( "{{qnotice|%s}}\n" % event[ 2 ] )
fileToWrite.write( "{{begin-hl2msg|%s|string}}\n" % event[ 0 ] )
for arg in event[ 1 ] :
fileToWrite.write( "{{hl2msg|%s|%s|%s}}\n" % ( arg[ 1 ], arg[ 0 ], arg[ 2 ] ) )
fileToWrite.write( "{{end-hl2msg}}\n\n" )
fileToWrite.close()
Red
p.s. posting here as it isn't really directly code related; plus anyone can update the wiki
p.p.s. I added a link to here from the wiki event page
Notice : Your modevents.res might be in the .vpk files (happens with CSS/CSGO/DODS/TF2). Use GCFScape to open *_dir.vpk to find the file.
__________________