Skip to content
This repository was archived by the owner on Jul 19, 2020. It is now read-only.

Commit 1295e3a

Browse files
authored
Develop/main (#15)
migrate to **v2.1.1**: * remove `USE_NONE_SAFE_VALUES` env var usage
1 parent 300d5c5 commit 1295e3a

File tree

5 files changed

+20
-23
lines changed

5 files changed

+20
-23
lines changed

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ Usage
3535
import ruz
3636
schedule = ruz.person_lessons("mymail@edu.hse.ru")
3737
38+
Module configuration performs throw setting environment variables:
39+
* `HSE_RUZ_ENABLE_LOGGING` - to enable verbose logging (`@log`)
40+
* `HSE_RUZ_API_URL` - url to RUZ API, possible values (not all endpoints supported for 2, 3):
41+
1. `http://92.242.58.221/ruzservice.svc` - default
42+
2. `http://92.242.58.221/ruzservice.svc/v2`
43+
3. `https://www.hse.ru/api`
44+
* `CHECK_EMAIL_ONLINE` - to enable online email verification (throw API call)
45+
3846

3947
Contributing
4048
------------

ruz/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
type_of_auditoriums)
1414

1515
__author__ = "Dmitriy Pchelkin | hell03end"
16-
__version__ = (2, 1, 0)
16+
__version__ = (2, 1, 1)

ruz/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ruz.schema import API_ENDPOINTS, API_URL, REQUEST_SCHEMA
1212

1313
CHECK_EMAIL_ONLINE = bool(os.environ.get("CHECK_EMAIL_ONLINE", False))
14-
USE_NONE_SAFE_VALUES = bool(os.environ.get("USE_NONE_SAFE_VALUES", True))
14+
1515
HSE_EMAIL_REGEX = re.compile(r"^[a-z0-9\._-]{3,}@(edu\.)?hse\.ru$")
1616

1717

@@ -167,25 +167,23 @@ def make_url(endpoint: str, **params) -> str:
167167
@log
168168
def get(endpoint: str,
169169
encoding: str="utf-8",
170-
return_none_safe: bool=USE_NONE_SAFE_VALUES,
171170
**params) -> (list, dict, None):
172171
"""
173-
Return requested data in JSON
172+
Return requested data in JSON (empty list on fallback)
174173
175174
Check request has correct schema.
176175
177176
:param endpoint - endpoint for request.
178177
:param encoding - encoding for received data.
179-
:param return_none_safe - return empty list on fallback.
180178
:param params - requested params
181179
"""
182180
if not is_valid_schema(endpoint, **params):
183-
return [] if return_none_safe else None
181+
return []
184182

185183
url = make_url(endpoint, **params)
186184
try:
187185
response = request.urlopen(url)
188186
return json.loads(response.read().decode(encoding))
189187
except (error.HTTPError, error.URLError) as err:
190188
logging.debug("Can't get '%s'.\n%s", url, err)
191-
return [] if return_none_safe else None
189+
return []

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
setup(
1313
name="hse_ruz",
1414
packages=packages,
15-
version="2.1.0",
15+
version="2.1.1",
1616
description="Python wrapper for HSE RUZ API",
1717
long_description=open(os.path.join(os.path.dirname(__file__),
1818
"README.rst")).read(),
@@ -24,8 +24,8 @@
2424
# "Development Status :: 1 - Planning",
2525
# "Development Status :: 2 - Pre-Alpha",
2626
# "Development Status :: 3 - Alpha",
27-
"Development Status :: 4 - Beta",
28-
# "Development Status :: 5 - Production/Stable",
27+
# "Development Status :: 4 - Beta",
28+
"Development Status :: 5 - Production/Stable",
2929
# "Development Status :: 6 - Mature",
3030
# "Development Status :: 7 - Inactive",
3131
"Environment :: Console",

tests/test_RUZ.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,16 @@ def test_is_valid_schema():
8282
def test_get():
8383
for endpoint in API_ENDPOINTS.keys():
8484
if endpoint == "schedule":
85-
none_safe = ruz.utils.get(
85+
response = ruz.utils.get(
8686
endpoint,
8787
email=INTRUSTED_EMAILS['other'],
8888
return_none_safe=True,
8989
check_email_online=False
9090
)
91-
usual = ruz.utils.get(
92-
endpoint,
93-
email=INTRUSTED_EMAILS['other'],
94-
return_none_safe=False,
95-
check_email_online=False
96-
)
9791
else:
98-
none_safe = ruz.utils.get(endpoint, tmp=123, return_none_safe=True)
99-
usual = ruz.utils.get(endpoint, tmp=123, return_none_safe=False)
100-
assert not none_safe
101-
assert isinstance(none_safe, list)
102-
assert not usual
103-
assert usual is None
92+
response = ruz.utils.get(endpoint, tmp=123, return_none_safe=True)
93+
assert not response
94+
assert isinstance(response, list)
10495

10596

10697
def test_schedules():

0 commit comments

Comments
 (0)