Add __PUBLISH__ logic

Closes https://gitlab.constantvzw.org/aa/etherdump/issues/3.

This allows for the following to be run:

    etherdump pull --publish-opt-in --all --pub mydump

And if `__PUBLISH__` is not present on the pads, then the pad will not
be archived. It is also possible to configure this magic word by
specifying the `--publish ...` option.
This commit is contained in:
Luke Murphy 2019-03-06 10:17:18 +01:00
parent 810a990d13
commit e82ac2db33
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -69,6 +69,8 @@ def main (args):
p.add_argument("--script", default="/versions.js", help="add script url to output pages, default: /versions.js")
p.add_argument("--nopublish", default="__NOPUBLISH__", help="no publish magic word, default: __NOPUBLISH__")
p.add_argument("--publish", default="__PUBLISH__", help="the publish magic word, default: __PUBLISH__")
p.add_argument("--publish-opt-in", default=False, action="store_true", help="ensure `--publish` is honoured instead of `--nopublish`")
args = p.parse_args(args)
@ -187,6 +189,13 @@ def main (args):
try_deleting((p+raw_ext,p+".raw.html",p+".diff.html",p+".meta.json"))
continue
##########################################
## ENFORCE __PUBLISH__ MAGIC WORD
##########################################
if args.publish_opt_in and args.publish not in text:
try_deleting((p+raw_ext,p+".raw.html",p+".diff.html",p+".meta.json"))
continue
ver["path"] = p+raw_ext
ver["url"] = quote(ver["path"])
with open(ver["path"], "w") as f: