Skip to content

Commit

Permalink
🎉 Release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
torrua committed Dec 12, 2020
1 parent cae75dc commit 9e8fdfc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sudo: false
os: linux
dist: xenial
language: python
python:
- "3.5"
Expand Down
10 changes: 5 additions & 5 deletions callbaker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def info_from_callback(call_data: str, separators: tuple = (EMS, IMS, DMV)) -> d
"""

if not isinstance(call_data, str):
raise TypeError(f"call_data should be a str type. You input {type(call_data)}.")
raise TypeError("call_data should be a str type. You input %s." % type(call_data))

for sep in separators:
if not isinstance(sep, str):
raise TypeError(f"Separator should be a str type. You input {type(sep)}.")
raise TypeError("Separator should be a str type. You input %s." % type(sep))

_ems, _ims, _ = separators
separated_items = call_data.split(_ems)
Expand All @@ -49,17 +49,17 @@ def callback_from_info(info: dict, separators: tuple = (EMS, IMS, DMV)) -> str:
:return:
"""
if not isinstance(info, dict):
raise TypeError(f"info should be a dict type. You input {type(info)}.")
raise TypeError("Info should be a dict type. You input %s." % type(info))

for sep in separators:
if not isinstance(sep, str):
raise TypeError(f"Separator should be a str type. You input {type(sep)}.")
raise TypeError("Separator should be a str type. You input %s." % type(sep))

_ems, _ims, _ = separators

callback = "".join(["%s%s%s%s" % (_ems, mark, _ims, value) for mark, value in info.items()])

if len(callback) > 64:
raise ValueError("The length of callback_data should not be more that 64 symbols."
f"Your callback's length is {len(callback)} symbols.")
"Your callback's length is %s symbols." % len(callback))
return callback
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def read(filename):
setup(
name='callbaker',
packages=['callbaker'],
version='1.1.0',
version='1.2.0',
license='MIT',
description="Telegram Button Callback Data Converter",
long_description=read("README.md"),
long_description_content_type="text/markdown",
author='torrua',
author_email='torrua@gmail.com',
url='https://github.com/torrua/callbaker',
download_url='https://github.com/torrua/callbaker/archive/v1.1.0.tar.gz',
download_url='https://github.com/torrua/callbaker/archive/v1.2.0.tar.gz',
keywords=['Convert', 'Callback', 'Keyboard', 'Telegram', "Inline"],
classifiers=[
'Development Status :: 4 - Beta', # "3 - Alpha", "4 - Beta" or "5 - Production/Stable"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_info_from_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def test_call_data_without_separators(self):
@pytest.mark.parametrize("value", bool_tuple)
def test_call_data_bool(self, value):
result = info_from_callback(
call_data=f"&key_1={value}")
call_data="&key_1=%s" % value)
assert isinstance(result, dict)
assert result['key_1'] == value

def test_call_data_digit(self):
result = info_from_callback(
call_data=f"&key_1=20")
call_data="&key_1=20")
assert isinstance(result, dict)
assert result['key_1'] == 20

0 comments on commit 9e8fdfc

Please sign in to comment.