Compare commits

..

No commits in common. "ec6a94f18e6d37ff30be5e667dc315c211aa7198" and "28f3d7e6cb7ed5b669882b75d16ac99bd1057ed6" have entirely different histories.

2 changed files with 1 additions and 4581 deletions

View File

@ -1,5 +1,4 @@
import json
import urllib.parse
import os
import re
@ -11,32 +10,16 @@ app = Flask(__name__)
app.config["MONGO_URI"] = os.environ["MONGO_URI"]
mongo = PyMongo(app)
LOCALIZATION_JSON = {}
with open("./db_explorer/en.json") as f:
LOCALIZATION_JSON = json.load(f)
@app.template_filter('filter_vtt')
def filter_vtt(text):
compendium_re = re.compile(r"@Compendium\[([^\]]+)\]\{([^\}]+)\}")
def compendium_return(m):
# TODO: Actually add links
return f"<a>{m.group(2)}</a>"
macro_re = re.compile(r"\[\[\/\S+?r(?:oll)?\s(?:(?P<sdice>[^\{\] ]+)[^\{\]]*|(?:\{(?P<ldice>[^\}]+)\}\[[^\]]+\])?)\]\](?:\{(?P<alt>[^\}]+)\})?")
macro_re = re.compile(r"\[\[\/\S?r\s(?:(?P<sdice>[^\{\] ]+)[^\{\]]*|(?:\{(?P<ldice>[^\}]+)\}\[[^\]]+\])?)\]\](?:\{(?P<alt>[^\}]+)\})?")
def macro_return(m):
if m.group('alt') is not None:
return m.group('alt')
return m.group('sdice')
localize_re = re.compile(r"@Localize\[([^\]]+)\]")
def localize_return(m):
path = m.group(1)
output = LOCALIZATION_JSON
for chunk in path.split('.'):
output = output.get(chunk, {})
if type(output) != str:
output = f"[LOCALIZATION LOOKUP ERROR - {m.group(0)}]"
return output
# Template
text = localize_re.sub(localize_return, text) # Has to be run before Compendium and Macro replacement
text = compendium_re.sub(compendium_return, text)
text = macro_re.sub(macro_return, text)
return text

File diff suppressed because it is too large Load Diff