'Determine the path to which the archive should be extracted.'

def extract(self, path):

    contents = self.getmembers()
    extraction_path = path
    common_prefix = ''
    if (len(contents) == 1):
        if self.isfile(contents[0]):
            extraction_path = os.path.join(path, self.file_name)
            if (not os.path.exists(extraction_path)):
                os.makedirs(extraction_path)
            self.archive.extractall(extraction_path)
    else:
        common_prefix = os.path.commonprefix([self.getname(item) for item in contents])
        if ((len(common_prefix) >= 1) and (not common_prefix.endswith(os.sep)) and self.isdir(self.getmember(common_prefix))):
            common_prefix += os.sep
        if (not common_prefix.endswith(os.sep)):
            common_prefix = ''
            extraction_path = os.path.join(path, self.file_name)
            if (not os.path.exists(extraction_path)):
                os.makedirs(extraction_path)
        self.archive.extractall(extraction_path)
    if (self.file_type == 'zip'):
        for zipped_file in contents:
            filename = self.getname(zipped_file)
            absolute_filepath = os.path.join(extraction_path, filename)
            external_attributes = self.archive.getinfo(filename).external_attr
            unix_permissions = (external_attributes >> 16)
            if (unix_permissions != 0):
                if os.path.exists(absolute_filepath):
                    os.chmod(absolute_filepath, unix_permissions)
                else:
                    log.warning(("Unable    to    change    permission    on    extracted    file    '%s'    as    it    does    not    exist" % absolute_filepath))
    return os.path.abspath(os.path.join(extraction_path, common_prefix))
