muelli / geysigning

An easier way to sign OpenPGP keys over the local network
GNU General Public License v3.0
9 stars 10 forks source link

Optimizes parse_sig_list function in SignPages.py #13

Closed jobediah closed 9 years ago

jobediah commented 9 years ago

I went ahead and added comments to the source code but below is a comparison of the previous and current output.

Here's the original siglist output: root (DEBUG): sig record (12) ['sig', '', '', '1', '038562A096D57DC9', '1412545511', '', '', '', 'Jody XXXXXX xxxxxxxxx@hotmail.com', '13x', ''] root (DEBUG): sig record (12) ['sig', '', '', '1', '038562A096D57DC9', '1412545511', '', '', '', 'Jody XXXXXX xxxxxxxxx@hotmail.com', '18x', '']

With the original code since there are two copies of 'sig' in the text so you append the siglist twice. You also splice at every '\n' and ':'.

root (DEBUG): sig record (11) ['sig', '', '', '1', '038562A096D57DC9', '1412545511', '', '', '', 'Jody XXXXXX xxxxxxxxx@hotmail.com', '13x:\nspk:30:1:1:%01\nspk:27:1:1:%03\nspk:23:1:1:%80\nspk:22:1:3:%02%03%01\nspk:21:1:5:%08%02%09%0A%0B\nspk:16:0:8:%03%85b%A0%96%D5}%C9\nspk:11:1:5:%09%08%07%03%02\nspk:2:1:4:T1%BB%E7\nsub:u:1024:1:C81502C388070E36:1412545511::::::e:\nsig:::1:038562A096D57DC9:1412545511::::Jody XXXXXX xxxxxxxxx@hotmail.com:18x:\nspk:27:1:1:%0C\nspk:16:0:8:%03%85b%A0%96%D5}%C9\nspk:2:1:4:T1%BB%E7\n']

In my revisions you slice the text up until sig which eliminates splicing the '\n' (line 244). To circumvent splice all the ':', I set it so that it only splices the ':' up until after the uid (line 245). record[10] is the remainder of the text. Alternatively, I could set the slicing to a limited amount of characters so that siglist record[10] is less text.

jobediah commented 9 years ago

Okay, the output is exactly the same as the previous code.

Old code: [('keyID**_', 'timestamp_**', 'Your Name youremail@hotmail.com'), ('keyIDXXXXX', 'timestampXXXXX', 'Your Name youremail@hotmail.com’)]

New code: [('keyID**_', 'timestamp_**', 'Your Name youremail@hotmail.com'), ('keyIDXXXXX', 'timestampXXXXX', 'Your Name youremail@hotmail.com')]

The only optimization is that it no longer splits(":") if it does not contain sig in the line.

muelli commented 9 years ago

Good work!

I've merged this into the develop branch with e314d3500102a6f1c077f06546e1d3a793be6bd4