Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
luissilva1044894 committed May 28, 2019
1 parent 7ffe1fd commit 54decee
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 73 deletions.
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyrez[docs]>=1.0.4,<2
pyrez[docs]>=1.0.5,<2
4 changes: 2 additions & 2 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. currentmodule:: pyrez

API Reference
=============
API Reference (pyrez.api)
=========================

The following section outlines the API of Pyrez.

Expand Down
14 changes: 9 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@

on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

def __regexFunc(pattern, packageName="pyrez", filename="__version__.py"):
with open('../../{}/{}'.format(packageName, filename), 'r', encoding="utf-8") as f:
import re
return re.search(r'^__{}__\s*=\s*[\'"]([^\'"]*)[\'"]'.format(pattern), f.read(), re.MULTILINE).group(1)

# -- Project information -----------------------------------------------------
import pyrez #from pyrez import __version__ as pyrez
epub_title = project = pyrez.__package_name__.capitalize()
epub_copyright = copyright = pyrez.__copyright__
epub_publisher = epub_author = author = pyrez.__author__
epub_title = project = __regexFunc("package_name").capitalize()
epub_publisher = epub_author = author = __regexFunc("author")
epub_copyright = copyright = "2018-{}, {}".format(datetime.utcnow().year, author)

# The full version, including alpha/beta/rc tags
version = release = pyrez.__version__
version = release = __regexFunc("version")

# -- General configuration ---------------------------------------------------

Expand Down
30 changes: 19 additions & 11 deletions docs/source/gettingstarted.rst → docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Getting Started
Registration
------------

A `Credentials`_ that will provide access to Hi-Rez Studios API.
A `Credentials`_ that will provide access to |HIREZSTUDIOS| API.

If you don't already have a Credentials, `click here`_ to become
developer.

If your application is accepted, you will receive an e-mail from Hi-Rez
Studios containing your personal `Credentials`_ within a few
days.
.. attention::
If your application is accepted, you will receive an e-mail from Hi-Rez
Studios containing your personal `Credentials`_ within a few days.

Credentials
-----------
Expand All @@ -25,6 +25,11 @@ Here are the Credentials for a sample account:
1004 23DF3C7E9BD14D84BF892AD206B6755C
======= ==================================

.. note::
The same ``devId`` and ``authKey`` combination should work for |PALADINSGAME| API, |SMITEGAME| API and |REALMROYALEGAME| API, across all supported platforms.

Do not request a new, if you already have a Credentials.

Importing
---------

Expand All @@ -50,12 +55,11 @@ Creating API object
reamlRoyale = RealmRoyaleAPI(options)
Options can have the following fields:

- devId (|INT|) – |DevId|
- authKey (|STR|) – |AuthKey|
- responseFormat (:class:`.Format`) – |Format|
- sessionId (|STR|) – |Format|
- storeSession (|STR|) – Allows Pyrez to read and store sessionId in a .json file.
- devId (|INT|) – |DevId|
- authKey (|STR|) – |AuthKey|
- responseFormat (:class:`.Format`) – |Format|
- sessionId (|STR|) – |Format|
- storeSession (|STR|) – Allows Pyrez to read and store sessionId in a .json file.

Sessions
--------
Expand All @@ -66,7 +70,9 @@ Manually:

.. code:: py
paladins = PaladinsAPI(devId=1004, authKey="23DF3C7E9BD14D84BF892AD206B6755C", sessionId="1465AFCA32DBDB800CEF8C72F296C52C")
paladins = PaladinsAPI(devId=1004,
authKey="23DF3C7E9BD14D84BF892AD206B6755C",
sessionId="1465AFCA32DBDB800CEF8C72F296C52C")
Requesting a new Session:

Expand All @@ -76,5 +82,7 @@ Requesting a new Session:
session = paladins._createSession()
print(session.sessionId)
>>> '1465AFCA32DBDB800CEF8C72F296C52C'
.. _Credentials: #credentials
.. _click here: https://fs12.formsite.com/HiRez/form48/secure_index.html
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Welcome to Pyrez's documentation!
:maxdepth: 2
:caption: Contents:

gettingstarted
getting_started
api
dataclasses

Expand Down
28 changes: 13 additions & 15 deletions pyrez/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
_____
| __ \
| |__) | _ _ __ ___ ____
| ___/ | | | '__/ _ \_ /
| | | |_| | | | __// /
|_| \__, |_| \___/___|
__/ |
|___/
"""

import sys
from datetime import datetime
if sys.version_info[:2] < (3, 4) and datetime.utcnow().year >= 2020:
raise RuntimeError("Unsupported Python version - Pyrez requires Python 3.4+")
from .command_line import check_python
check_python((3, 5))

from .api import *
from .enumerations import *
Expand All @@ -38,3 +26,13 @@ class NullHandler(logging.Handler):
def emit(self, record):
pass
logging.getLogger(__name__).addHandler(NullHandler())

#
# _____
#| __ \
#| |__) | _ _ __ ___ ____
#| ___/ | | | '__/ _ \_ /
#| | | |_| | | | __// /
#|_| \__, |_| \___/___|
# __/ |
# |___/
10 changes: 6 additions & 4 deletions pyrez/__version__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from datetime import datetime
__author__ = "Luis (Lugg) Gustavo"
__author_email__ = "[email protected]"
__copyright__ = "2018-{}, {}".format(datetime.utcnow().year, __author__)
__build__ = 0x010004
__description__ = "An open-source wrapper for Hi-Rez Studios API (Paladins, Realm Royale, and Smite), written in Python"
__build__ = 0x010005
__description__ = "An open-source wrapper for Hi-Rez Studios API (Paladins, Realm Royale, and Smite), written in Python."
__license__ = "MIT"
__package_name__ = "pyrez"
__url__ = "https://pyrez.readthedocs.io/en/stable"
__version__ = "1.0.4" #'.'.join(map(str, (1, 0, 4)))
__version__ = "1.0.5" #'.'.join(map(str, (1, 0, 5)))
__title__ = "{}-{}".format(__package_name__.capitalize(), __version__)
version = __version__

from collections import namedtuple
version_info = namedtuple("VersionInfo", "major minor micro releaselevel serial")(major=1, minor=0, micro=4, releaselevel="final", serial=0)
version_info = namedtuple("VersionInfo", "major minor micro releaselevel serial")(major=1, minor=0, micro=5, releaselevel="final", serial=0)

__all__ = (
"__title__",
Expand Down
14 changes: 9 additions & 5 deletions pyrez/api/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def getMatch(self, matchId, isLiveMatch=False):
-------
There is a byte limit to the amount of data returned.
Please limit the CSV parameter to 5-10 matches because of this and for Hi-Rez DB Performance reasons.
Please limit the CSV parameter to 5-10 matches for DB Performance reasons.
"""
_ = self.makeRequest("getmatchdetailsbatch", [','.join(matchId)]) if isinstance(matchId, (type(()), type([]))) else self.makeRequest("getmatchplayerdetails" if isLiveMatch else "getmatchdetails", [matchId])
if self._responseFormat.equal(Format.XML) or not _:
Expand Down Expand Up @@ -521,10 +521,14 @@ def getPlayerId(self, playerName, portalId=None):
__ = [ PlayerId(**___) for ___ in (_ or []) ]
return __ if __ else None
def getPlayerStatus(self, playerId):
"""
/getplayerstatus[ResponseFormat]/{devId}/{signature}/{session}/{timestamp}/{playerId}
Returns player status as follows:
0 - Offline, 1 - In Lobby, 2 - god Selection, 3 - In Game, 4 - Online, 5 - Player not found
"""Returns player status as follows:
- 0: Offline,
- 1: In Lobby,
- 2: God Selection,
- 3: In Game,
- 4: Online,
- 5: Player not found
Parameters
----------
playerId : |INT|
Expand Down
Empty file removed pyrez/api/aio/__init__.py
Empty file.
46 changes: 46 additions & 0 deletions pyrez/command_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def check_python(min_version=(3, 5)):
import sys
from .__version__ import __package_name__
from datetime import datetime

if sys.version_info[:2] < min_version and datetime.utcnow().year >= 2020:
print("ERROR: {} requires at least Python {} to run.".format(__package_name__.capitalize(), '.'.join(map(str, (min_version)))))
sys.exit(1)

def show_version():
from .__version__ import __package_name__, version_info

import sys
import platform
import requests
entries = []
entries.append("- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}".format(sys.version_info))
entries.append("- {0} v{1.major}.{1.minor}.{1.micro}-{1.releaselevel}".format(__package_name__.capitalize(), version_info))

entries.append("- requests v{0.__version__}".format(requests))
entries.append("- System info: {0.system} {0.release} {0.version}".format(platform.uname()))
print("\n".join(entries))

def parse_cli_flags(args):
from .__version__ import __package_name__, __version__
from argparse import ArgumentParser

parser = ArgumentParser(prog=__package_name__.capitalize(), usage="%(prog)s [arguments]")
parser.add_argument("--version", "-V", "-v", action="store_true", help="Show %(prog)s's current version")
parser.set_defaults(func=show_version)

return parser.parse_args(args)

def main():
import sys

cli_flags = parse_cli_flags(sys.argv[1:])
if cli_flags.version:
show_version()
sys.exit(0)

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion pyrez/models/Mixin/Dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def __repr__(self):
return self.__str__()
def __str__(self):
import json
return json.dumps(self.__kwargs__, sort_keys=True, indent=2) if self.__kwargs__ else '' #return str(self.__kwargs__).replace("'", "\"") if self.__kwargs__ else None
return json.dumps(self.__kwargs__, sort_keys=True, indent=2) if self.__kwargs__ else None #return str(self.__kwargs__).replace("'", "\"") if self.__kwargs__ else None
3 changes: 1 addition & 2 deletions pyrez/models/ServerStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ class ServerStatus(APIResponse):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.entryDateTime = kwargs.get("entry_datetime", None) if kwargs else None
self.environment = kwargs.get("environment", None) if kwargs else None
self.limitedAccess = kwargs.get("limited_access", False) if kwargs else False
self.platform = kwargs.get("platform", None) if kwargs else None
self.status = str(kwargs.get("status", None).upper()) == "UP" if kwargs else False
self.version = kwargs.get("version", None) if kwargs else None
def __str__(self):
return "entry_datetime: {0.entryDateTime} platform: {0.platform} status: {1} version: {0.version}".format(self, "UP" if self.status else "DOWN")
3 changes: 0 additions & 3 deletions requirements/async.txt

This file was deleted.

43 changes: 20 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
#https://realpython.com/pipenv-guide/
import os
import sys
from datetime import datetime
from subprocess import call
from shutil import rmtree
from setuptools import find_packages, setup, Command

os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) # allow setup.py to be run from any path
HERE = os.path.abspath(os.path.dirname(__file__))

if sys.version_info[:2] < (3, 4) and datetime.utcnow().year >= 2020:
raise RuntimeError("Unsupported Python version - Pyrez requires Python 3.4+")
if sys.version_info[:2] < (3, 5) and datetime.utcnow().year >= 2020:
print("ERROR: {} requires at least Python 3.5 to run.".format(NAME.capitalize()))
sys.exit(1)

def __getGithub(_acc, _end=None):
return "https://github.com/{}/{}{}".format(_acc, NAME, "/{}".format(_end) if _end else '')
def __readFile(fileName):
with open(os.path.join(HERE, fileName), 'r', encoding="utf-8") as f:
return f.read()

#https://docs.python.org/3/distutils/setupscript.html
#https://packaging.python.org/tutorials/packaging-projects/#description
#https://stackoverflow.com/questions/26737222/pypi-description-markdown-doesnt-work
#https://stackoverflow.com/questions/1471994/what-is-setup-py
def __getReadMe(fileName="README.rst"):
try:
import pypandoc
Expand All @@ -32,11 +28,7 @@ def __getReadMe(fileName="README.rst"):
def __regexFunc(pattern):
import re
return re.search(r'^__{}__\s*=\s*[\'"]([^\'"]*)[\'"]'.format(pattern), __readFile("pyrez/__version__.py"), re.MULTILINE).group(1)

NAME, AUTHOR, AUTHOR_EMAIL, DESCRIPTION, LICENSE, URL, VERSION = __regexFunc("package_name"), __regexFunc("author"), __regexFunc("author_email"), __regexFunc("description"), __regexFunc("license"), __regexFunc("url"), __regexFunc("version")#https://www.python.org/dev/peps/pep-0440/
def getGithub(_acc, _end=None):
return "https://github.com/{}/{}{}".format(_acc, NAME, "/{}".format(_end) if _end else '')

class UploadCommand(Command):
"""Support setup.py upload."""

Expand All @@ -51,6 +43,7 @@ def initialize_options(self):
def finalize_options(self):
pass
def run(self):
from shutil import rmtree
try:
self.status("Removing previous builds…")
rmtree(os.path.join(HERE, "dist"))
Expand All @@ -66,16 +59,16 @@ def run(self):
call("git tag v{0}".format(VERSION), shell=False)
call("git push --tags", shell=False)
sys.exit()
#https://docs.python.org/3/distutils/setupscript.html
#https://packaging.python.org/tutorials/packaging-projects/#description
#https://stackoverflow.com/questions/26737222/pypi-description-markdown-doesnt-work
#https://stackoverflow.com/questions/1471994/what-is-setup-py
#https://stackoverflow.com/questions/17803829/how-to-customize-a-requirements-txt-for-multiple-environments
DOCS_EXTRAS_REQUIRE = [
"sphinx_rtd_theme>=0.4.3,<1",
"sphinxcontrib-asyncio",
"sphinxcontrib-websupport",
]
ASYNC_EXTRAS_REQUIRE = [
"aiohttp>=3.5.4;python_version>='3.5'",
"asyncio>=3.4.3;python_version>='3.4'",
]
DEV_EXTRAS_REQUIRE = [
"pip>=19.1.1",
"pipenv>=2018.11.26",
Expand Down Expand Up @@ -118,13 +111,17 @@ def run(self):
"upload": UploadCommand, #$ setup.py upload support.
},
description=DESCRIPTION,
entry_points = {
'console_scripts': [
"{0}={0}.command_line:main".format(NAME)
],
},
extras_require={
"async": ASYNC_EXTRAS_REQUIRE,
"dev": DEV_EXTRAS_REQUIRE,
"docs": DOCS_EXTRAS_REQUIRE,
},
#download_url="https://pypi.org/project/pyrez/#files", #getGithub("luissilva1044894", "tarball/{}".format(VERSION)) #{}/archive/{}.tar.gz".format(getGithub("luissilva1044894"), VERSION)
download_url=getGithub("luissilva1044894", "archive/{}.tar.gz".format(VERSION)),
#download_url="https://pypi.org/project/pyrez/#files", #__getGithub("luissilva1044894", "tarball/{}".format(VERSION)) #{}/archive/{}.tar.gz".format(__getGithub("luissilva1044894"), VERSION)
download_url=__getGithub("luissilva1044894", "archive/{}.tar.gz".format(VERSION)),
include_package_data=True,
install_requires=INSTALL_EXTRAS_REQUIRE,
keywords=["pyrez", "hirez", "hi-rez", "smite", "paladins", "realmapi", "open-source", "api", "wrapper", "library", "python", "api-wrapper", "paladins-api", "smitegame", "smiteapi", "realm-api", "realm-royale", "python3", "python-3", "python-3-6"],
Expand All @@ -143,11 +140,11 @@ def run(self):
#zip_safe=True,
#include_package_data=True, # include everything in source control (Accept all data files and directories matched by MANIFEST.in)
project_urls={
#"Documentation": "https://pyrez.readthedocs.io/en/stable/",
"Documentation": "https://{}.readthedocs.io/en/stable/".format(NAME),
"Discord: Support Server": "https://discord.gg/XkydRPS",
#"Changelog": "https://pyrez.readthedocs.io/en/stable/news.html",
"Github: Issues": getGithub("luissilva1044894", "issues"),
"Github: Repo": getGithub("luissilva1044894"),
"Github: Issues": __getGithub("luissilva1044894", "issues"),
"Github: Repo": __getGithub("luissilva1044894"),
"Say Thanks!": "https://saythanks.io/to/luissilva1044894",
},
)
Expand Down

0 comments on commit 54decee

Please sign in to comment.