Registry Mirror
搜索
Skip to content
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Files
Expand file tree
master
Breadcrumbs
python
/
clip.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
35 lines (27 loc) · 1.05 KB
master
Breadcrumbs
python
/
clip.py
Copy path
Top
File metadata and controls
Code
Blame
35 lines (27 loc) · 1.05 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import sys
import pyperclip
TEXT = {
'agree': """Yes, I agree. That sounds fine to me.""",
'busy': """Sorry, can we do this later this week or next week?""",
'upsell': """Would you consider making this a monthly donation?"""
}
def main() -> None:
"""Copy a phrase to the clipboard based on a keyphrase argument."""
if len(sys.argv) < 2:
print('Usage: py mclip.py [keyphrase] - copy phrase text')
sys.exit()
keyphrase = sys.argv[1] # first command line arg is the keyphrase
if keyphrase in TEXT:
pyperclip.copy(TEXT[keyphrase])
print('Text for ' + keyphrase + ' copied to clipboard.')
else:
print('There is no text for ' + keyphrase)
def clip(text: str, max_len: int = 80) -> str:
"""Return text clipped at the last space before or at max_len."""
end = None
if len(text) > max_len:
space_before = text.rfind(' ', 0, max_len)
end = space_before if space_before >= 0 else max_len
return text[:end].rstrip() if end else text
if __name__ == '__main__':
main()
You can’t perform that action at this time.