From dcce25ae8a769fe5ea5df7ad0eaa27283b1b34cd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 23 Feb 2023 15:02:29 +0100 Subject: [PATCH] python/samba: adapt ms_schema[_markdown].py to the latest schema definitions Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- python/samba/ms_schema.py | 11 ++++++++++- python/samba/ms_schema_markdown.py | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/python/samba/ms_schema.py b/python/samba/ms_schema.py index 2250fb55e3b..986ae3d6fa7 100644 --- a/python/samba/ms_schema.py +++ b/python/samba/ms_schema.py @@ -90,6 +90,8 @@ def __read_folded_line(f, buffer): """ reads a line from an LDIF file, unfolding it""" line = buffer + attr_type_re = re.compile("^([A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])::?") + while True: l = f.readline() @@ -110,6 +112,12 @@ def __read_folded_line(f, buffer): # eof, definitely won't be folded break else: + if l[:1] != "#" and l != "\n" and l != "": + m = attr_type_re.match(l) + if not m: + line = line + " " + l + continue + # marks end of a folded line # line contains the now unfolded line # buffer contains the start of the next possibly folded line @@ -124,7 +132,8 @@ def __read_raw_entries(f): import sys # will not match options after the attribute type - attr_type_re = re.compile("^([A-Za-z]+[A-Za-z0-9-]*):") + # attributes in the schema definition have at least two chars + attr_type_re = re.compile("^([A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])::?") buffer = "" diff --git a/python/samba/ms_schema_markdown.py b/python/samba/ms_schema_markdown.py index 86c4b694405..8a9ad78b870 100644 --- a/python/samba/ms_schema_markdown.py +++ b/python/samba/ms_schema_markdown.py @@ -51,6 +51,10 @@ def read_ms_markdown(in_file, out_folder): out_path = os.path.join(out_folder, innertext(node).strip()) ldf = open(out_path, 'w') + elif node.tag == 'h2': + if ldf is not None: + ldf.close() + ldf = None elif node.tag == 'p' and ldf is not None: ldf.write(innertext(node).replace('```', '') + '\n') finally: -- 2.11.4.GIT