Skip to content

Commit

Permalink
add version_number_str
Browse files Browse the repository at this point in the history
  • Loading branch information
MinchinWeb committed Aug 30, 2015
1 parent bcdbb74 commit 48a4366
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions minchin/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

'''Minchin.Text
v.5.0.2 - WM - June 15, 2015
v.5.1.0 - WM - August 29, 2015
This is a helper file, containing formatting helps for creating command line
programs.
Expand All @@ -13,7 +13,7 @@
import re
import colorama

__version__ = '5.0.2'
__version__ = '5.1.0'

# Fix Python 2.x.
try:
Expand Down Expand Up @@ -222,6 +222,22 @@ def reset(self):
self.current = 0


def version_number_str(major, minor=0, patch=0, prerelease=None, build=None):
"""Takes the parts of a semantic version number, and returns a nicely formatted string"""
version = str(major) + '.' + str(minor) + '.' + str(patch)
if prerelease:
if prerelease.startswith('-'):
version = version + prerelease
else:
version = version + "-" + str(prerelease)
if build:
if build.startswith('+'):
version = version + build
else:
version = version + "+" + str(build)
return(version)


# To-Do:
# * add a 'rainbow-ize function to make text a rainbow of colours!
# * add a 'align-righted' function (text on right)

0 comments on commit 48a4366

Please sign in to comment.