Skip to content
Snippets Groups Projects
Commit e4a68d56 authored by nimrod's avatar nimrod
Browse files

Use the module docstring as the package description.

Had to workaround the jinja package missing in some cases (like
pre-commit) so I can import the module to get the docstring.
parent eb0a5e57
Branches
No related tags found
No related merge requests found
Pipeline #849 passed
#!/usr/bin/env python #!/usr/bin/env python
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
from setuptools import setup, find_packages from setuptools import setup, find_packages
from template import __doc__ as description
setup( setup(
name="template", name="template",
version="0.6.4", version="0.6.4",
description="""A CLI tool for generating files from Jinja2 templates and description=description,
environment variables.""",
long_description=open("README.rst", "r").read(), long_description=open("README.rst", "r").read(),
long_description_content_type="text/x-rst", long_description_content_type="text/x-rst",
url="https://git.shore.co.il/nimrod/template", url="https://git.shore.co.il/nimrod/template",
......
...@@ -10,12 +10,19 @@ from __future__ import ( ...@@ -10,12 +10,19 @@ from __future__ import (
unicode_literals, unicode_literals,
) # pylint: disable=duplicate-code ) # pylint: disable=duplicate-code
from os import environ from os import environ
from sys import stdin, stdout import sys
import argparse import argparse
from argparse import ArgumentParser from argparse import ArgumentParser
from jinja2 import Environment
import template.filters import template.filters
# I ignore import errors here and fail on them later in the main function so
# the module can be imported by the setup.py with jinja missing so the
# docstring can be used as the package description.
try:
from jinja2 import Environment
except ImportError:
pass
__version__ = "0.6.4" __version__ = "0.6.4"
...@@ -47,10 +54,16 @@ def main(): ...@@ -47,10 +54,16 @@ def main():
type=argparse.FileType("w"), type=argparse.FileType("w"),
) )
args = parser.parse_args() args = parser.parse_args()
infd = args.filename if args.filename else stdin infd = args.filename if args.filename else sys.stdin
outfd = args.output if args.output else stdout outfd = args.output if args.output else sys.stdout
print(render(infd.read()), file=outfd) print(render(infd.read()), file=outfd)
if __name__ == "__main__": if __name__ == "__main__":
if "Environment" not in dir():
print(
"Failed to import jinja2, is the package installed?",
file=sys.stderr,
)
sys.exit(2)
main() main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment