mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
sync-dbscheme-fragments: add files argument
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
"/*- Configuration files with key value pairs -*/",
|
"/*- Configuration files with key value pairs -*/",
|
||||||
"/*- YAML -*/",
|
"/*- YAML -*/",
|
||||||
"/*- XML Files -*/",
|
"/*- XML Files -*/",
|
||||||
|
"/*- XML: sourceline -*/",
|
||||||
"/*- DEPRECATED: External defects and metrics -*/",
|
"/*- DEPRECATED: External defects and metrics -*/",
|
||||||
"/*- DEPRECATED: Snapshot date -*/",
|
"/*- DEPRECATED: Snapshot date -*/",
|
||||||
"/*- DEPRECATED: Duplicate code -*/",
|
"/*- DEPRECATED: Duplicate code -*/",
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
@@ -24,7 +26,15 @@ def validate_fragments(fragments):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
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:
|
with open(os.path.join(script_dir, "dbscheme-fragments.json"), "r") as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
@@ -32,7 +42,7 @@ def main():
|
|||||||
fragment_headers = set(config["fragments"])
|
fragment_headers = set(config["fragments"])
|
||||||
fragments = {}
|
fragments = {}
|
||||||
ok = True
|
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:
|
with open(os.path.join(os.path.dirname(script_dir), file), "r") as dbscheme:
|
||||||
header = None
|
header = None
|
||||||
line_number = 1
|
line_number = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user