VersionInfo

VersionInfo is a small class I use to store version information about a Python app …

from collections import namedtuple

class VersionInfo (namedtuple('VersionInfo', 'name, major, minor, sub_minor, description')):
    """ VersionInfo: a read-only class to store and format version information. """

    @property
    def app_name (self)->str:
        return self.name

    @property
    def brief (self)->str:
        """ Get a brief description of this version. """
        return f"{self.name}: {self.major}.{self.minor}.{self.sub_minor}"

    @property
    def verbose (self)->str:
        """ Get a verbose description of this version. """
        return f"{self.name}: {self.major}.{self.minor}.{self.sub_minor} {self.description}"

    def __str__(self):
        return verbose

Copy the above code to a Python file, and import into your Python project.

Usage

Put this code in your main function …

vinfo = VersionInfo(app_name, 26, 2, 9, brief_description)
MessageCenter.ShowInfoMessage(vinfo.brief, vinfo.verbose, False)

Questions

Post questions about MicroStation programming to the MicroStation Programming Forum.