From 5262b54311117f92ab882f35a5337acff110c429 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 14 May 2020 12:47:24 -0400 Subject: [PATCH] barectf/__init__.py: build version string instead of parsing it This is more natural and less complicated. Leaving get_version_tuple() as some modules use it. Signed-off-by: Philippe Proulx --- barectf/__init__.py | 28 +++++++--------------------- doc/man/Makefile | 2 +- doc/man/barectf.1 | 8 ++++---- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/barectf/__init__.py b/barectf/__init__.py index f13bb19..ca03db1 100644 --- a/barectf/__init__.py +++ b/barectf/__init__.py @@ -1,6 +1,6 @@ # The MIT License (MIT) # -# Copyright (c) 2014-2016 Philippe Proulx +# Copyright (c) 2014-2020 Philippe Proulx # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,26 +20,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -__version__ = '2.3.1' - - -def _split_version_suffix(): - parts = __version__.split('-') - version = parts[0] - suffix = None - - if len(parts) == 2: - suffix = parts[1] - - return version, suffix +__major_version__ = 2 +__minor_version__ = 3 +__patch_version__ = 1 +__version__ = '{}.{}.{}'.format(__major_version__, __minor_version__, + __patch_version__) def get_version_tuple(): - version, suffix = _split_version_suffix() - parts = version.split('.') - - return (int(parts[0]), int(parts[1]), int(parts[2])) - - -def get_version_suffix(): - return _split_version_suffix()[1] + return __major_version__, __minor_version__, __patch_version__ diff --git a/doc/man/Makefile b/doc/man/Makefile index 5311f7f..4c79ad0 100644 --- a/doc/man/Makefile +++ b/doc/man/Makefile @@ -36,7 +36,7 @@ XSL_SRC_FILES = $(addprefix xsl/,$(XSL_FILES)) ASCIIDOC ?= asciidoc XMLTO ?= xmlto ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \ - -a barectf_version=$(shell grep '^__version__' ../../barectf/__init__.py | grep -Po '\d+\.\d+\.\d+(?:-\w+)?') + -a barectf_version=$(shell cd ../../barectf; python3 -c 'import __init__; print(__init__.__version__)') ADOC_DOCBOOK = $(ADOC) -b docbook XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man diff --git a/doc/man/barectf.1 b/doc/man/barectf.1 index 457a392..758c37d 100644 --- a/doc/man/barectf.1 +++ b/doc/man/barectf.1 @@ -1,13 +1,13 @@ '\" t .\" Title: barectf .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.79.1 -.\" Date: 11/15/2016 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 05/14/2020 .\" Manual: barectf manual -.\" Source: barectf 2.2.1 +.\" Source: barectf 2.3.1 .\" Language: English .\" -.TH "BARECTF" "1" "11/15/2016" "barectf 2\&.2\&.1" "barectf manual" +.TH "BARECTF" "1" "05/14/2020" "barectf 2\&.3\&.1" "barectf manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- -- 2.34.1