Add more reasoning
This commit is contained in:
parent
28706e9c93
commit
cdd255c5bb
@ -215,6 +215,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
revisions = response["data"]["revisions"]
|
revisions = response["data"]["revisions"]
|
||||||
if meta["revisions"] == revisions and not args.force:
|
if meta["revisions"] == revisions and not args.force:
|
||||||
skip = True
|
skip = True
|
||||||
|
reason = "No new revisions, we already have the latest local copy"
|
||||||
break
|
break
|
||||||
|
|
||||||
meta["padid"] = padid
|
meta["padid"] = padid
|
||||||
@ -234,6 +235,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
|
|
||||||
if (meta["revisions"] == 0) and (not args.zerorevs):
|
if (meta["revisions"] == 0) and (not args.zerorevs):
|
||||||
skip = True
|
skip = True
|
||||||
|
reason = "0 revisions, this pad was never edited"
|
||||||
break
|
break
|
||||||
|
|
||||||
# todo: load more metadata!
|
# todo: load more metadata!
|
||||||
@ -261,6 +263,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
skip = True
|
skip = True
|
||||||
|
reason = "PANIC, couldn't download the pad contents"
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
await trio.sleep(1)
|
await trio.sleep(1)
|
||||||
@ -272,10 +275,11 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
skip = True
|
skip = True
|
||||||
|
reason = "PANIC, couldn't download the pad contents"
|
||||||
break
|
break
|
||||||
|
|
||||||
if skip:
|
if skip:
|
||||||
print("[ ] {} (skipped)".format(padid))
|
print("[ ] {} (skipped, reason: {})".format(padid, reason))
|
||||||
return
|
return
|
||||||
|
|
||||||
if args.output:
|
if args.output:
|
||||||
@ -286,7 +290,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
path = trio.Path(os.path.split(metapath)[0])
|
path = trio.Path(os.path.split(metapath)[0])
|
||||||
await path.mkdir()
|
await path.mkdir()
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
print("PANIC: unable to create {}".format(str(path)))
|
||||||
|
|
||||||
if args.all or args.text:
|
if args.all or args.text:
|
||||||
url = info["localapiurl"] + "getText?" + urlencode(data)
|
url = info["localapiurl"] + "getText?" + urlencode(data)
|
||||||
@ -310,7 +314,11 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
p + ".meta.json",
|
p + ".meta.json",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print("[ ] {} (no publish)".format(padid))
|
print(
|
||||||
|
"[ ] {} (deleted, reason: explicit __NOPUBLISH__)".format(
|
||||||
|
padid
|
||||||
|
)
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
@ -325,7 +333,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
p + ".meta.json",
|
p + ".meta.json",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print("[ ] {} (publish opt out)".format(padid))
|
print("[ ] {} (deleted, reason: publish opt-out)".format(padid))
|
||||||
return
|
return
|
||||||
|
|
||||||
ver["path"] = p + raw_ext
|
ver["path"] = p + raw_ext
|
||||||
@ -443,7 +451,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
async with await trio.open_file(metapath, "w") as f:
|
async with await trio.open_file(metapath, "w") as f:
|
||||||
await f.write(json.dumps(meta))
|
await f.write(json.dumps(meta))
|
||||||
|
|
||||||
print("[x] {}".format(padid))
|
print("[x] {} (saved)".format(padid))
|
||||||
|
|
||||||
|
|
||||||
async def handle_pads(args):
|
async def handle_pads(args):
|
||||||
|
Loading…
Reference in New Issue
Block a user