File tree Expand file tree Collapse file tree
Chapter8–ReadingandWritingFiles Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/python3.5
2+
3+ """
4+
5+ Author: Samrat Banerjee
6+ Dated: 28/05/2018
7+ Description: PROJECT- Saves and loads pieces of text to the clipboard.
8+
9+ py.exe mcb.pyw save <keyword> - Saves clipboard to keyword.
10+ py.exe mcb.pyw <keyword> - Loads keyword to clipboard.
11+ py.exe mcb.pyw list - Loads all keywords to clipboard.
12+
13+ """
14+
15+ import shelve , pyperclip , sys
16+
17+ mcbShelf = shelve .open ('mcb' )
18+ # Save clipboard content
19+ if len (sys .argv ) == 3 and sys .argv [1 ].lower ()== 'save' :
20+ mcbShelf [sys .argv [2 ]]= pyperclip .paste ()
21+ #List keywords and load content
22+ elif len (sys .argv )== 2 :
23+ if sys .argv [1 ].lower () == 'list' :
24+ pyperclip .copy (str (list (mcbShelf .keys ())))
25+ elif sys .argv [1 ] in mcbShelf :
26+ pyperclip .copy (mcbShelf [sys .argv [1 ]])
27+ mcbShelf .close ()
You can’t perform that action at this time.
0 commit comments