File: info.py

package info (click to toggle)
python-asdf 2.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,248 kB
  • sloc: python: 13,104; makefile: 125
file content (45 lines) | stat: -rw-r--r-- 1,278 bytes parent folder | download | duplicates (2)
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
"""
Commands for displaying summaries of ASDF trees
"""

from .main import Command
from .. import _convenience as convenience


__all__ = ["info"]


class Info(Command):
    @classmethod
    def setup_arguments(cls, subparsers):
        parser = subparsers.add_parser(
            "info", help="Print a rendering of an ASDF tree.",
            description="Print a rendering of an ASDF tree."
        )

        parser.add_argument("filename", help="ASDF file to render")
        parser.add_argument(
            "--max-rows",
            type=int,
            help="maximum number of lines"
        )
        parser.add_argument(
            "--max-cols",
            type=int,
            help="maximum length of line")

        parser.add_argument("--show-values", dest="show_values", action="store_true")
        parser.add_argument("--no-show-values", dest="show_values", action="store_false")
        parser.set_defaults(show_values=True)

        parser.set_defaults(func=cls.run)

        return parser

    @classmethod
    def run(cls, args):
        info(args.filename, args.max_rows, args.max_cols, args.show_values)


def info(filename, max_rows, max_cols, show_values):
    convenience.info(filename, max_rows=max_rows, max_cols=max_cols, show_values=show_values)