Skip to content

Commit

Permalink
terrabutler: utils.py: Add is_semantic_version
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelNdeCarvalho committed May 13, 2022
1 parent 1be6e63 commit d6568a9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions terrabutler/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from terrabutler.requirements import check_requirements
from sys import exit
from semantic_version import Version
from os import getenv

check_requirements()
Expand All @@ -13,3 +15,17 @@
"templates": ROOT_PATH + "/configs/templates",
"variables": ROOT_PATH + "/configs/variables"
}


def is_semantic_version(version):
"""
Check if the version corresponds to the semantic versioning.
"""
try:
Version(version)
except ValueError:
return False
except Exception as e:
print(f"There was an error while parsing version: {e}")
exit(1)
return True

0 comments on commit d6568a9

Please sign in to comment.