-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_paper.py
43 lines (34 loc) · 1.07 KB
/
update_paper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Trying to test papers"""
import os
import argparse
import dropbox
from dropbox.paper import (
ImportFormat,
PaperDocCreateUpdateResult,
PaperDocUpdatePolicy,
)
def main(args):
print(args)
dbx = dropbox.Dropbox(args.token)
print(f"uploading paper {args.in_file_path}")
with open(args.in_file_path, "rb") as in_file:
content = in_file.read()
docs_list = []
res: PaperDocCreateUpdateResult = dbx.paper_docs_update(
f=content,
doc_id=args.doc_id,
import_format=ImportFormat.html,
doc_update_policy=PaperDocUpdatePolicy.overwrite_all,
revision=int(args.rev),
)
print(f"{res.title} updated")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Updates a paper")
parser.add_argument(dest="in_file_path")
parser.add_argument(dest="doc_id")
parser.add_argument(dest="rev", default="1")
parser.add_argument("--token", "-t", dest="token", default=os.environ.get("DROPBOX_TOKEN"))
arg = parser.parse_args()
main(arg)
# 8UHH0KQFM0CdRYtByDCCk
# rev 53