src/borg/patterns.py
def parse_inclexcl_command(cmd_line_str, fallback=ShellPattern):
    """Read a --patterns-from command from string and return a CmdTuple object."""

    cmd_prefix_map = {
        '-': IECommand.Exclude,
        '!': IECommand.ExcludeNoRecurse,
        '+': IECommand.Include,
        'R': IECommand.RootPath,
        'r': IECommand.RootPath,
        'P': IECommand.PatternStyle,
        'p': IECommand.PatternStyle,
    }
    if not cmd_line_str:
        raise argparse.ArgumentTypeError("A pattern/command must not be empty.")

    cmd = cmd_prefix_map.get(cmd_line_str[0])
    if cmd is None:
        raise argparse.ArgumentTypeError("A pattern/command must start with anyone of: %s" %
                                         ', '.join(cmd_prefix_map))

    # remaining text on command-line following the command character
    remainder_str = cmd_line_str[1:].lstrip()
    if not remainder_str:
        raise argparse.ArgumentTypeError("A pattern/command must have a value part.")

    if cmd is IECommand.RootPath:
        # TODO: validate string?
        val = remainder_str
    elif cmd is IECommand.PatternStyle:
        # then remainder_str is something like 're' or 'sh'
        try:
            val = get_pattern_class(remainder_str)
        except ValueError:
            raise argparse.ArgumentTypeError("Invalid pattern style: {}".format(remainder_str))
    else:
        # determine recurse_dir based on command type
        recurse_dir = command_recurses_dir(cmd)
        val = parse_pattern(remainder_str, fallback, recurse_dir)

    return CmdTuple(val, cmd)
Read a --patterns-from command from string and return a CmdTuple object.
Read a --patterns-from command from string and return a CmdTuple object.
Read a -- patterns - from command from string and return a CmdTuple object .
def parse_inclexcl_command(cmd_line_str, fallback=ShellPattern):
    cmd_prefix_map = {
        '-': IECommand.Exclude,
        '!': IECommand.ExcludeNoRecurse,
        '+': IECommand.Include,
        'R': IECommand.RootPath,
        'r': IECommand.RootPath,
        'P': IECommand.PatternStyle,
        'p': IECommand.PatternStyle,
    }
    if not cmd_line_str:
        raise argparse.ArgumentTypeError("A pattern/command must not be empty.")
    cmd = cmd_prefix_map.get(cmd_line_str[0])
    if cmd is None:
        raise argparse.ArgumentTypeError("A pattern/command must start with anyone of: %s" %
                                         ', '.join(cmd_prefix_map))
    remainder_str = cmd_line_str[1:].lstrip()
    if not remainder_str:
        raise argparse.ArgumentTypeError("A pattern/command must have a value part.")
    if cmd is IECommand.RootPath:
        val = remainder_str
    elif cmd is IECommand.PatternStyle:
        try:
            val = get_pattern_class(remainder_str)
        except ValueError:
            raise argparse.ArgumentTypeError("Invalid pattern style: {}".format(remainder_str))
    else:
        recurse_dir = command_recurses_dir(cmd)
        val = parse_pattern(remainder_str, fallback, recurse_dir)
    return CmdTuple(val, cmd)
def parse_inclexcl_command ( cmd_line_str , fallback = ShellPattern ) : cmd_prefix_map = { '-' : IECommand . Exclude , '!' : IECommand . ExcludeNoRecurse , '+' : IECommand . Include , 'R' : IECommand . RootPath , 'r' : IECommand . RootPath , 'P' : IECommand . PatternStyle , 'p' : IECommand . PatternStyle , } if not cmd_line_str : raise argparse . ArgumentTypeError ( "A pattern/command must not be empty." ) cmd = cmd_prefix_map . get ( cmd_line_str [ 0 ] ) if cmd is None : raise argparse . ArgumentTypeError ( "A pattern/command must start with anyone of: %s" % ', ' . join ( cmd_prefix_map ) ) remainder_str = cmd_line_str [ 1 : ] . lstrip ( ) if not remainder_str : raise argparse . ArgumentTypeError ( "A pattern/command must have a value part." ) if cmd is IECommand . RootPath : val = remainder_str elif cmd is IECommand . PatternStyle : try : val = get_pattern_class ( remainder_str ) except ValueError : raise argparse . ArgumentTypeError ( "Invalid pattern style: {}" . format ( remainder_str ) ) else : recurse_dir = command_recurses_dir ( cmd ) val = parse_pattern ( remainder_str , fallback , recurse_dir ) return CmdTuple ( val , cmd )
Read a --patterns-from command from string and return a CmdTuple object.
Read a -- patterns - from command from string and return a CmdTuple object .
"""Read a --patterns-from command from string and return a CmdTuple object.""" # remaining text on command-line following the command character # TODO: validate string? # then remainder_str is something like 're' or 'sh' # determine recurse_dir based on command type
cmd_line_str
fallback