improve tools for protocol handling
This commit is contained in:
17
generate.py
17
generate.py
@@ -59,6 +59,9 @@ class Top:
|
||||
else:
|
||||
raise ValueError("One of title or message is needed")
|
||||
|
||||
if self.body is None:
|
||||
self.body = ""
|
||||
|
||||
def __repr__(self):
|
||||
return "<TOP "+self.title+">"
|
||||
|
||||
@@ -92,12 +95,18 @@ def weekday(indate):
|
||||
return WEEKDAYS[indate.weekday()]
|
||||
|
||||
def prototop(top):
|
||||
result = ""
|
||||
|
||||
if "protostub" in dir(top) and top.protostub:
|
||||
return j2env.from_string(top.protostub).render(context, top=top)
|
||||
result = j2env.from_string(top.protostub).render(context, top=top)
|
||||
elif top.body:
|
||||
return j2env.from_string(top.body).render(context)
|
||||
else:
|
||||
return None
|
||||
result = j2env.from_string(top.body).render(context)
|
||||
|
||||
for search,replace in config["protoreplace"].items():
|
||||
result = result.replace(search, replace)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def conf2top(top):
|
||||
sender = None
|
||||
|
||||
Reference in New Issue
Block a user