Add program version to context

This commit is contained in:
Jake Howard 2017-05-27 14:20:39 +01:00
parent 67020eb8c5
commit ecc0b174cb
4 changed files with 8 additions and 3 deletions

View file

@ -0,0 +1 @@
__version__ = '1.0'

View file

@ -1,9 +1,11 @@
import argparse import argparse
from md_pdf import __version__
def parse_args(): def parse_args():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", help="Set verbosity level (repeat argument)", action="count", default=0) 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("--update-csl", help="Update CSL files", action="store_true")
parser.add_argument("--version", action="version", version="%(prog)s {}".format(__version__))
parser.add_help = True parser.add_help = True
return parser.parse_args() return parser.parse_args()

View file

@ -1,6 +1,7 @@
from md_pdf.consts import TEMPLATES_DIR, STATIC_DIR, DATE_FORMAT, TIME_FORMAT, DATETIME_FORMAT from md_pdf.consts import TEMPLATES_DIR, STATIC_DIR, DATE_FORMAT, TIME_FORMAT, DATETIME_FORMAT
from word_count import word_count from word_count import word_count
from md_pdf.utils import get_plain_text from md_pdf.utils import get_plain_text
from md_pdf import __version__
from dateutil import parser from dateutil import parser
import datetime import datetime
import os import os
@ -11,7 +12,8 @@ EXTRA_CONTEXT = {
'static_dir': STATIC_DIR, 'static_dir': STATIC_DIR,
'date': datetime.datetime.now().strftime(DATE_FORMAT), 'date': datetime.datetime.now().strftime(DATE_FORMAT),
'time': datetime.datetime.now().strftime(TIME_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__
} }

View file

@ -1,9 +1,9 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
from md_pdf import __version__
setup( setup(
name="md-pdf", name="md-pdf",
version="1.0", version=__version__,
use_scm_version=True, use_scm_version=True,
install_requires=[ install_requires=[
"beautifulsoup4==4.5.3", "beautifulsoup4==4.5.3",