From 96d5cb9be28037b024ec87411a3f87d9ac313fe9 Mon Sep 17 00:00:00 2001 From: Merlintor Date: Tue, 9 Feb 2021 10:28:25 +0100 Subject: [PATCH 1/2] Make package installable over git --- setup.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..97f779b --- /dev/null +++ b/setup.py @@ -0,0 +1,23 @@ +import pathlib + +import setuptools + +ROOT = pathlib.Path(__file__).parent + +setuptools.setup( + name="bottom", + version="0.0.1", + description="Pure python implementation of https://github.com/bottom-software-foundation/bottom-rs", + url="https://github.com/bottom-software-foundation/bottom-py", + packages=setuptools.find_packages(), + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", + "Operating System :: OS Independent", + ], + install_requires=[], + python_requires=">=3.0", +) From ff7270745110ead33111c5f1643b40b39a24aaeb Mon Sep 17 00:00:00 2001 From: Merlintor Date: Tue, 9 Feb 2021 10:28:51 +0100 Subject: [PATCH 2/2] Compatibility with older python versions --- bottom.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/bottom.py b/bottom.py index 5c9226a..90e602f 100644 --- a/bottom.py +++ b/bottom.py @@ -1,11 +1,14 @@ -CHARACTER_VALUES = { - 200: "🫂", - 50: "💖", - 10: "✨", - 5: "🥺", - 1: ",", - 0: "❤️" -} +from collections import OrderedDict + + +CHARACTER_VALUES = OrderedDict([ + (200, "🫂"), + (50, "💖"), + (10, "✨"), + (5, "🥺"), + (1, ","), + (0, "❤️") +]) SECTION_SEPERATOR = '👉👈' @@ -28,7 +31,8 @@ def to_bottom(text: str) -> str: def from_bottom(text: str) -> str: out = bytearray() - text = text.strip().removesuffix(SECTION_SEPERATOR) + + text = text.strip()[:-len(SECTION_SEPERATOR)] if not all(c in CHARACTER_VALUES.values() for c in text.replace(SECTION_SEPERATOR, '')): raise TypeError(f'Invalid bottom text: {text}')