Changed batchprocessor regex matching to not rely on python2.7 feature.
This commit is contained in:
parent
5c212683de
commit
c776a2da18
2 changed files with 16 additions and 7 deletions
|
|
@ -620,7 +620,7 @@ class CmdServerLoad(MuxCommand):
|
||||||
show server load and memory statistics
|
show server load and memory statistics
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@serverload[/mem]
|
@server[/mem]
|
||||||
|
|
||||||
Switch:
|
Switch:
|
||||||
mem - return only a string of the current memory usage
|
mem - return only a string of the current memory usage
|
||||||
|
|
|
||||||
|
|
@ -171,13 +171,17 @@ import traceback
|
||||||
import sys
|
import sys
|
||||||
#from traceback import format_exc
|
#from traceback import format_exc
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from src.utils import logger
|
|
||||||
from src.utils import utils
|
from src.utils import utils
|
||||||
#from game import settings as settings_module
|
#from game import settings as settings_module
|
||||||
|
|
||||||
ENCODINGS = settings.ENCODINGS
|
ENCODINGS = settings.ENCODINGS
|
||||||
CODE_INFO_HEADER = re.compile(r"\(.*?\)")
|
CODE_INFO_HEADER = re.compile(r"\(.*?\)")
|
||||||
|
|
||||||
|
RE_INSERT = re.compile(r"^\#INSERT (.*?)", re.MULTILINE)
|
||||||
|
RE_CLEANBLOCK = re.compile(r"^\#.*?$|^\s*$", re.MULTILINE)
|
||||||
|
RE_CMD_SPLIT = re.compile(r"^\#.*?$", re.MULTILINE)
|
||||||
|
RE_CODE_SPLIT = re.compile(r"(^\#CODE.*?$|^\#HEADER)$", re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
# Helper function
|
# Helper function
|
||||||
|
|
@ -267,9 +271,11 @@ class BatchCommandProcessor(object):
|
||||||
return "\#\n".join(self.parse_file(match.group()))
|
return "\#\n".join(self.parse_file(match.group()))
|
||||||
|
|
||||||
# insert commands from inserted files
|
# insert commands from inserted files
|
||||||
text = re.sub(r"^\#INSERT (.*?)", replace_insert, text, flags=re.MULTILINE)
|
text = RE_INSERT.sub(replace_insert, text)
|
||||||
|
#text = re.sub(r"^\#INSERT (.*?)", replace_insert, text, flags=re.MULTILINE)
|
||||||
# get all commands
|
# get all commands
|
||||||
commands = re.split(r"^\#.*?$", text, flags=re.MULTILINE)
|
commands = RE_CMD_SPLIT.split(text)
|
||||||
|
#commands = re.split(r"^\#.*?$", text, flags=re.MULTILINE)
|
||||||
#remove eventual newline at the end of commands
|
#remove eventual newline at the end of commands
|
||||||
commands = [c.strip('\r\n') for c in commands]
|
commands = [c.strip('\r\n') for c in commands]
|
||||||
commands = [c for c in commands if c]
|
commands = [c for c in commands if c]
|
||||||
|
|
@ -318,15 +324,18 @@ class BatchCodeProcessor(object):
|
||||||
text = "".join(read_batchfile(pythonpath, file_ending='.py'))
|
text = "".join(read_batchfile(pythonpath, file_ending='.py'))
|
||||||
|
|
||||||
def clean_block(text):
|
def clean_block(text):
|
||||||
text = re.sub(r"^\#.*?$|^\s*$", "", text, flags=re.MULTILINE)
|
text = RE_CLEANBLOCK.sub("", text)
|
||||||
|
#text = re.sub(r"^\#.*?$|^\s*$", "", text, flags=re.MULTILINE)
|
||||||
return "\n".join([line for line in text.split("\n") if line])
|
return "\n".join([line for line in text.split("\n") if line])
|
||||||
|
|
||||||
def replace_insert(match):
|
def replace_insert(match):
|
||||||
"Map replace entries"
|
"Map replace entries"
|
||||||
return "\#\n".join(self.parse_file(match.group()))
|
return "\#\n".join(self.parse_file(match.group()))
|
||||||
|
|
||||||
text = re.sub(r"^\#INSERT (.*?)", replace_insert, text, flags=re.MULTILINE)
|
text = RE_INSERT.sub(replace_insert, text)
|
||||||
blocks = re.split(r"(^\#CODE.*?$|^\#HEADER)$", text, flags=re.MULTILINE)
|
#text = re.sub(r"^\#INSERT (.*?)", replace_insert, text, flags=re.MULTILINE)
|
||||||
|
blocks = RE_CODE_SPLIT(text)
|
||||||
|
#blocks = re.split(r"(^\#CODE.*?$|^\#HEADER)$", text, flags=re.MULTILINE)
|
||||||
headers = []
|
headers = []
|
||||||
codes = [] # list of tuples (code, info, objtuple)
|
codes = [] # list of tuples (code, info, objtuple)
|
||||||
if blocks:
|
if blocks:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue