-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add item-edit example for non-field item properties
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
examples/item_editing/03-item-edit-non-field-properties.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from pyonepassword import OP | ||
|
||
|
||
def edit_non_field_properites(op: OP): | ||
""" | ||
You can edit/set the following non-field properties: | ||
- favorite (set/unset) | ||
- tags (You can set, remove, or add to an item's et of tags) | ||
- autofill URL property for Login items (this does not set URLs on arbitrary fields) | ||
- generate new password for Login or Password items (this does not generate passwords for arbitrary fields) | ||
""" | ||
|
||
item = "Example Login Item 104" | ||
new_item_label = "New Login Item 104" | ||
favorite = True | ||
tags = ["tag_1", "tag_2"] | ||
autofill_url = "https://new-url/login.html" | ||
vault = "Test Data 2" | ||
|
||
# Toggle item favorite flag | ||
op.item_edit_favorite(item, | ||
favorite, | ||
vault=vault) | ||
|
||
# Set or replace item's list of tags | ||
op.item_edit_tags(item, | ||
tags, | ||
append_tags=False, | ||
vault=vault) | ||
|
||
# for Login items, set the website/URL property | ||
op.item_edit_url(item, | ||
autofill_url, | ||
vault=vault) | ||
|
||
# set new item titel | ||
op.item_edit_title(item, | ||
new_item_label, | ||
vault=vault) | ||
|
||
|
||
if __name__ == "__main__": | ||
# see README.md for sign-in process | ||
op: OP = OP() | ||
edit_non_field_properites(op) |