mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 21:13:25 +00:00
Added a very simple WML parser and support in the webapp to receive upload logs
This commit is contained in:
parent
f6b6ebccd8
commit
5c196334eb
@ -1,9 +1,11 @@
|
||||
import MySQLdb
|
||||
import types
|
||||
import configuration
|
||||
import time
|
||||
import logging
|
||||
import datetime
|
||||
import re
|
||||
|
||||
import configuration
|
||||
|
||||
log = logging.getLogger("wesstats")
|
||||
|
||||
@ -89,3 +91,29 @@ def listfix(l):
|
||||
return [l]
|
||||
return l
|
||||
|
||||
tag = re.compile('^\[.*\]')
|
||||
endtag = re.compile('^\[/.*\]')
|
||||
wmlvar = re.compile('.*=.*')
|
||||
|
||||
def build_tree(lines):
|
||||
vars = dict()
|
||||
i = 0
|
||||
while i < len(lines):
|
||||
l = lines[i].strip()
|
||||
if tag.match(l) and not endtag.match(l):
|
||||
#start of a new wml tag
|
||||
tagname = l[1:len(l)-1]
|
||||
vars[tagname] = build_tree(lines[i+1:])
|
||||
#go past the end of the tag we just processed
|
||||
while lines[i].strip() != ("[/%s]" % (tagname)):
|
||||
i += 1
|
||||
elif endtag.match(l):
|
||||
return vars
|
||||
elif wmlvar.match(l):
|
||||
#variable within tag
|
||||
lvalue = l[0:l.index("=")]
|
||||
rvalue = l[l.index("=")+2:-1]
|
||||
vars[lvalue] = rvalue
|
||||
i += 1
|
||||
return vars
|
||||
|
||||
|
@ -20,6 +20,7 @@ import configuration
|
||||
import helperlib
|
||||
|
||||
from tg import expose
|
||||
import pylons
|
||||
|
||||
from wesstats.lib.base import BaseController
|
||||
from wesstats.controllers.error import ErrorController
|
||||
@ -45,6 +46,12 @@ class RootController(BaseController):
|
||||
@expose(template="wesstats.templates.addview")
|
||||
def addview(self):
|
||||
return dict()
|
||||
|
||||
@expose()
|
||||
def upload(self, **kw):
|
||||
raw_log = pylons.request.body
|
||||
print helperlib.build_tree(raw_log.split('\n'))
|
||||
return dict()
|
||||
|
||||
@expose(template="wesstats.templates.deleteview")
|
||||
def deleteview(self,**kw):
|
||||
|
Loading…
x
Reference in New Issue
Block a user