def cat_extract(tar, member, targetpath):
assert member.isreg()<EOL>targetpath = targetpath.rstrip("<STR_LIT:/>")<EOL>targetpath = targetpath.replace("<STR_LIT:/>", os.sep)<EOL>upperdirs = os.path.dirname(targetpath)<EOL>if upperdirs and not os.path.exists(upperdirs):<EOL><INDENT>try:<EOL><INDENT>os.makedirs(upperdirs)<EOL><DEDENT>except EnvironmentError as e:<EOL><INDENT>if e.errno == errno.EEXIST:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>with files.DeleteOnError(targetpath) as dest:<EOL><INDENT>with pipeline.get_cat_pipeline(pipeline.PIPE, dest.f) as pl:<EOL><INDENT>fp = tar.extractfile(member)<EOL>copyfileobj.copyfileobj(fp, pl.stdin)<EOL><DEDENT><DEDENT>if sys.version_info < (<NUM_LIT:3>, <NUM_LIT:5>):<EOL><INDENT>tar.chown(member, targetpath)<EOL><DEDENT>else:<EOL><INDENT>tar.chown(member, targetpath, False)<EOL><DEDENT>tar.chmod(member, targetpath)<EOL>tar.utime(member, targetpath)<EOL>
Extract a regular file member using cat for async-like I/O

    Mostly adapted from tarfile.py.