'Extract the ZipInfo object \'member\' to a physical
file on the path targetpath.'

def _extract_member(self, member, targetpath, pwd):

    if ((targetpath[(-1):] in (os.path.sep, os.path.altsep)) and (len(os.path.splitdrive(targetpath)[1]) > 1)):
        targetpath = targetpath[:(-1)]
    base_target = targetpath
    fname = member.filename.replace(os.sep, '/')
    fname = os.path.splitdrive(fname)[1]
    fname = '/'.join((x for x in fname.split('/') if (x not in {'', os.path.curdir, os.path.pardir})))
    if (not fname):
        raise BadZipfile(('The    member    %r    has    an    invalid    name' % member.filename))
    targetpath = os.path.normpath(os.path.join(base_target, fname))
    if (os.sep != '/'):
        targetpath = targetpath.replace('/', os.sep)
    upperdirs = os.path.dirname(targetpath)
    if (upperdirs and (not os.path.exists(upperdirs))):
        try:
            os.makedirs(upperdirs)
        except:
            targetpath = os.path.join(base_target, sanitize_file_name2(fname))
            upperdirs = os.path.dirname(targetpath)
            if (upperdirs and (not os.path.exists(upperdirs))):
                os.makedirs(upperdirs)
    if (member.filename[(-1)] == '/'):
        if (not os.path.isdir(targetpath)):
            os.mkdir(targetpath)
        self.extract_mapping[member.filename] = targetpath
        return targetpath
    if (not os.path.exists(targetpath)):
        with closing(self.open(member, pwd=pwd)) as source:
            try:
                with open(targetpath, 'wb') as target:
                    shutil.copyfileobj(source, target)
            except:
                components = list(os.path.split(targetpath))
                components[(-1)] = sanitize_file_name2(components[(-1)])
                targetpath = os.sep.join(components)
                with open(targetpath, 'wb') as target:
                    shutil.copyfileobj(source, target)
    try:
        mtime = time.localtime()
        mtime = time.mktime(((member.date_time + (0, 0)) + (mtime.tm_isdst,)))
        os.utime(targetpath, (mtime, mtime))
    except:
        pass
    self.extract_mapping[member.filename] = targetpath
    return targetpath
