# Path: anchorhub/util/stripprefix.py
# def strip_prefix(string, strip):
#     """
#     Strips a prefix from a string, if the string starts with the prefix.
# 
#     :param string: String that should have its prefix removed
#     :param strip: Prefix to be removed
#     :return: string with the prefix removed if it has the prefix, or else it
#         just returns the original string
#     """
#     import re
#     strip_esc = re.escape(strip)
#     if re.match(strip_esc, string):
#         return string[len(strip):]
#     else:
#         return string


from anchorhub.util.stripprefix import strip_prefix
"""
messages.py - Functions that print out messages to the console
"""


def print_input_output(opts):
    """
    Prints the input and output directories to the console.

    :param opts: namespace that contains printable 'input' and 'output' fields.
    """
    if opts.is_dir:
        print("Root input directory:\t" + opts.input)
        print("Outputting to:\t\t" + opts.output + "\n")
    else:
        print("Input file:\t\t" + opts.input)
        print("Outputting to:\t\t" + opts.output + opts.input + "\n")


def print_files(opts, file_paths):
    """
    Prints the file paths that will be parsed.

    :param file_paths:
    """
    print("Parsing the following files:")
    for file_path in file_paths:

# Path: anchorhub/util/stripprefix.py
# def strip_prefix(string, strip):
#     """
#     Strips a prefix from a string, if the string starts with the prefix.
# 
#     :param string: String that should have its prefix removed
#     :param strip: Prefix to be removed
#     :return: string with the prefix removed if it has the prefix, or else it
#         just returns the original string
#     """
#     import re
#     strip_esc = re.escape(strip)
#     if re.match(strip_esc, string):
#         return string[len(strip):]
#     else:
#         return string


# Path: anchorhub/messages.py
from anchorhub.util.stripprefix import strip_prefix

"""
messages.py - Functions that print out messages to the console
"""


def print_input_output(opts):
    """
    Prints the input and output directories to the console.

    :param opts: namespace that contains printable 'input' and 'output' fields.
    """
    if opts.is_dir:
        print("Root input directory:\t" + opts.input)
        print("Outputting to:\t\t" + opts.output + "\n")
    else:
        print("Input file:\t\t" + opts.input)
        print("Outputting to:\t\t" + opts.output + opts.input + "\n")


def print_files(opts, file_paths):
    """
    Prints the file paths that will be parsed.

    :param file_paths:
    """
    print("Parsing the following files:")
    for file_path in file_paths:

        print("  " + strip_prefix(file_path, opts.abs_input))