<commit_before>"""
Command line parser for the application.
"""
import os
import argparse
import six

DESCRIPTION_STR = "DukeDSClient ({}) Manage projects/folders/files in the duke-data-service"
INVALID_PATH_CHARS = (':', '/', '\\')


def replace_invalid_path_chars(path):
    """
    Converts bad path characters to '_'.
    :param path: str path to fix
    :return: str fixed path
    """
    for bad_char in INVALID_PATH_CHARS:
        path = path.replace(bad_char, '_')
    return path


def to_unicode(s):
    """
    Convert a command line string to utf8 unicode.
    :param s: string to convert to unicode
    :return: unicode string for argument
    """
    return s if six.PY3 else unicode(s, 'utf-8')


def add_project_name_arg(arg_parser, required, help_text):
    """
    Adds project_name parameter to a parser.
    :param arg_parser: ArgumentParser parser to add this argument to.
    :param help_text: str label displayed in usage
    """
    arg_parser.add_argument("-p", '--project-name',
                            metavar='ProjectName',
                            type=to_unicode,
                            dest='project_name',
                            help=help_text,
                            required=required)


def add_project_id_arg(arg_parser, required, help_text):
    """
    Adds project_name parameter to a parser.
    :param arg_parser: ArgumentParser parser to add this argument to.
    :param help_text: str label displayed in usage
    """
    arg_parser.add_argument("-i", '--project-id',
                            metavar='ProjectUUID',
                            type=to_unicode,<commit_msg>disable flake8 undefined name unicode check<commit_after>"""
Command line parser for the application.
"""
import os
import argparse
import six

DESCRIPTION_STR = "DukeDSClient ({}) Manage projects/folders/files in the duke-data-service"
INVALID_PATH_CHARS = (':', '/', '\\')


def replace_invalid_path_chars(path):
    """
    Converts bad path characters to '_'.
    :param path: str path to fix
    :return: str fixed path
    """
    for bad_char in INVALID_PATH_CHARS:
        path = path.replace(bad_char, '_')
    return path


def to_unicode(s):
    """
    Convert a command line string to utf8 unicode.
    :param s: string to convert to unicode
    :return: unicode string for argument
    """
    # Disabling flake8 undefined name unicode check below.
    # flake8 is unaware of the python version check which makes this safe to do.
    return s if six.PY3 else unicode(s, 'utf-8')  # noqa: F821


def add_project_name_arg(arg_parser, required, help_text):
    """
    Adds project_name parameter to a parser.
    :param arg_parser: ArgumentParser parser to add this argument to.
    :param help_text: str label displayed in usage
    """
    arg_parser.add_argument("-p", '--project-name',
                            metavar='ProjectName',
                            type=to_unicode,
                            dest='project_name',
                            help=help_text,
                            required=required)


def add_project_id_arg(arg_parser, required, help_text):
    """
    Adds project_name parameter to a parser.
    :param arg_parser: ArgumentParser parser to add this argument to.
    :param help_text: str label displayed in usage
    """
    arg_parser.add_argument("-i", '--project-id',
                            metavar='ProjectUUID',
                            type=to_unicode,
{'fraction_non_alphanumeric': 0.09353348729792148, 'fraction_numerical': 0.003464203233256351, 'mean_word_length': 2.3543078412391094, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '302470', 'n_tokens_mistral': 994, 'n_tokens_neox': 971, 'n_words': 303}