Debian Codegraph @

nixio/cmd/main.py

raw symbols SCIP
1 """
2 Command line interface for nixio tools.
3
4 nixio explore: Print file information, data, or metadata, with support for
5 filtering and plotting.
6 nixio validate: Check NIX files for missing or inconsistent objects and
7 annotations.
8 nixio upgrade: Update older files to the newest file format.
9 """
10 import sys
11 import argparse
12 from . import explore, validate, upgrade
13
14
15 def main():
16 parser = argparse.ArgumentParser(
17 description="Command line interface for nixio tools"
18 )
19 if sys.version_info.major < 3 or sys.version_info.minor < 6:
20 raise RuntimeError("nixio does not support python versions less than 3.6!")
21 if sys.version_info.minor < 7:
22 subcmds = parser.add_subparsers(title="commands", dest="cmd")
23 else:
24 subcmds = parser.add_subparsers(title="commands", required=True,
25 dest="cmd")
26
27 # nixio explore
28 explore_cmd = subcmds.add_parser("explore", help=explore.__doc__)
29 explore.create_subcmd_parsers(explore_cmd)
30
31 # nixio validate
32 validate_cmd = subcmds.add_parser("validate", help=validate.__doc__)
33 validate.create_subcmd_parser(validate_cmd)
34
35 # nixio upgrade
36 upgrade_cmd = subcmds.add_parser("upgrade", help=upgrade.__doc__)
37 upgrade.create_subcmd_parser(upgrade_cmd)
38
39 cmdmap = {
40 "explore": explore.main,
41 "validate": validate.main,
42 "upgrade": upgrade.main
43 }
44
45 args = parser.parse_args()
46 cmd = args.cmd
47 cmdmap[cmd](args)
48
49
50 if __name__ == "__main__":
51 main()