Closed rgcr closed 6 years ago
What is the repr()
of stdoutdata
? Because it should be as it was (with the surrounding \b
s)
Even it does match r'--wildcards\b'
but does not r'\b--wildcards\b'
>>> re.search(r'--wildcards\b', stdoutdata)
<re.Match object; span=(3109, 3120), match='--wildcards'>
>>> re.search(r'\b--wildcards', stdoutdata)
>>> re.search(r'\b--wildcards\b', stdoutdata)
re.search(r'\s--wildcards\s', stdoutdata)
<re.Match object; span=(3108, 3121), match=' --wildcards '>
>>> re.search(r'\s+--wildcards\s+', stdoutdata)
<re.Match object; span=(3102, 3132), match='\n --wildcards '>
>>> re.search(r'--wildcards', stdoutdata)
<re.Match object; span=(3109, 3120), match='--wildcards'>
>>> repr(stdoutdata)
'"Usage: tar [OPTION...] [FILE]...\\nGNU \'tar\' saves many files together into a single tape or disk archive, and can\\nrestore individual files from the archive.\\n\\nExamples:\\n tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.\\n tar -t
vf archive.tar # List all files in archive.tar verbosely.\\n tar -xf archive.tar # Extract all files from archive.tar.\\n\\n Local file name selection:\\n\\n -C, --directory=DIR change to directory DIR\\n -T, --files-from=FILE get name
s to extract or create from FILE\\n -X, --exclude-from=FILE exclude patterns listed in FILE\\n --add-file=FILE add given FILE to the archive (useful if its name\\n starts with a dash)\\n --exclude=PATTERN exclude
files, given as a PATTERN\\n --exclude-backups exclude backup and lock files\\n --exclude-caches exclude contents of directories containing\\n CACHEDIR.TAG, except for the tag file itself\\n --exclude-caches-all
exclude directories containing CACHEDIR.TAG\\n --exclude-caches-under exclude everything under directories containing\\n CACHEDIR.TAG\\n --exclude-ignore=FILE read exclude patterns for each directory from\\n
FILE, if it exists\\n --exclude-ignore-recursive=FILE\\n read exclude patterns for each directory and its\\n subdirectories from FILE, if it exists\\n --exclude-tag=FILE exclude contents o
f directories containing FILE,\\n except for FILE itself\\n --exclude-tag-all=FILE exclude directories containing FILE\\n --exclude-tag-under=FILE exclude everything under directories\\n containing F
ILE\\n --exclude-vcs exclude version control system directories\\n --exclude-vcs-ignores read exclude patterns from the VCS ignore files\\n --no-null disable the effect of the previous --null option\\n --no-recursion
avoid descending automatically in directories\\n --no-unquote do not unquote input file or member names\\n --no-verbatim-files-from -T treats file names starting with dash as\\n options (default)\\n --null
-T reads null-terminated names; implies\\n --verbatim-files-from\\n --recursion recurse into directories (default)\\n --unquote unquote input file or member names (default)\\n --verbatim-fi
les-from -T reads file names verbatim (no escape or option\\n handling)\\n\\n File name matching options (affect both exclude and include patterns):\\n\\n --anchored patterns match file name start\\n --ignore-case
ignore case\\n --no-anchored patterns match after any \'/\' (default for\\n exclusion)\\n --no-ignore-case case sensitive matching (default)\\n --no-wildcards verbatim string matching\\n --
no-wildcards-match-slash wildcards do not match \'/\'\\n --wildcards use wildcards (default for exclusion)\\n --wildcards-match-slash wildcards match \'/\' (default for exclusion)\\n\\n Main operation mode:\\n\\n -A, --catenate, --concatenat
e append tar files to an archive\\n -c, --create create a new archive\\n --delete delete from the archive (not on mag tapes!)\\n -d, --diff, --compare find differences between archive and file system\\n -r, --append
append files to the end of an archive\\n -t, --list list the contents of an archive\\n --test-label test the archive volume label and exit\\n -u, --update only append files newer than copy in archive\\n -x, --extr
act, --get extract files from an archive\\n\\n Operation modifiers:\\n\\n -G, --incremental handle old GNU-format incremental backup\\n -S, --sparse handle sparse files efficiently\\n --check-device check device numbers whe
n creating incremental\\n archives (default)\\n -g, --listed-incremental=FILE handle new GNU-format incremental backup\\n --hole-detection=TYPE technique to detect holes\\n --ignore-failed-read do not exit with nonzero on u
nreadable files\\n --level=NUMBER dump level for created listed-incremental archive\\n -n, --seek archive is seekable\\n --no-check-device do not check device numbers when creating\\n incremental arc
hives\\n --no-seek archive is not seekable\\n --occurrence[=NUMBER] process only the NUMBERth occurrence of each file\\n in the archive; this option is valid only in\\n conjunction with o
ne of the subcommands --delete,\\n --diff, --extract or --list and when a list of\\n files is given either on the command line or via\\n the -T option; NUMBER defaults to 1\\n --
sparse-version=MAJOR[.MINOR]\\n set version of the sparse format to use (implies\\n --sparse)\\n\\n Overwrite control:\\n\\n -U, --unlink-first remove each file prior to extracting over it\\n -W, --ver
ify attempt to verify the archive after writing it\\n --keep-directory-symlink preserve existing symlinks to directories when\\n extracting\\n --keep-newer-files don\'t replace existing files that are newer th
an\\n their archive copies\\n -k, --keep-old-files don\'t replace existing files when extracting,\\n treat them as errors\\n --no-overwrite-dir preserve metadata of existing directories\\n -
-one-top-level[=DIR] create a subdirectory to avoid having loose files\\n extracted\\n --overwrite overwrite existing files when extracting\\n --overwrite-dir overwrite metadata of existing directories when\\n
extracting (default)\\n --recursive-unlink empty hierarchies prior to extracting directory\\n --remove-files remove files after adding them to the archive\\n --skip-old-files don\'t replace existing files w
hen extracting,\\n silently skip over them\\n\\n Select output stream:\\n\\n -O, --to-stdout extract files to standard output\\n --ignore-command-error ignore exit codes of children\\n --no-ignore-command-error trea
t non-zero exit codes of children as\\n error\\n --to-command=COMMAND pipe extracted files to another program\\n\\n Handling of file attributes:\\n\\n --atime-preserve[=METHOD] preserve access times on dumped files, either\\n
by restoring the times after reading\\n (METHOD=\'replace\'; default) or by not setting the\\n times in the first place (METHOD=\'system\')\\n --clamp-mtime only set ti
me when the file is more recent than\\n what was given with --mtime\\n --delay-directory-restore delay setting modification times and\\n permissions of extracted directories until the end\\n
of extraction\\n --group=NAME force NAME as group for added files\\n --group-map=FILE use FILE to map file owner GIDs and names\\n --mode=CHANGES force (symbolic) mode CHANGES for added files\\n --mtime=DATE-
OR-FILE set mtime for added files from DATE-OR-FILE\\n -m, --touch don\'t extract file modified time\\n --no-delay-directory-restore\\n cancel the effect of --delay-directory-restore\\n op
tion\\n --no-same-owner extract files as yourself (default for ordinary\\n users)\\n --no-same-permissions apply the user\'s umask when extracting permissions\\n from the archive (default for o
rdinary users)\\n --numeric-owner always use numbers for user/group names\\n --owner=NAME force NAME as owner for added files\\n --owner-map=FILE use FILE to map file owner UIDs and names\\n -p, --preserve-permissions, --same-pe
rmissions\\n extract information about file permissions\\n (default for superuser)\\n --same-owner try extracting files with the same ownership as\\n exists in the arch
ive (default for superuser)\\n -s, --preserve-order, --same-order\\n member arguments are listed in the same order as\\n the files in the archive\\n --sort=ORDER directory sorting order: none (de
fault), name or\\n inode\\n\\n Handling of extended file attributes:\\n\\n --acls Enable the POSIX ACLs support\\n --no-acls Disable the POSIX ACLs support\\n --no-selinux Disable the S
ELinux context support\\n --no-xattrs Disable extended attributes support\\n --selinux Enable the SELinux context support\\n --xattrs Enable extended attributes support\\n --xattrs-exclude=MASK specify the ex
clude pattern for xattr keys\\n --xattrs-include=MASK specify the include pattern for xattr keys\\n\\n Device selection and switching:\\n\\n -F, --info-script=NAME, --new-volume-script=NAME\\n run script at end of each tape (implies
-M)\\n -L, --tape-length=NUMBER change tape after writing NUMBER x 1024 bytes\\n -M, --multi-volume create/list/extract multi-volume archive\\n -f, --file=ARCHIVE use archive file or device ARCHIVE\\n --force-local archive file is
local even if it has a colon\\n --rmt-command=COMMAND use given rmt COMMAND instead of rmt\\n --rsh-command=COMMAND use remote COMMAND instead of rsh\\n --volno-file=FILE use/update the volume number in FILE\\n\\n Device blocking:\\n\\n -B, --r
ead-full-records reblock as we read (for 4.2BSD pipes)\\n -b, --blocking-factor=BLOCKS BLOCKS x 512 bytes per record\\n -i, --ignore-zeros ignore zeroed blocks in archive (means EOF)\\n --record-size=NUMBER NUMBER of bytes per record, multiple o
f 512\\n\\n Archive format selection:\\n\\n -H, --format=FORMAT create archive of the given format\\n\\n FORMAT is one of the following:\\n\\n gnu GNU tar 1.13.x format\\n oldgnu GNU format as per tar <= 1.12\\n
pax POSIX 1003.1-2001 (pax) format\\n posix same as pax\\n ustar POSIX 1003.1-1988 (ustar) format\\n v7 old V7 tar format\\n\\n -V, --label=TEXT create archive with
volume name TEXT; at\\n list/extract time, use TEXT as a globbing pattern\\n for volume name\\n --old-archive, --portability\\n same as --format=v7\\n --pax-option=keyword[[
:]=value][,keyword[[:]=value]]...\\n control pax keywords\\n --posix same as --format=posix\\n\\n Compression options:\\n\\n -I, --use-compress-program=PROG\\n filter through PROG (must acce
pt -d)\\n -J, --xz filter the archive through xz\\n -Z, --compress, --uncompress filter the archive through compress\\n -a, --auto-compress use archive suffix to determine the compression\\n program\\n -j, --
bzip2 filter the archive through bzip2\\n --lzip filter the archive through lzip\\n --lzma filter the archive through lzma\\n --lzop filter the archive through lzop\\n --no-auto-compre
ss do not use archive suffix to determine the\\n compression program\\n -z, --gzip, --gunzip, --ungzip filter the archive through gzip\\n\\n Local file selection:\\n\\n -K, --starting-file=MEMBER-NAME\\n
begin at member MEMBER-NAME when reading the\\n archive\\n -N, --newer=DATE-OR-FILE, --after-date=DATE-OR-FILE\\n only store files newer than DATE-OR-FILE\\n -P, --absolute-names don\'t strip leading \'
/\'s from file names\\n --backup[=CONTROL] backup before removal, choose version CONTROL\\n -h, --dereference follow symlinks; archive and dump the files they\\n point to\\n --hard-dereference follow hard links;
archive and dump the files they\\n refer to\\n --newer-mtime=DATE compare date and time when data changed only\\n --one-file-system stay in local file system when creating archive\\n --suffix=STRING backup b
efore removal, override usual suffix (\'~\'\\n unless overridden by environment variable\\n SIMPLE_BACKUP_SUFFIX)\\n\\n File name transformations:\\n\\n --strip-components=NUMBER strip NUMBER leading comp
onents from file\\n names on extraction\\n --transform=EXPRESSION, --xform=EXPRESSION\\n use sed replace EXPRESSION to transform file\\n names\\n\\n Informative output:\\n\\n -R
, --block-number show block number within archive with each\\n message\\n --checkpoint[=NUMBER] display progress messages every NUMBERth record\\n (default 10)\\n --checkpoint-action=ACTION
execute ACTION on each checkpoint\\n --full-time print file time to its full resolution\\n --index-file=FILE send verbose output to FILE\\n -l, --check-links print a message if not all links are dumped\\n --no-quote-chars=STRI
NG disable quoting for characters from STRING\\n --quote-chars=STRING additionally quote characters from STRING\\n --quoting-style=STYLE set name quoting style; see below for valid STYLE\\n values\\n --show-defaults
show tar defaults\\n --show-omitted-dirs when listing or extracting, list each directory\\n that does not match search criteria\\n --show-snapshot-field-ranges\\n show valid ranges for snapshot-
file fields\\n --show-transformed-names, --show-stored-names\\n show file or archive names after transformation\\n --totals[=SIGNAL] print total bytes after processing the archive;\\n with an argu
ment - print total bytes when this\\n SIGNAL is delivered; Allowed signals are: SIGHUP,\\n SIGQUIT, SIGINT, SIGUSR1 and SIGUSR2; the names\\n without SIG prefix are also accepted\\n
--utc print file modification times in UTC\\n -v, --verbose verbosely list files processed\\n -w, --interactive, --confirmation\\n ask for confirmation for every action\\n --warning=KEYWORD war
ning control\\n\\n Compatibility options:\\n\\n -o when creating, same as --old-archive; when\\n extracting, same as --no-same-owner\\n\\n Other options:\\n\\n -?, --help give this help list\\n
--restrict disable use of some potentially harmful options\\n --usage give a short usage message\\n --version print program version\\n\\nMandatory or optional arguments to long options are also mandatory or optional
\\nfor any corresponding short options.\\n\\nThe backup suffix is \'~\', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\\nThe version control may be set with --backup or VERSION_CONTROL, values are:\\n\\n none, off never make backups\\n t, numbered mak
e numbered backups\\n nil, existing numbered if numbered backups exist, simple otherwise\\n never, simple always make simple backups\\n\\nValid arguments for the --quoting-style option are:\\n\\n literal\\n shell\\n shell-always\\n shell-escape\\n shell-es
cape-always\\n c\\n c-maybe\\n escape\\n locale\\n clocale\\n\\n*This* tar defaults to:\\n--format=gnu -f- -b20 --quoting-style=escape --rmt-command=/usr/lib/tar/rmt.exe\\n--rsh-command=/usr/bin/rsh\\n"'
(Pdb)
Thank you for the detailed report! I ended up using r'--wildcards\b'
(after merge).
Seems there is an issue with the regex so --wildcards parameter never is passed to the tar command.