hakai_api 1.2.0__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hakai_api-1.2.0 → hakai_api-1.3.0}/PKG-INFO +1 -1
- {hakai_api-1.2.0 → hakai_api-1.3.0}/hakai_api/Client.py +6 -7
- {hakai_api-1.2.0 → hakai_api-1.3.0}/hakai_api.egg-info/PKG-INFO +1 -1
- {hakai_api-1.2.0 → hakai_api-1.3.0}/README.md +0 -0
- {hakai_api-1.2.0 → hakai_api-1.3.0}/hakai_api/__init__.py +0 -0
- {hakai_api-1.2.0 → hakai_api-1.3.0}/hakai_api.egg-info/SOURCES.txt +0 -0
- {hakai_api-1.2.0 → hakai_api-1.3.0}/hakai_api.egg-info/dependency_links.txt +0 -0
- {hakai_api-1.2.0 → hakai_api-1.3.0}/hakai_api.egg-info/requires.txt +0 -0
- {hakai_api-1.2.0 → hakai_api-1.3.0}/hakai_api.egg-info/top_level.txt +0 -0
- {hakai_api-1.2.0 → hakai_api-1.3.0}/setup.cfg +0 -0
- {hakai_api-1.2.0 → hakai_api-1.3.0}/setup.py +0 -0
|
@@ -5,12 +5,11 @@ Last updated: April 2021
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
|
-
import
|
|
8
|
+
import json
|
|
9
9
|
from datetime import datetime
|
|
10
10
|
from time import mktime, sleep
|
|
11
11
|
from typing import Dict, Union
|
|
12
12
|
|
|
13
|
-
from pytz import utc
|
|
14
13
|
from requests_oauthlib import OAuth2Session
|
|
15
14
|
|
|
16
15
|
|
|
@@ -68,8 +67,8 @@ class Client(OAuth2Session):
|
|
|
68
67
|
|
|
69
68
|
def _save_credentials(self, credentials: Dict):
|
|
70
69
|
"""Save the credentials object to a file."""
|
|
71
|
-
with open(self._credentials_file, "
|
|
72
|
-
|
|
70
|
+
with open(self._credentials_file, "w") as outfile:
|
|
71
|
+
json.dump(credentials, outfile)
|
|
73
72
|
|
|
74
73
|
def _try_to_load_credentials_file(self) -> Union[Dict, bool]:
|
|
75
74
|
"""Try to load the cached credentials file."""
|
|
@@ -78,7 +77,7 @@ class Client(OAuth2Session):
|
|
|
78
77
|
|
|
79
78
|
with open(self._credentials_file, "rb") as infile:
|
|
80
79
|
try:
|
|
81
|
-
credentials =
|
|
80
|
+
credentials = json.load(infile)
|
|
82
81
|
expires_at = int(credentials["expires_at"])
|
|
83
82
|
except (KeyError, ValueError):
|
|
84
83
|
os.remove(self._credentials_file)
|
|
@@ -86,8 +85,8 @@ class Client(OAuth2Session):
|
|
|
86
85
|
|
|
87
86
|
now = int(
|
|
88
87
|
(
|
|
89
|
-
mktime(datetime.now(
|
|
90
|
-
+ datetime.now(
|
|
88
|
+
mktime(datetime.now().timetuple())
|
|
89
|
+
+ datetime.now().microsecond / 1000000.0
|
|
91
90
|
)
|
|
92
91
|
) # utc timestamp
|
|
93
92
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|