]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python/samba: adapt ms_schema[_markdown].py to the latest schema definitions
authorStefan Metzmacher <metze@samba.org>
Thu, 23 Feb 2023 14:02:29 +0000 (15:02 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 22 Mar 2023 22:10:32 +0000 (22:10 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/ms_schema.py
python/samba/ms_schema_markdown.py

index 2250fb55e3b1f997ceeb0ea204cfb50213531716..986ae3d6fa7453f8960efbed6e664b7ff8371af5 100644 (file)
@@ -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 = ""
 
index 86c4b6944051fa83d546a3d4fafc7e4ac9681077..8a9ad78b870df4c3f61d8afec331c662975dd872 100644 (file)
@@ -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: