From e6d29af5a4c0c83e2a9d45a608a541ce1ec71ef4 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Tue, 16 May 2023 16:55:33 +0200 Subject: [PATCH] sync-dbscheme-fragments: add files argument --- config/dbscheme-fragments.json | 1 + config/sync-dbscheme-fragments.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/dbscheme-fragments.json b/config/dbscheme-fragments.json index 0e8c6859fffd..2a56ed57bae0 100644 --- a/config/dbscheme-fragments.json +++ b/config/dbscheme-fragments.json @@ -15,6 +15,7 @@ "/*- Configuration files with key value pairs -*/", "/*- YAML -*/", "/*- XML Files -*/", + "/*- XML: sourceline -*/", "/*- DEPRECATED: External defects and metrics -*/", "/*- DEPRECATED: Snapshot date -*/", "/*- DEPRECATED: Duplicate code -*/", diff --git a/config/sync-dbscheme-fragments.py b/config/sync-dbscheme-fragments.py index 5ada01537e96..266a504691e2 100755 --- a/config/sync-dbscheme-fragments.py +++ b/config/sync-dbscheme-fragments.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 +import argparse import json import os +import pathlib import re @@ -24,7 +26,15 @@ def validate_fragments(fragments): def main(): - script_dir = os.path.dirname(os.path.realpath(__file__)) + script_path = os.path.realpath(__file__) + script_dir = os.path.dirname(script_path) + parser = argparse.ArgumentParser( + prog=os.path.basename(script_path), + description='Sync dbscheme fragments across files.' + ) + parser.add_argument('files', metavar='dbscheme_file', type=pathlib.Path, nargs='*', default=[], + help='dbscheme files to check') + args = parser.parse_args() with open(os.path.join(script_dir, "dbscheme-fragments.json"), "r") as f: config = json.load(f) @@ -32,7 +42,7 @@ def main(): fragment_headers = set(config["fragments"]) fragments = {} ok = True - for file in config["files"]: + for file in args.files + config["files"]: with open(os.path.join(os.path.dirname(script_dir), file), "r") as dbscheme: header = None line_number = 1