-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
src/cmd/contact/delete.sh
Outdated
gpg --delete-keys "$@" | ||
else | ||
gpg --batch --no-tty --yes --delete-keys "$@" | ||
yesno "Delete contact(s). Are you sure?" || return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is does not preserve the original behavior.
The question itself is meaningless and does not add any extra protection, without showing the contacts that are going to be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Make tests pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of the files __init.py__
?
src/egpg.sh
Outdated
@@ -124,6 +124,7 @@ call_fn() { | |||
call_gpg() { | |||
local file=$1; shift | |||
local pyfile="$LIBDIR/gpg/$file" | |||
export PYTHONPATH=$PYTHONPATH:"$LIBDIR/gpg/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be better moved down, before the python3
call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok done.
src/gpg/contact/delete.py
Outdated
for key in keys: | ||
if(not force): | ||
print_key(key.fpr) | ||
ans = input("Delete this key from the keyring? (y/N)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are deleting contacts, not keys. Why do you print a key? Why do you ask for a key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am currently somewhat imitating what egpg did earlier. This is one of the ways it could be done. I pushed it here to discuss more about it.
So here is what gpg commands (egpg) originally did:
- If I pass a
egpg delete contact1
without --force- For each key of the contact gpg asked if you want to delete the key (with the exact same message)
- it exited as soon as one key was deleted
- If I pass
egpg delete contact1 --force
- it deletes all keys matching contact1
What i am doing right now is:
- delete all keys matching the contact in case of
--force
without any messages - for all matching keys with the contact ask one by one and let the user choose to delete or not
(y/N)
(I feel it is helpful if he wants to delete specific keys corresponding to a contact name).
Would like your suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way to approach this could be:
-
by default doing a
cmd_contact_list contact1
first and askingdelete all these keys matching contact1 (y/N)
. If these are more keys let the user him/herself delete these by using keyids instead. -
we might add a option
--interactive
which has the current behavior as mentioned in the above comment. -
--force
dominates over--interactive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am currently somewhat imitating what egpg did earlier.
You can stick to the gpg
behavior if you want. But I don't think it is right to delete single subkeys of a given contact (in case he has different encryption subkeys).
Actually I think that we are talking about different contacts, although they may have the same name and the same email address. So what you are doing may be right. You are actually deleting all the matching contacts (the contacts that match with the given search string), not all the keys of the given contact. I am not sure if I am explaining myself clearly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we talk about contact1
, as an argument to the delete command, it can be an email address, or a full name, or a first name, etc. So, it is actually a search pattern which may match more than one contact (called key
in the gpg language, which is an overloaded term according to me). It makes sense to ask for each of these matching contacts whether they should be deleted or not. But when we delete a contact, we delete it completely, not only one subkey of it. I believe this is also the current behavior of gpg
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup I think I got it : a contact in egpg is identified as a key (with subkeys) in gpg / gpgme.
I am deleting all subkeys with the key at once only.
I was actually talking about the case of multiple contact matches occur corresponding to the string passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had borrowed the message Delete this key from the keyring? (y/N)
from gpg only. If it seems confusing I can change key
to contact
.
It does delete a key with all subkeys together as mentioned above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be confusing for the user, because as far as the user knows there is only one key, his own private key. All the rest are contacts.
Sorry, I just notice the label "work in progress". Otherwise I would not have made a review. |
print_key modified
The purpose of |
@dashohoxha the PR can be reviewed now. |
Since this required quite some changes with the print_key functionality I also addressed contact list in this PR only. |
some minor changes in contact list
Its fine and I am sorry too, I hadn't updated my progress for the day so pushed whatever I had done by that time. |
Now I understand it. I guess that you can merge this PR as soon as @sourabhtk37 reviews the code style etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few pointers here and there. Great job 👏
src/gpg/contact/delete.py
Outdated
keys = list(c.keylist(contact)) | ||
ans = "n" | ||
for key in keys: | ||
if(not force): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why still use brackets for if expr
? Please keep it consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool I have addressed this and also opened #79 also for this. This gets missed as I am using flake8 which doesn't detect this by default.
src/gpg/contact/list.py
Outdated
try: | ||
c = gpg.Context() | ||
|
||
key_set = set({}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply initialise a set as set()
.
src/gpg/contact/list.py
Outdated
key_set = set({}) | ||
|
||
for contact in contact_list: | ||
key_set.update(set(c.keylist(contact))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might want to use the set.add()
method or are we missing some use-case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A contact (contact string) can have multiple matches. This is intended to list all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set is required as in case of multiple arguments, like egpg contact ls divesh $MYKEYID
i want to list each contact only once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if c.keylist
returns a list, you don't need to convert it into a set is what I'm inferring, it will do that on its own afaik.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It returns a generator but yup it will do the job I guess.
src/gpg/contact/list.py
Outdated
from fn.print_key import print_key | ||
|
||
|
||
def ls(contact_list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe have a bit more descriptive function name like: list_contact
, you can do away with comments with this.
Tip: Your code should be such that it doesn't required comments to describe what it is doing. I think it's pretty clear with the function name.
Something to read:https://blog.codinghorror.com/coding-without-comments/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dashohoxha Good to go imo.
closes #35 closes #40