<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_key(self, key, request_only=False):
 """Get a data key value for each resolved package. Args: key (str):
 String key of property, eg 'tools'. request_only (bool):
 If True, only return the key from resolved packages that were also present in the request. Returns: Dict of {pkg-name: (variant, value)}. """

        values = {}
        requested_names = [x.name for x in self._package_requests
                           if not x.conflict]

        for pkg in self.resolved_packages:
            if (not request_only) or (pkg.name in requested_names):
                value = getattr(pkg, key)
                if value is not None:
                    values[pkg.name] = (pkg, value)

        return values