def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions, KgtkReaderMode from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str)->str: if _expert: return msg else: return SUPPRESS parser.add_input_file(who="The KGTK file to convert to an HTML table.", positional=True) parser.add_output_file(who="The GitHub markdown file to write.") parser.add_argument( "--output-format", dest="output_format", help=h("The file format (default=%(default)s)"), type=str, default="table") KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, default_mode=KgtkReaderMode.NONE, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions from kgtk.utils.argparsehelpers import optional_bool from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert parser.add_input_file(positional=True, optional=False) parser.add_output_file( who= "Graph tool file to dump the graph too - if empty, it will not be saved.", optional=True) parser.add_argument( '--undirected', dest="undirected", help="When True, the graph is undirected. (default=%(default)s)", type=optional_bool, nargs='?', const=True, default=False, metavar="True|False") KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ _expert: bool = parsed_shared_args._expert parser.add_argument( "kgtk_files", nargs="*", help="The KGTK file(s) to validate. May be omitted or '-' for stdin.", type=Path) parser.add_argument( "--header-only", dest="header_only", help= "Process the only the header of the input file (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=False) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, validate_by_default=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions from kgtk.utils.argparsehelpers import optional_bool from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert parser.add_input_file(who="The KGTK file(s) to validate.", dest="input_files", options=["-i", "--input-files"], allow_list=True, positional=True) parser.add_argument( "--header-only", dest="header_only", help= "Process the only the header of the input file (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=False) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, validate_by_default=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ _expert: bool = parsed_shared_args._expert # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str)->str: if _expert: return msg else: return SUPPRESS parser.add_argument( "input_kgtk_file", nargs="?", type=Path, default="-", help="The KGTK file to filter. May be omitted or '-' for stdin (default=%(default)s).") parser.add_argument("-o", "--output-file", dest="output_kgtk_file", help="The KGTK file to write (default=%(default)s).", type=Path, default="-") KgtkIdBuilderOptions.add_arguments(parser, expert=True) # Show all the options. KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert parser.add_input_file(positional=True) parser.add_output_file() parser.add_argument( "--columns", dest="key_column_names", help= "The key columns will not be expanded. They will be repeated on each output record. " + "(default=id for node files, (node1, label, node2) for edge files).", nargs='+', default=[]) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.value.kgtkvalueoptions import KgtkValueOptions from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions _expert: bool = parsed_shared_args._expert parser.add_input_file() parser.add_argument('--output-path', action='store', type=str, dest="output_path", required=True, help="Path of an existing folder where the split files will be written") parser.add_argument('--file-prefix', action='store', type=str, default='split_', dest='file_prefix', required=False, help="file name prefix, will be appended to output file names before a number") parser.add_argument('--split-by-qnode', default=False, action="store_true", dest='split_by_qnode', help="If specified, all edges for a qnode will be written to a separate file, " "qnode will be added to the file name. WARNING: If there are millions of Qnodes, " "this option will create millions of file." " Default [FALSE]") parser.add_argument('--gzipped-output', default=False, action="store_true", dest='gzipped_output', help="If specified, the output split files will be gzipped. Default FALSE") parser.add_argument('--lines', action='store', dest='lines', type=int, default=1000000, required=False, help="number of lines in each split file. The actual number of lines will exceed this number, " "since Qnode boundaries are preserved.") KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ # import modules locally from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions from kgtk.utils.argparsehelpers import optional_bool from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str) -> str: if _expert: return msg else: return SUPPRESS parser.add_input_file() parser.add_output_file() parser.add_argument("--output-format", dest="output_format", help=h("The file format (default=kgtk)"), type=str) parser.add_argument( '-c', "--columns", dest="column_names", required=True, nargs='+', metavar="COLUMN_NAME", help= "The list of source column names, optionally containing '..' for column ranges " + "and '...' for column names not explicitly mentioned.") parser.add_argument( "--into", dest="into_column_name", help="The name of the column to receive the result of the calculation.", required=True) parser.add_argument("--do", dest="operation", help="The name of the operation.", required=True, choices=["percentage"]) parser.add_argument("--format", dest="format_string", help="The format string for the calculation.") KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments(parser: KGTKArgumentParser): """ Parse arguments Args: parser (argparse.ArgumentParser) """ parser.add_input_file(positional=True) parser.add_argument('--english_only', action="store_true", help="Only english conceptnet?")
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderMode, KgtkReaderOptions from kgtk.io.kgtkwriter import KgtkWriter from kgtk.utils.argparsehelpers import optional_bool from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str)->str: if _expert: return msg else: return SUPPRESS parser.add_input_file(who="KGTK input files", dest="input_files", options=["-i", "--input-files"], allow_list=True, positional=True) parser.add_output_file() parser.add_argument( "--output-format", dest="output_format", help="The file format (default=kgtk)", type=str, choices=KgtkWriter.OUTPUT_FORMAT_CHOICES) parser.add_argument( "--output-columns", dest="output_column_names", metavar="NEW_COLUMN_NAME", help=h("The list of new column names when renaming all columns."), type=str, nargs='+') parser.add_argument( "--old-columns", dest="old_column_names", metavar="OLD_COLUMN_NAME", help=h("The list of old column names for selective renaming."), type=str, nargs='+') parser.add_argument( "--new-columns", dest="new_column_names", metavar="NEW_COLUMN_NAME", help=h("The list of new column names for selective renaming."), type=str, nargs='+') parser.add_argument( "--no-output-header", dest="no_output_header", metavar="True|False", help=h("When true, do not write a header to the output file (default=%(default)s)."), type=optional_bool, nargs='?', const=True, default=False) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, default_mode=KgtkReaderMode[parsed_shared_args._mode], expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.exceptions import KGTKException from kgtk.lift.kgtklift import KgtkLift from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions from kgtk.utils.argparsehelpers import optional_bool from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert _command: str = parsed_shared_args._command # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str) -> str: if _expert: return msg else: return SUPPRESS parser.add_input_file() parser.add_output_file() # The default value for this option depends upon the command used. parser.add_argument( '-l', '--lines', dest="count_records", metavar="True/False", help="If true, count records and print a single number to stdout. " + "If false, count non-empty values per column and produce a simple KGTK output file. (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=DEFAULT_COUNT_RECORDS_WC if _command == WC_COMMAND else DEFAULT_COUNT_RECORDS) # This is an expert option. It will not show up on `--help` without `--expert`: parser.add_argument( "--count-property", dest="count_property", help= h("The property used for column count output edges. (default=%(default)s)." ), default=DEFAULT_COUNT_PROPERTY) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ _expert: bool = parsed_shared_args._expert parser.add_argument( "input_kgtk_file", nargs="?", help="The KGTK file to filter. May be omitted or '-' for stdin.", type=Path) parser.add_argument( "--columns", dest="filter_column_names", help="The columns in the file being filtered (Required).", nargs='+', required=True) parser.add_argument( "--count", dest="only_count", help="Only count the records, do not copy them. (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=False) parser.add_argument("-o", "--output-file", dest="output_kgtk_file", help="The KGTK file to write (default=%(default)s).", type=Path, default="-") parser.add_argument( "--all", dest="all_are", help= "False: Test if any are, True: test if all are (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=False) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments(parser: KGTKArgumentParser): """ Parse arguments Args: parser (kgtk.cli_argparse.KGTKArgumentParser) """ parser.add_argument(action="store", type=str, metavar="name", dest="name") parser.add_argument("-i", "--info", action="store", type=str, dest="info") parser.add_argument("-e", "--error", action="store_true", help="raise an error") parser.accept_shared_argument('_debug')
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions, KgtkReaderMode from kgtk.io.kgtkwriter import KgtkWriter from kgtk.utils.argparsehelpers import optional_bool from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str) -> str: if _expert: return msg else: return SUPPRESS parser.add_input_file(who="The KGTK file to convert to an HTML table.", positional=True) parser.add_output_file(who="The GitHub markdown file to write.") parser.add_argument( "--pp", "--readable", dest="readable", help= "If true, use a human-readable output format. (default=%(default)s).", metavar="True/False", type=optional_bool, nargs='?', const=True, default=False) parser.add_argument("--output-format", dest="output_format", type=str, help=h("The file format (default=%(default)s)"), default=KgtkWriter.OUTPUT_FORMAT_HTML_COMPACT) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, default_mode=KgtkReaderMode.NONE, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ _expert: bool = parsed_shared_args._expert parser.add_input_file(positional=True, who="The KGTK file to find connected components in.") parser.add_output_file() parser.add_argument("--no-header", action="store_true", dest="no_header", help="Specify if the input file does not have a header, default FALSE") parser.add_argument("--properties", action="store", type=str, dest="properties", help=' A comma separated list of properties to traverse while finding connected components, ' 'by default all properties will be considered', default='') parser.add_argument('--undirected', action='store_true', dest="undirected", help="Specify if the input graph is undirected, default FALSE") parser.add_argument('--strong', action='store_true', dest="strong", help="Treat graph as directed or not, independent of its actual directionality.") # CMR: The folowing options aren't used. Is the intent to support them, or # was this cut-and-paste overkill? KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, who="input", expert=_expert, defaults=False)
def add_arguments(parser: KGTKArgumentParser): """ Parse arguments Args: parser (argparse.ArgumentParser) """ parser.add_input_file(positional=True) parser.add_argument('--directed', action='store_true', dest="directed", help="Is the graph directed or not?") parser.add_argument('--max_hops', action="store", type=int, dest="max_hops", help="Maximum number of hops allowed.") parser.add_argument('--from', action="store", nargs="*", dest="source_nodes", help="List of source nodes") parser.add_argument('--to', action="store", nargs="*", dest="target_nodes", help="List of target nodes")
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions, KgtkReaderMode from kgtk.utils.argparsehelpers import optional_bool from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert parser.add_input_file(positional=True) parser.add_output_file() parser.add_argument('-c', "--columns", action="store", type=str, dest="columns", nargs='+', required=True, help="Columns to remove as a comma- or space-separated strings, e.g., id,docid or id docid") parser.add_argument( "--split-on-commas", dest="split_on_commas", help="Parse the list of columns, splitting on commas. (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=True) parser.add_argument( "--split-on-spaces", dest="split_on_spaces", help="Parse the list of columns, splitting on spaces. (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=False) parser.add_argument( "--strip-spaces", dest="strip_spaces", help="Parse the list of columns, stripping whitespace. (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=True) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, default_mode=KgtkReaderMode.NONE, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ _expert: bool = parsed_shared_args._expert parser.add_argument( "input_file", nargs="?", help="The KGTK file to read. May be omitted or '-' for stdin.", type=Path) parser.add_argument( "output_file", nargs="?", help="The KGTK file to write. May be omitted or '-' for stdout.", type=Path) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, validate_by_default=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions, KgtkReaderMode from kgtk.io.kgtkwriter import KgtkWriter from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str) -> str: if _expert: return msg else: return SUPPRESS parser.add_input_file() parser.add_output_file() parser.add_argument( "-n", "--edges", dest="edge_limit", type=int, default=10, help="The number of records to pass if positive (default=%(default)d)." ) parser.add_argument("--output-format", dest="output_format", help=h("The file format (default=kgtk)"), type=str, choices=KgtkWriter.OUTPUT_FORMAT_CHOICES) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, default_mode=KgtkReaderMode.NONE, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments(parser: KGTKArgumentParser): """ Parse arguments Args: parser (argparse.ArgumentParser) """ parser.add_input_file(positional=True) parser.add_argument('--english_only', action="store_true", help="Only english conceptnet?") parser.add_output_file() parser.add_output_file( who="A KGTK output file that will contain only the weights.", dest="weights_file", options=["--weights-file"], metavar="WEIGHTS_FILE", optional=True)
def add_arguments(parser: KGTKArgumentParser): """ Parse arguments Args: parser (argparse.ArgumentParser) """ parser.add_input_file(positional=True) parser.add_argument('--relation', action="store", default="/r/RelatedTo", type=str, dest="relation", help="Relation to connect the word pairs with.") parser.add_argument('--source', action="store", type=str, dest="source", help="Source identifier")
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str) -> str: if _expert: return msg else: return SUPPRESS parser.add_input_file(positional=True) parser.add_output_file() parser.add_argument("--output-format", dest="output_format", help=h("The file format (default=kgtk)"), type=str) parser.add_argument( "--output-columns", dest="output_column_names", metavar="NEW_COLUMN_NAME", help="The list of new column names when renaming all columns.", type=str, nargs='+') parser.add_argument( "--old-columns", dest="old_column_names", metavar="OLD_COLUMN_NAME", help="The list of old column names for selective renaming.", type=str, nargs='+') parser.add_argument( "--new-columns", dest="new_column_names", metavar="NEW_COLUMN_NAME", help="The list of new column names for selective renaming.", type=str, nargs='+') KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.utils.argparsehelpers import optional_bool # These special shared aruments inticate whether the `--expert` option # was supplied and the command name that was used. _expert: bool = parsed_shared_args._expert _command: str = parsed_shared_args._command # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str) -> str: if _expert: return msg else: return SUPPRESS # KGTK Browser hostname parser.add_argument( '--host', dest="kgtk_browser_host", help="Hostname used to launch flask server, defaults to localhost", default="localhost", ) # KGTK Browser port number parser.add_argument( '-p', '--port', dest="kgtk_browser_port", help="Port number used to launch flask server, defaults to 5000", default="5000", ) # KGTK Browser configuration file parser.add_argument( '-c', '--config', dest="kgtk_browser_config", help="KGTK Browser configuration file, defaults to `kgtk_browser_config.py`", default="kgtk_browser_config.py", ) # KGTK Browser application file parser.add_argument( '-a', '--app', dest="kgtk_browser_app", help="KGTK Browser flask application file, defaults to `kgtk_browser_app.py`", default="kgtk_browser_app.py", )
def add_arguments(parser: KGTKArgumentParser): parser.add_argument('-o', '--out', default=None, dest='output', help='output file to write to, otherwise output goes to stdout') parser.add_argument('--gz', '--gzip', action='store_true', dest='gz', help='compress result with gzip') parser.add_argument('--bz2', '--bzip2', action='store_true', dest='bz2', help='compress result with bzip2') parser.add_argument('--xz', action='store_true', dest='xz', help='compress result with xz') # parser.add_argument("inputs", metavar="INPUT", nargs="*", action="store", # help="input files to process, if empty or `-' read from stdin") parser.add_input_file(positional=True, allow_list=True, dest="input_files")
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions, KgtkReaderMode from kgtk.utils.argparsehelpers import optional_bool from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert parser.add_input_file() parser.add_output_file() parser.add_output_file(who="The tee output file", dest="into_file", options=["--into-file"], metavar="INTO_FILE", optional=False, allow_list=False, allow_stdout=False, default_stdout=False) parser.add_argument( "--enable", dest="enable", help= "When True, enable copying the data stream to the --into-file. (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=True) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, default_mode=KgtkReaderMode.NONE, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ _expert: bool = parsed_shared_args._expert # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str)->str: if _expert: return msg else: return SUPPRESS parser.add_argument( "input_file_path", help="The KGTK file to convert to a GitHub markdown table.", type=Path, nargs='?', default=Path("-")) parser.add_argument("-o", "--output-file", dest="output_file_path", help="The KGTK file to write (default=%(default)s).", type=Path, default="-") parser.add_argument( "--output-format", dest="output_format", help=h("The file format (default=%(default)s)"), type=str, default="md") KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ _expert: bool = parsed_shared_args._expert parser.add_input_file(positional=True) parser.add_output_file() parser.add_argument( "--columns", dest="filter_column_names", help="The columns in the file being filtered (Required).", nargs='+', required=True) parser.add_argument( "--count", dest="only_count", metavar="True|False", help="Only count the records, do not copy them. (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=False) parser.add_argument( "--all", dest="all_are", metavar="True|False", help="False: Test if any are not empty, True: test if all are not empty (default=%(default)s).", type=optional_bool, nargs='?', const=True, default=False) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)
def add_arguments(parser: KGTKArgumentParser): """ Parse arguments Args: parser (argparse.ArgumentParser) """ parser.add_input_file(positional=True) parser.add_input_file(who="KGTK file with path start and end nodes.", options=["--path_file"], dest="path_file", metavar="PATH_FILE") parser.add_argument( '--statistics-only', action='store_true', dest='output_stats', help= 'If this flag is set, output only the statistics edges. Else, append the statistics to the original graph.' ) parser.add_argument('--directed', action='store_true', dest="directed", help="Is the graph directed or not?") parser.add_argument('--max_hops', action="store", type=int, dest="max_hops", help="Maximum number of hops allowed.")
def add_arguments(parser: KGTKArgumentParser): """ Parse arguments Args: parser (argparse.ArgumentParser) """ parser.add_input_file(positional=True, optional=False) parser.add_output_file( who= "Graph tool file to dump the graph too - if empty, it will not be saved.", optional=True) parser.add_argument('--directed', action='store_true', dest="directed", help="Is the graph directed or not?") parser.add_argument( '--log', action='store', type=str, dest='log_file', help='Log file for summarized statistics of the graph.', default="./log.txt")
def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Namespace): """ Parse arguments Args: parser (argparse.ArgumentParser) """ # import modules locally from kgtk.io.kgtkreader import KgtkReader, KgtkReaderOptions, KgtkReaderMode from kgtk.utils.argparsehelpers import optional_bool from kgtk.value.kgtkvalueoptions import KgtkValueOptions _expert: bool = parsed_shared_args._expert _command: str = parsed_shared_args._command # This helper function makes it easy to suppress options from # The help message. The options are still there, and initialize # what they need to initialize. def h(msg: str)->str: if _expert: return msg else: return SUPPRESS parser.add_input_file() parser.add_output_file() parser.add_argument( "--output-format", dest="output_format", help=h("The file format (default=kgtk)"), type=str) parser.add_argument('-c', "--columns", "--column", dest="column_names_list", required=True, nargs='+', action="append", default=list(), metavar="COLUMN_NAME", help="The list of reordered column names, optionally containing '...' for column names not explicitly mentioned.") parser.add_argument( "--as", "--as-columns", "--as-column", dest="as_column_names_list", nargs='+', action="append", default=list(), metavar="COLUMN_NAME", help="Replacement column names.") parser.add_argument( "--trim", dest="omit_remaining_columns", help="If true, omit unmentioned columns. (default=%(default)s).", metavar="True|False", type=optional_bool, nargs='?', const=True, default=(_command == SELECT_COLUMNS_COMMAND)) KgtkReader.add_debug_arguments(parser, expert=_expert) KgtkReaderOptions.add_arguments(parser, mode_options=True, default_mode=KgtkReaderMode.NONE, expert=_expert) KgtkValueOptions.add_arguments(parser, expert=_expert)