-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
document_editing.py
38 lines (26 loc) · 1.17 KB
/
document_editing.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
from pathlib import Path
from pyonepassword import OP
def replace_document():
op = OP()
document_title = "example document 01"
replacement_file_path = "path/to/replacement_image_01.png"
op.document_edit(document_title, replacement_file_path)
# or replacmenet document can be bytes instead of str/Path:
replacement_bytes = open(replacement_file_path, "rb").read()
op.document_edit(document_title, replacement_bytes)
def replace_document_set_title():
op = OP()
document_title = "example document 01"
replacement_file_path = "path/to/replacement_image_01.png"
new_document_title = "updated example document 01"
op.document_edit(document_title, replacement_file_path,
new_title=new_document_title)
def replace_document_set_filename():
op = OP()
document_title = "example document 01"
# replacement path may be Path or str
replacement_file_path = Path("path/to/replacement_image_01.png")
# get basename: "replacement_image_01.png"
new_document_filename = replacement_file_path.name
op.document_edit(document_title, replacement_file_path,
file_name=new_document_filename)