From 4fa958d537a5ba89851c0f463925f7655fd94d9b Mon Sep 17 00:00:00 2001 From: Mark Sullivan Date: Thu, 28 Jun 2018 15:18:31 -0700 Subject: Specify [disclaimer] header to insert --- divergence | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/divergence b/divergence index 9351e45..615c488 100755 --- a/divergence +++ b/divergence @@ -18,12 +18,15 @@ import subprocess import logging as log +DEFAULT_HEADER = """This page was generated automatically from Markdown using +the 'divergence' tool. Edits will need to be merged manually.""" + class DivergenceProgram: def __init__(self, user, password, url, space, force_update=False, include_toc=False, - include_header=True): + header=DEFAULT_HEADER): self.api = requests.Session() self.api.auth = (user, password) self.api.headers.update({'Content-Type': 'application/json'}) @@ -31,7 +34,7 @@ class DivergenceProgram: self.default_space = space self.force_update = force_update self.include_toc = include_toc - self.include_header = include_header + self.header = header # TODO: clean up this code duplication... use pandoc data directory # instead? self.pandoc_helper_path = None @@ -149,11 +152,10 @@ class DivergenceProgram: 1 3 """ + body - if self.include_header: + if self.header: body = """ -

This page was generated automatically from Markdown using the - 'divergence' tool. Edits will need to be merged manually.

+

""" + self.header + """

\n""" + body return body @@ -225,6 +227,9 @@ required environment variables: parser.add_argument("-f", "--force", action='store_true', help='Forces an update even if we think nothing has changed') + parser.add_argument("--header", + action='store', + help='Specify header to insert into the confluence document') parser.add_argument("--no-header", action='store_true', help='Disables inserting disclaimer headers into the confluence document') @@ -267,7 +272,7 @@ required environment variables: dp = DivergenceProgram(user,password, url, args.space_key, force_update=args.force, - include_header=not args.no_header, + header=args.header or (None if args.no_header else DEFAULT_HEADER), include_toc=args.toc) dp.run(args.FILE) -- cgit v1.2.3