mirror of
https://github.com/moparisthebest/xeps
synced 2025-02-28 08:31:45 -05:00
Create tool to generate xep.ent entries
This commit is contained in:
parent
4db628d79b
commit
8aeef7b526
50
tools/makeent.py
Normal file
50
tools/makeent.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import html
|
||||||
|
import xml.etree.ElementTree as etree
|
||||||
|
|
||||||
|
from xeplib import load_xepinfos
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
"-l", "--xeplist",
|
||||||
|
type=argparse.FileType("r"),
|
||||||
|
default=None,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"xeps",
|
||||||
|
metavar="NUM",
|
||||||
|
type=int,
|
||||||
|
nargs="+",
|
||||||
|
)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.xeplist is None:
|
||||||
|
args.xeplist = open("build/xeplist.xml", "r")
|
||||||
|
|
||||||
|
with args.xeplist as f:
|
||||||
|
tree = etree.parse(f)
|
||||||
|
|
||||||
|
accepted, _ = load_xepinfos(tree)
|
||||||
|
|
||||||
|
for num in args.xeps:
|
||||||
|
info = accepted[num]
|
||||||
|
print(
|
||||||
|
"""<!ENTITY xep{number:04d} "<span class='ref'>"""
|
||||||
|
"""<link url='{url}'>{title} (XEP-{number:04d})</link></span> """
|
||||||
|
"""<note>XEP-{number:04d}: {title} <<link url='{url}'>"""
|
||||||
|
"""{url}</link>>.</note>" >""".format(
|
||||||
|
title=html.escape(info["title"]),
|
||||||
|
number=num,
|
||||||
|
url="https://xmpp.org/extensions/xep-{:04d}.html".format(
|
||||||
|
num,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user