devabhishekpal commented on code in PR #6916:
URL: https://github.com/apache/ozone/pull/6916#discussion_r1720804790
##########
dev-support/ci/xml_to_md.py:
##########
@@ -0,0 +1,90 @@
+import os
+import re
+import zipfile
+import xml.etree.ElementTree as ET
+from collections import namedtuple
+from pathlib import Path
+
+Property = namedtuple('Property', ['name', 'value', 'tag', 'description'])
+
+def extract_xml_from_jar(jar_path, xml_filename):
+ xml_files = []
+ with zipfile.ZipFile(jar_path, 'r') as jar:
+ for file_info in jar.infolist():
+ if file_info.filename.endswith(xml_filename):
+ with jar.open(file_info.filename) as xml_file:
+ xml_files.append(xml_file.read())
+ return xml_files
+
+def parse_xml_file(xml_content):
+ root = ET.fromstring(xml_content)
+ properties = {}
+ for prop in root.findall('property'):
+ name = prop.find('name').text if prop.find('name') is not None else ''
+ value = prop.find('value').text if prop.find('value') is not None else
''
+ tag = prop.find('tag').text if prop.find('tag') is not None else ''
+ description = prop.find('description').text if
prop.find('description') is not None else ''
+ description = ' '.join(description.split()).strip() if description
else ''
+ properties[name] = Property(name, value, tag, description)
+ return properties
+
+def generate_markdown(properties):
+ markdown = []
+ markdown.append("---\n")
+ markdown.append("title: \"Ozone configurations\"\n")
+ markdown.append("summary: Ozone configurations\n")
+ markdown.append("---\n")
+ markdown.append("<!--\n")
+ markdown.append("Licensed to the Apache Software Foundation (ASF) under
one or more\n")
+ markdown.append("contributor license agreements. See the NOTICE file
distributed with\n")
+ markdown.append("this work for additional information regarding copyright
ownership.\n")
+ markdown.append("The ASF licenses this file to You under the Apache
License, Version 2.0\n")
+ markdown.append("(the \"License\"); you may not use this file except in
compliance with\n")
+ markdown.append("the License. You may obtain a copy of the License
at\n\n")
+ markdown.append(" http://www.apache.org/licenses/LICENSE-2.0\n\n")
+ markdown.append("Unless required by applicable law or agreed to in
writing, software\n")
+ markdown.append("distributed under the License is distributed on an \"AS
IS\" BASIS,\n")
+ markdown.append("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied.\n")
+ markdown.append("See the License for the specific language governing
permissions and\n")
+ markdown.append("limitations under the License.\n")
+ markdown.append("-->\n\n")
+
+ for prop in sorted(properties.values(), key=lambda p: p.name):
+ markdown.append(f"| **Name** | `{prop.name}` |\n")
+ markdown.append("|:----------------|:----------------------------|\n")
+ markdown.append(f"| **Value** | {prop.value} |\n")
+ markdown.append(f"| **Tag** | {prop.tag} |\n")
+ markdown.append(f"| **Description** | {prop.description} |\n")
+
markdown.append("--------------------------------------------------------------------------------\n")
+
+ return ''.join(markdown)
+
+def main():
+ base_path = 'ozone-bin/extracted'
+
+ # Find ozone SNAPSHOT directory dynamically using regex
+ snapshot_dir = next(
+ (os.path.join(base_path, d) for d in os.listdir(base_path) if
re.match(r'ozone-.*-SNAPSHOT', d)),
Review Comment:
Can we change the regex to be more specific?
`r'ozone-[\d.]+\d-SNAPSHOT'`
Current regex will match even if the folder is something like
`ozone-tmp-SNAPSHOT` which we would like to avoid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]