'Converts StatEntry to ExportedRegistryKey.
Does nothing if StatEntry corresponds to a file and not a registry entry.
Args:
metadata: ExportedMetadata to be used for conversion.
stat_entry: StatEntry to be converted.
token: Security token.
Returns:
List or generator with resulting RDFValues. Empty list if StatEntry
corresponds to a file and not to a registry entry.'

def Convert(self, metadata, stat_entry, token=None):

    if (stat_entry.pathspec.pathtype != rdf_paths.PathSpec.PathType.REGISTRY):
        return []
    result = ExportedRegistryKey(metadata=metadata, urn=stat_entry.AFF4Path(metadata.client_urn), last_modified=stat_entry.st_mtime)
    if (stat_entry.HasField('registry_type') and stat_entry.HasField('registry_data')):
        result.type = stat_entry.registry_type
        try:
            data = str(stat_entry.registry_data.GetValue())
        except UnicodeEncodeError:
            data = stat_entry.registry_data.GetValue()
            data = unicode(data).encode('utf-16be')
        result.data = data
    return [result]
