<commit_before>#
# Copyright (c) 2019 UAVCAN Development Team
# This software is distributed under the terms of the MIT License.
# Author: <NAME> <<EMAIL>>
#

import typing
import logging
import argparse
import pyuavcan
from . import _base


INFO = _base.CommandInfo(
    help='''
Subscribe to the specified subject, receive and print messages into stdout.
'''.strip(),
    examples=f'''
pyuavcan sub uavcan.node.Heartbeat.1
'''.strip(),
    aliases=[
        'sub',
    ]
)


_logger = logging.getLogger(__name__)


def register_arguments(parser: argparse.ArgumentParser) -> None:
    parser.add_argument(
        'full_data_type_name_with_version',
        help='''
The full data type name with version. The minor version number may be omitted,
in which case the newest known version will be used.
Example: uavcan.node.Heartbeat.1.0
'''.strip(),
    )
    parser.add_argument(
        'subject_id',
        type=int,
        nargs='?',
        help='''
The subject ID to subscribe to. If not specified, the fixed subject ID will
be used, if such is available for the selected version of the data type. If
the argument is not specified and the fixed subject ID is not defined for the
selected data type, the command will exit immediately with an error.
'''.strip(),
    )
    format_choices = ['yaml', 'json-line', 'tsv']
    parser.add_argument(
        '--format',
        choices=format_choices,
        default=format_choices[0],
        help='''
The representation of the data printed into stdout.
Default: %(default)s
'''.strip(),
    )


def execute(args: argparse.Namespace) -> int:
    full_data_type_name_with_version = str(args.full_data_type_name_with_version)
    subject_id: typing.Optional[int] = int(args.subject_id) if args.subject_id is not None else None
    print('full_data_type_name_with_version:', full_data_type_name_with_version)
    print('subject_id:                      ', subject_id)
    # TODO implement
    return 1<commit_msg>subscriber tool command line args refactored to support multi-subject subscription in the future<commit_after>#
# Copyright (c) 2019 UAVCAN Development Team
# This software is distributed under the terms of the MIT License.
# Author: <NAME> <<EMAIL>>
#

import typing
import logging
import argparse
import pyuavcan
from . import _base


INFO = _base.CommandInfo(
    help='''
Subscribe to the specified subject, receive and print messages into stdout.
'''.strip(),
    examples=f'''
pyuavcan sub uavcan.node.Heartbeat.1
'''.strip(),
    aliases=[
        'sub',
    ]
)


_logger = logging.getLogger(__name__)


def register_arguments(parser: argparse.ArgumentParser) -> None:
    parser.add_argument(
        'data_id',
        metavar='[subject_id.]full_data_type_name.version_major[.version_minor]',
        help='''
The full data type name with version and optional subject ID.
If the subject ID is not specified, the fixed subject ID will be used,
if such is available for the selected version of the data type. If the
subject ID is not specified and the fixed subject ID is not defined for the
selected data type version, the command will exit immediately with an error.
The minor version number may be omitted, in which case the newest known
version will be used. Examples:
    1234.uavcan.node.Heartbeat.1.0
    uavcan.node.Heartbeat.1
'''.strip(),
    )
    format_choices = ['yaml', 'json-line', 'tsv']
    parser.add_argument(
        '--format',
        choices=format_choices,
        default=format_choices[0],
        help='''
The representation of the data printed into stdout.
Default: %(default)s
'''.strip(),
    )


def execute(args: argparse.Namespace) -> int:
    data_id = str(args.data_id)
    print('data_id:', data_id)
    # TODO implement
    return 1
{'fraction_non_alphanumeric': 0.09898341359015517, 'fraction_numerical': 0.006153023006955591, 'mean_word_length': 3.5653235653235655, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '781273', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1097, 'n_words': 389}