<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __parse_identities(self, json):
 """Parse identities using Eclipse format. The Eclipse identities format is a JSON document under the "commiters" key. The document should follow the next schema: { 'committers' : { 'john': { 'affiliations': { '1': { 'active': '2001-01-01', 'inactive': null, 'name': 'Organization 1' } }, 'email': [ 'john@example.com' ], 'first': 'John', 'id': 'john', 'last': 'Doe', 'primary': 'john.doe@example.com' } } } :parse json: JSON object to parse :raise InvalidFormatError: raised when the format of the JSON is not valid. """

        try:
            for committer in json['committers'].values():
                name = self.__encode(committer['first'] + ' ' + committer['last'])
                email = self.__encode(committer['primary'])
                username = self.__encode(committer['id'])
                uuid = username

                uid = UniqueIdentity(uuid=uuid)
                identity = Identity(name=name, email=email, username=username,
                                    source=self.source, uuid=uuid)
                uid.identities.append(identity)

                if 'email' in committer:
                    for alt_email in committer['email']:
                        alt_email = self.__encode(alt_email)

                        if alt_email == email:
                            continue

                        identity = Identity(name=name, email=alt_email, username=username,
                                            source=self.source, uuid=uuid)
                        uid.identities.append(identity)

                if 'affiliations' in committer:
                    enrollments = self.__parse_affiliations_json(committer['affiliations'],
                                                                 uuid)
                    for rol in enrollments:
                        uid.enrollments.append(rol)

                self._identities[uuid] = uid
        except KeyError as e:
            msg = "invalid json format. Attribute %s not found" % e.args
            raise InvalidFormatError(cause=msg)