<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def purge_metadata_by_name(self, name):
 """Purge a processes metadata directory. :raises: `ProcessManager.MetadataError` when OSError is encountered on metadata dir removal. """

    meta_dir = self._get_metadata_dir_by_name(name, self._metadata_base_dir)
    logger.debug('purging metadata directory: {}'.format(meta_dir))
    try:
      rm_rf(meta_dir)
    except OSError as e:
      raise ProcessMetadataManager.MetadataError('failed to purge metadata directory {}: {!r}'.format(meta_dir, e))