From e82f1e4d1e224a30912d0ecc9a562cd30c9f74c7 Mon Sep 17 00:00:00 2001 From: Terence Lee <hone02@gmail.com> Date: Fri, 13 Jul 2018 12:06:44 -0500 Subject: [PATCH] add Python version operators --- bin/utils | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bin/utils b/bin/utils index b748bbea..33fd2b30 100755 --- a/bin/utils +++ b/bin/utils @@ -58,3 +58,30 @@ measure-size() { echo "$(du -s .heroku/python 2>/dev/null || echo 0) | awk '{print $1}')" } +# Python version operator > +version_gt() { + test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; +} + +# Python verison operator >= +version_gte() { + if [ "$1" == "$2" ]; then + return 0 + fi + + version_gt "$1" "$2" +} + +# Check if Python 2 +python2_check() { + VERSION="$1" + + version_gte "$VERSION" "python-2.7.0" && version_gt "python-3.0.0" "$VERSION" +} + +# Check if Python 3 +python3_check() { + VERSION="$1" + + version_gte "$VERSION" "python-3.0.0" && version_gt "python-4.0.0" "$VERSION" +} -- GitLab