1# Copyright 2020 pydicom authors. See LICENSE file for details.
2"""Pydicom command line interface program for codify"""
3
4import argparse
5
6import pydicom.util.codify
7
8
9default_exclude_size = 100
10
11
12def add_subparser(subparsers: argparse._SubParsersAction) -> None:
13    codify_parser = subparsers.add_parser(
14        "codify",
15        description=(
16            "Read a DICOM file and produce the pydicom (Python) "
17            "code which can create that file"
18        ),
19        epilog=(
20            "Binary data (e.g. pixels) larger than --exclude-size "
21            f"(default {default_exclude_size} bytes) is not included. "
22            "A dummy line with a syntax error is produced. "
23            "Private data elements are not included by default."
24        ),
25    )
26
27    # Codify existed before as a stand-alone before, re-use it here
28    pydicom.util.codify.set_parser_arguments(
29        codify_parser, default_exclude_size
30    )
31    codify_parser.set_defaults(func=pydicom.util.codify.do_codify)
32