From ecc0b174cb19ca621c07660a2526c913e8279bc5 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 27 May 2017 14:20:39 +0100 Subject: [PATCH] Add program version to context --- md_pdf/__init__.py | 1 + md_pdf/args.py | 2 ++ md_pdf/build/context.py | 4 +++- setup.py | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/md_pdf/__init__.py b/md_pdf/__init__.py index e69de29..7e49527 100644 --- a/md_pdf/__init__.py +++ b/md_pdf/__init__.py @@ -0,0 +1 @@ +__version__ = '1.0' diff --git a/md_pdf/args.py b/md_pdf/args.py index bf5ac06..3b42416 100644 --- a/md_pdf/args.py +++ b/md_pdf/args.py @@ -1,9 +1,11 @@ import argparse +from md_pdf import __version__ def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", help="Set verbosity level (repeat argument)", action="count", default=0) parser.add_argument("--update-csl", help="Update CSL files", action="store_true") + parser.add_argument("--version", action="version", version="%(prog)s {}".format(__version__)) parser.add_help = True return parser.parse_args() diff --git a/md_pdf/build/context.py b/md_pdf/build/context.py index 7919d79..f486b5c 100644 --- a/md_pdf/build/context.py +++ b/md_pdf/build/context.py @@ -1,6 +1,7 @@ from md_pdf.consts import TEMPLATES_DIR, STATIC_DIR, DATE_FORMAT, TIME_FORMAT, DATETIME_FORMAT from word_count import word_count from md_pdf.utils import get_plain_text +from md_pdf import __version__ from dateutil import parser import datetime import os @@ -11,7 +12,8 @@ EXTRA_CONTEXT = { 'static_dir': STATIC_DIR, 'date': datetime.datetime.now().strftime(DATE_FORMAT), 'time': datetime.datetime.now().strftime(TIME_FORMAT), - 'datetime': datetime.datetime.now().strftime(DATETIME_FORMAT) + 'datetime': datetime.datetime.now().strftime(DATETIME_FORMAT), + 'mdp_version': __version__ } diff --git a/setup.py b/setup.py index 5a59877..f0d671a 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ from setuptools import setup, find_packages - +from md_pdf import __version__ setup( name="md-pdf", - version="1.0", + version=__version__, use_scm_version=True, install_requires=[ "beautifulsoup4==4.5.3",