Skip to content

Commit

Permalink
add model files
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkflame72 committed Dec 14, 2020
1 parent 8f37350 commit 7ea7779
Show file tree
Hide file tree
Showing 15 changed files with 354 additions and 279 deletions.
26 changes: 13 additions & 13 deletions mcsrvstats/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def close(self) -> None:
"""Used for safe client cleanup and stuff."""
await self.session.close()

async def get_html(self, url: str) -> str:
async def _get_html(self, url: str) -> str:
"""Get html from api.
Args:
Expand All @@ -41,7 +41,7 @@ async def get_html(self, url: str) -> str:
return html
raise ApiError("Api response not succesful")

async def get_json(self, url: str) -> Dict[str, Any]:
async def _get_json(self, url: str) -> Dict[str, Any]:
"""Get json response from api.
Args:
Expand Down Expand Up @@ -69,7 +69,7 @@ async def hive_mc_achievments(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of achievements.
"""
url = f"http://api.hivemc.com/v1/player/{username}"
json_data = await self.get_json(url)
json_data = await self._get_json(url)
data: Dict[str, Any] = {"all_achievements": []}
for ach in json_data["achievements"]:
data["all_achievements"].append(ach)
Expand All @@ -85,7 +85,7 @@ async def hive_mc_status(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of status
"""
url = f"http://api.hivemc.com/v1/player/{username}"
json_data = await self.get_json(url)
json_data = await self._get_json(url)
data: Dict[str, Any] = {"status": []}
for _ in json_data["status"]:
thing = json_data["status"]
Expand All @@ -103,7 +103,7 @@ async def hive_mc_game_stats(self, username: str, game: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of stats.
"""
url = f"http://api.hivemc.com/v1/player/{username}/{game}"
json_data = await self.get_json(url)
json_data = await self._get_json(url)
data = {"stats": [json_data]}
return data

Expand All @@ -117,7 +117,7 @@ async def hive_mc_rank(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of player rank
"""
url = f"http://api.hivemc.com/v1/player/{username}"
json_data = await self.get_json(url)
json_data = await self._get_json(url)
data = {"rank": [json_data["rankName"]]}
return data

Expand All @@ -131,7 +131,7 @@ async def manacube(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of player stats
"""
url = f"https://manacube.com/stats_data/fetch.php?username={username}"
json_data = await self.get_json(url)
json_data = await self._get_json(url)
return json_data

async def wynncraft_classes(self, username: str) -> Dict[str, Any]:
Expand All @@ -144,7 +144,7 @@ async def wynncraft_classes(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of player classes
"""
url = f"https://api.wynncraft.com/v2/player/{username}/stats"
json_data = await self.get_json(url)
json_data = await self._get_json(url)
data: Dict[str, Any] = {"classes": []}
for _class in json_data["data"][0]["classes"]:
data["classes"].append(
Expand All @@ -166,7 +166,7 @@ async def blocksmc(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of player stats
"""
url = f"https://blocksmc.com/player/{username}"
html = await self.get_html(url)
html = await self._get_html(url)
soup = BeautifulSoup(html, "lxml")
rank = (
soup.find("p", {"class": ["profile-rank"]})
Expand Down Expand Up @@ -210,7 +210,7 @@ async def universocraft(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of player stats
"""
url = f"https://stats.universocraft.com/stats.php?player={username}"
html = await self.get_html(url)
html = await self._get_html(url)
soup = BeautifulSoup(html, "lxml")
data: Dict[str, Any] = {"game_stats": []}
for game in soup.find_all("div", {"class": "game"}):
Expand All @@ -233,7 +233,7 @@ async def minesaga(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of player stats
"""
url = f"https://www.minesaga.org/player/{username}"
html = await self.get_html(url)
html = await self._get_html(url)
soup = BeautifulSoup(html, "lxml")
main_info = soup.find("div", {"class": ["dd-profile-details"]})
joined = main_info.find("h4").get_text().strip()
Expand Down Expand Up @@ -270,7 +270,7 @@ async def gommehd(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of player stats
"""
url = f"https://www.gommehd.net/player/index?playerName={username}"
html = await self.get_html(url)
html = await self._get_html(url)
soup = BeautifulSoup(html, "lxml")
data: Dict[str, Any] = {"game_stats": []}
for game in soup.find_all("div", {"class": "stat-table"}):
Expand All @@ -295,7 +295,7 @@ async def veltpvp(self, username: str) -> Dict[str, Any]:
Dict[str, Any]: Dict[str, Any]ionary of player stats
"""
url = f"https://www.veltpvp.com/u/{username}"
html = await self.get_html(url)
html = await self._get_html(url)
soup = BeautifulSoup(html, "lxml")
rank = soup.find("div", {"id": "profile"}).find("h2").get_text().strip()
last_seen = (
Expand Down
Empty file added mcsrvstats/models/blocksmc.py
Empty file.
Empty file added mcsrvstats/models/gommehd.py
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added mcsrvstats/models/manacube.py
Empty file.
Empty file added mcsrvstats/models/minesaga.py
Empty file.
Empty file.
Empty file added mcsrvstats/models/veltpvp.py
Empty file.
4 changes: 3 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ disallow_any_generics = True
disallow_incomplete_defs = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_decorators = True
disallow_untyped_decorators = False
disallow_untyped_defs = True
no_implicit_optional = True
no_implicit_reexport = True
Expand All @@ -18,4 +18,6 @@ warn_return_any = True
warn_unreachable = True
warn_unused_configs = True
warn_unused_ignores = False

[mypy-aioresponses.*]
ignore_missing_imports = True
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def mypy(session: Session) -> None:
def tests(session: Session) -> None:
"""Run the test suite."""
session.install(".")
session.install("coverage[toml]", "pytest", "pygments", "cryptography", "aiohttp")
session.install("coverage[toml]", "pytest", "pytest-asyncio", "aioresponses")
try:
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
finally:
Expand All @@ -143,7 +143,7 @@ def coverage(session: Session) -> None:
def typeguard(session: Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".")
session.install("pytest", "typeguard", "pygments")
session.install("pytest", "typeguard", "pygments", "aioresponses", "pytest-asyncio")
session.run("pytest", f"--typeguard-packages={package}", *session.posargs)


Expand Down

0 comments on commit 7ea7779

Please sign in to comment.