Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add properties methods to schema #906

Merged
merged 1 commit into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions anitya_schema/anitya_schema/distro_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ def __str__(self):
def summary(self):
"""Return a short summary of the message."""
return "A new distribution, {}, was added to release-monitoring.".format(
self.name
self.distro_name
)

@property
def name(self):
def agent(self):
"""User that did the change."""
return self.body["message"]["agent"]

@property
def distro_name(self):
"""The new distribution's name."""
return self.body["distro"]["name"]

Expand Down Expand Up @@ -114,16 +119,21 @@ def __str__(self):
def summary(self):
"""Return a short summary of the message."""
return "The name of the {} distribution changed to {}.".format(
self.old_name, self.new_name
self.distro_name_old, self.distro_name_new
)

@property
def new_name(self):
def agent(self):
"""User that did the change."""
return self.body["message"]["agent"]

@property
def distro_name_new(self):
"""The distribution's new name."""
return self.body["message"]["new"]

@property
def old_name(self):
def distro_name_old(self):
"""The distribution's old name."""
return self.body["message"]["old"]

Expand Down Expand Up @@ -170,10 +180,15 @@ def __str__(self):
def summary(self):
"""Return a short summary of the message."""
return "The {} distribution was removed from release-monitoring.".format(
self.name
self.distro_name
)

@property
def name(self):
"""The distribution's new name."""
return self.body["message"]["distro"]
def agent(self):
"""User that did the change."""
return self.body["message"]["agent"]

@property
def distro_name(self):
"""The new distribution's name."""
return self.body["distro"]["name"]
Loading