33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
|
|
|
|
class BlenderVersion:
|
|
def __init__(self, version: str = '5.1.0'):
|
|
"""
|
|
Need an object like 'X.Y.Z' to work correctly, build a pythonic object about a blender version.
|
|
:param version:
|
|
"""
|
|
self.major : str = ''
|
|
self.minor : str = ''
|
|
self.hotfix : str = ''
|
|
self.version_object(version)
|
|
|
|
def version_object(self, version: str):
|
|
"""Set all version properties to a string"""
|
|
version = version.split('.')
|
|
self.major = version[0]
|
|
self.minor = version[1]
|
|
self.hotfix = version[2]
|
|
|
|
def format_to_tag(self, repository: str) -> str:
|
|
"""From version information, format to return a string"""
|
|
return f'{repository}:{self.major}.{self.minor}.{self.hotfix}'
|
|
|
|
def tag_name(self) -> str:
|
|
"""Return the tag name 'latest', 'X.Y.Z'..."""
|
|
return f'{self.major}.{self.minor}.{self.hotfix}'
|
|
|
|
def tag_name_slugify(self):
|
|
return f'{self.major}-{self.minor}-{self.hotfix}'
|
|
|
|
def __str__(self):
|
|
return str(self.major + '.' + self.minor + '.' + self.hotfix) |