forked from bentley-historical-library/baroque
-
Notifications
You must be signed in to change notification settings - Fork 0
/
baroque.py
65 lines (55 loc) · 2.42 KB
/
baroque.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import argparse
from baroque import defaults
from baroque.baroque_project import BaroqueProject
from baroque.config import get_config_setting
from baroque.mets_validation import MetsValidator
from baroque.report_generation import generate_reports
from baroque.structure_validation import StructureValidator
from baroque.wav_bext_chunk_validation import WavBextChunkValidator
def main():
parser = argparse.ArgumentParser()
parser.add_argument("source", help="Path to source directory")
parser.add_argument("export", help="Path to metadata export")
parser.add_argument("-d", "--destination", help="Path to destination for reports")
action_args = parser.add_argument_group("actions")
action_args.add_argument(
"-s", "--structure", dest="actions",
action="append_const", const="structure",
help="Validate directory and file structure"
)
action_args.add_argument(
"-m", "--mets", dest="actions",
action="append_const", const="mets",
help="Validate METS"
)
action_args.add_argument(
"-w", "--wav", dest="actions",
action="append_const", const="wav",
help="Validate WAV BEXT chunks"
)
action_args.add_argument(
"--all", dest="actions", action="store_const",
const=["structure", "mets", "wav"],
help="Run all validations"
)
args = parser.parse_args()
if args.actions:
actions = set(args.actions)
else:
parser.error("Please supply a validation action.")
if args.destination:
destination = args.destination
else:
destination = get_config_setting("destination", default=defaults.REPORTS_DIR)
project = BaroqueProject(args.source, destination, args.export)
if "structure" in actions:
StructureValidator(project).validate()
if "mets" in actions:
MetsValidator(project).validate()
if "wav" in actions:
WavBextChunkValidator(project).validate()
generate_reports(project)
if __name__ == "__main__":
print("SYSTEM ACTIVITY: baroque starting")
main()
print("SYSTEM ACTIVITY: baroque finished")