Skip to content

Commit

Permalink
Changed basic properties to no longer use functions because that's bad
Browse files Browse the repository at this point in the history
  • Loading branch information
benjhar committed Oct 12, 2019
1 parent 84e0aaa commit f6c587f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 48 deletions.
29 changes: 10 additions & 19 deletions foldingathome/Donor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class Donor:
def __init__(self, donorname, team=0):
r = requests.get(f'https://stats.foldingathome.org/api/team/{team}')
r = requests.get(f"https://stats.foldingathome.org/api/team/{team}")
self.team = r.json()

donors = self.team["donors"]
Expand All @@ -16,25 +16,16 @@ def __init__(self, donorname, team=0):
raise Exception(
f"\n\nNo user could be fou nd with that name: {donorname}.\n This could be due to the user not being on the leaderboard for the default team, as the api only displays the top 1000 members of a team."
)
return
elif not found:
raise Exception(
f"\n\nNo user could be found with that name: {donorname}")

def name(self):
return self.donor["name"]

def id(self):
return self.donor["id"]

def score(self):
return self.donor["credit"]

def work_units(self):
return self.donor["wus"]

def team_id(self):
team = self.team
return team["team"]
raise Exception(f"\n\nNo user could be found with that name: {donorname}")
return

self.name = self.donor["name"]
self.id = self.donor["id"]
self.score = self.donor["score"]
self.work_units = self.donor["work_units"]
self.team_id = self.team["team"]

def rank(self):
donors = self.team["donors"]
Expand Down
36 changes: 9 additions & 27 deletions foldingathome/Team.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ def __init__(self, team=0):
r = requests.get(f"https://stats.foldingathome.org/api/team/{team}")
self.team = r.json()
self.donors = r.json()["donors"]

def total_teams():
return self.team["total_teams"]
self.total_teams = self.team["total_teams"]
self.name = self.team["name"]
self.score = self.team["credit"]
self.work_units = self.team["wus"]
self.total_donors = len(self.team["donors"])
self.total_teams = self.team["total_teams"]
self.rank = self.team["rank"]
self.logo = self.team["logo"]
self.stats = self.team

def highest_scorer(self):
donors = self.donors
Expand Down Expand Up @@ -57,27 +63,3 @@ def most_wus(self):
"team": team,
"id": id,
}

def name(self):
return self.team["name"]

def score(self):
return self.team["credit"]

def work_units(self):
return self.team["wus"]

def total_donors(self):
return len(self.team["donors"])

def total_teams():
return self.team["total_teams"]

def rank(self):
return self.team["rank"]

def logo(self):
return self.team["logo"]

def stats(self):
return self.team
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
setup(
name="foldingathome",
packages=["foldingathome"],
version="0.1.3",
version="0.1.4",
license="MIT Licence",
description="A Python wrapper for the Folding@Home API.",
author="leet_hakker",
author_email="[email protected]",
url="https://github.com/thenamesweretakenalready/foldingathome/",
download_url="https://github.com/thenamesweretakenalready/foldingathome/archive/v0.1.3.tar.gz",
download_url="https://github.com/thenamesweretakenalready/foldingathome/archive/v0.1.4.tar.gz",
keywords=["API wrapper", "Python", "Folding@Home"],
install_requires=["requests"],
classifiers=[
Expand Down

0 comments on commit f6c587f

Please sign in to comment.