diff options
author | Mark Sullivan <msullivan@archive.org> | 2018-06-28 15:18:31 -0700 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2018-07-12 10:10:35 -0700 |
commit | 4fa958d537a5ba89851c0f463925f7655fd94d9b (patch) | |
tree | dc872be0e45ded4db03a2dd5fbf68ab2915a4d26 | |
parent | a88e3123c3c826bd28834f1dfb4a31c6389283ac (diff) | |
download | divergence-4fa958d537a5ba89851c0f463925f7655fd94d9b.tar.gz divergence-4fa958d537a5ba89851c0f463925f7655fd94d9b.zip |
Specify [disclaimer] header to insert
-rwxr-xr-x | divergence | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -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: <ac:parameter ac:name="minLevel">1</ac:parameter> <ac:parameter ac:name="maxLevel">3</ac:parameter> </ac:structured-macro>""" + body - if self.include_header: + if self.header: body = """<ac:structured-macro ac:name="info"> <ac:rich-text-body> - <p>This page was generated automatically from Markdown using the - 'divergence' tool. Edits will need to be merged manually. </p> + <p>""" + self.header + """</p> </ac:rich-text-body> </ac:structured-macro>\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) |