X-Git-Url: https://git.libre-soc.org/?p=utils.git;a=blobdiff_plain;f=src%2Fbudget_sync%2Fconfig.py;h=28b584ca33468fd449d66e6c0c5a8fe0dd14834f;hp=8a490b5ea61f4df3e50a3d6d3cf9a62275b09c04;hb=25f024fc5d2a1612e56cb230995b74e5f7495377;hpb=1408ab54f984e530d147ae60c5d35f7629daa75b diff --git a/src/budget_sync/config.py b/src/budget_sync/config.py index 8a490b5..28b584c 100644 --- a/src/budget_sync/config.py +++ b/src/budget_sync/config.py @@ -28,6 +28,8 @@ class Person: def all_names(self) -> Set[str]: retval = self.aliases.copy() retval.add(self.identifier) + if self.email is not None: + retval.add(self.email) return retval def __eq__(self, other): @@ -84,22 +86,25 @@ class Config: retval = self.people.copy() for person in self.people.values(): - for alias in person.aliases: - other_person = retval.get(alias) - if other_person is not None: - if alias in self.people: + for name in person.all_names: + other_person = retval.get(name) + if other_person is not None and other_person is not person: + alias_or_email = "alias" + if name == person.email: + alias_or_email = "email" + if name in self.people: raise ConfigParseError( - f"alias is not allowed to be the same as any" - f" person's identifier: in person entry for " - f"{person.identifier!r}: {alias!r} is also the " + f"{alias_or_email} is not allowed to be the same " + f"as any person's identifier: in person entry for " + f"{person.identifier!r}: {name!r} is also the " f"identifier for person" f" {other_person.identifier!r}") raise ConfigParseError( - f"alias is not allowed to be the same as another" - f" person's alias: in person entry for " - f"{person.identifier!r}: {alias!r} is also an alias " - f"for person {other_person.identifier!r}") - retval[alias] = person + f"{alias_or_email} is not allowed to be the same as " + f"another person's alias or email: in person entry " + f"for {person.identifier!r}: {name!r} is also an alias" + f" or email for person {other_person.identifier!r}") + retval[name] = person return retval @cached_property