本文整理汇总了Python中pyperclip.copy方法的典型用法代码示例。如果您正苦于以下问题:Python pyperclip.copy方法的具体用法?Python pyperclip.copy怎么用?Python pyperclip.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyperclip
的用法示例。
在下文中一共展示了pyperclip.copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lazy_load_stub_copy
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def lazy_load_stub_copy(text):
'''
A stub function for copy(), which will load the real copy() function when
called so that the real copy() function is used for later calls.
This allows users to import pyperclip without having determine_clipboard()
automatically run, which will automatically select a clipboard mechanism.
This could be a problem if it selects, say, the memory-heavy PyQt4 module
but the user was just going to immediately call set_clipboard() to use a
different clipboard mechanism.
The lazy loading this stub function implements gives the user a chance to
call set_clipboard() to pick another clipboard mechanism. Or, if the user
simply calls copy() or paste() without calling set_clipboard() first,
will fall back on whatever clipboard mechanism that determine_clipboard()
automatically chooses.
'''
global copy, paste
copy, paste = determine_clipboard()
return copy(text)
示例2: init_dev_clipboard_clipboard
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def init_dev_clipboard_clipboard():
def copy_dev_clipboard(text):
text = _stringifyText(text) # Converts non-str values to str.
if text == '':
warnings.warn('Pyperclip cannot copy a blank string to the clipboard on Cygwin. This is effectively a no-op.')
if '\r' in text:
warnings.warn('Pyperclip cannot handle \\r characters on Cygwin.')
fo = open('/dev/clipboard', 'wt')
fo.write(text)
fo.close()
def paste_dev_clipboard():
fo = open('/dev/clipboard', 'rt')
content = fo.read()
fo.close()
return content
return copy_dev_clipboard, paste_dev_clipboard
示例3: lazy_load_stub_paste
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def lazy_load_stub_paste():
'''
A stub function for paste(), which will load the real paste() function when
called so that the real paste() function is used for later calls.
This allows users to import pyperclip without having determine_clipboard()
automatically run, which will automatically select a clipboard mechanism.
This could be a problem if it selects, say, the memory-heavy PyQt4 module
but the user was just going to immediately call set_clipboard() to use a
different clipboard mechanism.
The lazy loading this stub function implements gives the user a chance to
call set_clipboard() to pick another clipboard mechanism. Or, if the user
simply calls copy() or paste() without calling set_clipboard() first,
will fall back on whatever clipboard mechanism that determine_clipboard()
automatically chooses.
'''
global copy, paste
copy, paste = determine_clipboard()
return paste()
示例4: copy
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def copy(to_copy, name='password', erase=False):
"""
Copy an item to the clipboard
"""
global clipboard_signature
# Discard invalid input like `None` or empty strings
if not erase and (type(to_copy) != str or to_copy == ''):
print('* Nothing to copy!')
return False
pyperclip.copy(to_copy)
if not erase:
print('* The %s has been copied to the clipboard.' % (name))
# Save signature
clipboard_signature = get_signature(to_copy)
示例5: paste
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def paste(self, *args):
""" Usage: paste([PSMRL], text)
If a pattern is specified, the pattern is clicked first. Doesn't support text paths.
``text`` is pasted as is using the OS paste shortcut (Ctrl+V for Windows/Linux, Cmd+V
for OS X). Note that `paste()` does NOT use special formatting like `type()`.
"""
target = None
text = ""
if len(args) == 1 and isinstance(args[0], basestring):
text = args[0]
elif len(args) == 2 and isinstance(args[1], basestring):
self.click(target)
text = args[1]
else:
raise TypeError("paste method expected [PSMRL], text")
pyperclip.copy(text)
# Triggers OS paste for foreground window
PlatformManager.osPaste()
time.sleep(0.2)
示例6: process_output
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def process_output(self, text, args):
if args.json:
res = self.output_as_json(text)
print(res)
elif args.cmd:
if args.custom_depth:
self.markdown = args.custom_depth.split(",")
res = self.output_as_cmd(text)
print(res)
elif args.plain:
res = "\n".join(text)
print(res)
else:
print(text)
res = text
if args.clipboard:
pyperclip.copy(res)
if args.output:
codecs.open(args.output, "w", encoding="utf-8").write(u"{}".format(res))
示例7: piratebay_search
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def piratebay_search(query, doDownload):
url='https://pirateproxy.gdn/search/'+query+'/0/99/0'
print("Searching......")
source=requests.get(url).text
soup=bs(source,'lxml')
results=soup.find_all('div',class_='detName')
i=1
for r in results:
print(i,r.text)
i=i+1
if doDownload == True:
print("Enter the Serial Number of the search item you like to download: ")
choice=int(input())
print ("Fetching data.....")
magnet_results=soup.find_all('a',title='Download this torrent using magnet')
a=[]
for m in magnet_results:
a.append(m['href'])
magnet_link=(a[choice-1])
print("Magnet Link of your selected choice has been fetched.")
pyperclip.copy(magnet_link)
print ("Your magnet link is now in your clipboard.")
示例8: kickass_search
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def kickass_search(query, doDownload):
base_url="https://kickasss.to/"
url=base_url+query+'/'
print("Searching......")
source=requests.get(url).text
soup=bs(source,'lxml')
name=soup.find_all('a', class_="cellMainLink")
results=[]
i=1
for r in name:
print(i,r.text)
i=i+1
if doDownload == True:
print("Enter the Serial Number of the search item you like to download: ")
choice=int(input())
print ("Fetching data.....")
magnet=soup.find_all('a', title="Torrent magnet link")
a=[]
for m in magnet:
a.append(m['href'])
magnet_link=(a[choice-1])
print("Magnet Link of your selected choice has been fetched.")
pyperclip.copy(magnet_link)
print ("Your magnet link is now in your clipboard.")
示例9: register_commands
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def register_commands(commands):
commands['add'] = RecordAddCommand()
commands['edit'] = RecordEditCommand()
commands['rm'] = RecordRemoveCommand()
commands['search'] = SearchCommand()
commands['list'] = RecordListCommand()
commands['list-sf'] = RecordListSfCommand()
commands['list-team'] = RecordListTeamCommand()
commands['get'] = RecordGetUidCommand()
commands['append-notes'] = RecordAppendNotesCommand()
commands['download-attachment'] = RecordDownloadAttachmentCommand()
commands['upload-attachment'] = RecordUploadAttachmentCommand()
commands['delete-attachment'] = RecordDeleteAttachmentCommand()
commands['clipboard-copy'] = ClipboardCommand()
commands['record-history'] = RecordHistoryCommand()
commands['totp'] = TotpCommand()
示例10: register_command_info
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def register_command_info(aliases, command_info):
aliases['a'] = 'add'
aliases['s'] = 'search'
aliases['l'] = 'list'
aliases['lsf'] = 'list-sf'
aliases['lt'] = 'list-team'
aliases['g'] = 'get'
aliases['an'] = 'append-notes'
aliases['da'] = 'download-attachment'
aliases['ua'] = 'upload-attachment'
aliases['cc'] = 'clipboard-copy'
aliases['find-password'] = ('clipboard-copy', '--output=stdout')
aliases['rh'] = 'record-history'
for p in [search_parser, list_parser, get_info_parser, clipboard_copy_parser, record_history_parser, totp_parser, add_parser, edit_parser, rm_parser,
append_parser, download_parser, upload_parser, delete_attachment_parser]:
command_info[p.prog] = p.description
command_info['list-sf|lsf'] = 'Display all shared folders'
command_info['list-team|lt'] = 'Display all teams'
示例11: pass_load
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def pass_load(self, originator, path):
"""Load a password page."""
self.set_header(path)
self.current = path
self.mode = 'pass_load'
self._clear_box()
prevdir = os.path.dirname(path) or '.'
self.box.body.append(BackButton('BACK', self.dir_load, prevdir, self))
self.box.body.append(ActionButton('DISPLAY', self.call_pass,
(path, False, None)))
self.box.body.append(ActionButton('COPY FIRST LINE', self.call_pass,
(path, True, False)))
self.box.body.append(ActionButton('COPY EVERYTHING', self.call_pass,
(path, True, True)))
self.box.body.append(ActionButton('GENERATE NEW PASSWORD', self.generate_password, (path, 16, True, True)))
self.box.body.append(urwid.Text("More copy options are available after displaying the password."))
示例12: get_command
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def get_command(self, ctx, cmd_name):
"""Allow aliases for commands.
"""
if cmd_name == 'list':
cmd_name = 'ls'
elif cmd_name == 'search':
cmd_name = 'find'
elif cmd_name == 'gen':
cmd_name = 'generate'
elif cmd_name == 'add':
cmd_name = 'insert'
elif cmd_name in ['remove', 'delete']:
cmd_name = 'rm'
elif cmd_name == 'rename':
cmd_name = 'mv'
elif cmd_name == 'copy':
cmd_name = 'cp'
# TODO(benedikt) Figure out how to make 'show' the default
# command and pass cmd_name as the first argument.
rv = click.Group.get_command(self, ctx, cmd_name)
if rv is not None:
return rv
示例13: cp
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def cp(ctx, old_path, new_path, force):
"""Copies the password or directory names `old-path` to `new-path`.
This command is alternatively named `copy`. If `--force` is
specified, silently overwrite `new_path` if it exists. If
`new-path` ends in a trailing `/`, it is always treated as a
directory. Passwords are selectively reencrypted to the
corresponding keys of their new destination.
"""
try:
ctx.obj.copy_path(old_path, new_path, force)
except StoreNotInitialisedError:
click.echo(MSG_STORE_NOT_INITIALISED_ERROR)
return 1
except FileNotFoundError:
click.echo('{0} is not in the password store.'.format(old_path))
return 1
except PermissionError:
click.echo(MSG_PERMISSION_ERROR)
return 1
except RecursiveCopyMoveError:
click.echo(MSG_RECURSIVE_COPY_MOVE_ERROR.format('copy'))
return 1
示例14: piratebay_search
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def piratebay_search(query):
#ubuntu
url='https://pirateproxy.gdn/search/'+query+'/0/99/0'
print("Searching......")
source=requests.get(url).text
soup=bs(source,'lxml')
results=soup.find_all('div',class_='detName')
i=1
for r in results:
print(i,r.text)
i=i+1
print("Enter the Serial Number of the search item you like to download: ")
choice=int(input())
print ("Fetching data.....")
magnet_results=soup.find_all('a',title='Download this torrent using magnet')
a=[]
for m in magnet_results:
a.append(m['href'])
magnet_link=(a[choice-1])
print("Magnet Link of your selected choice has been fetched.")
pyperclip.copy(magnet_link)
print ("Your magnet link is now in your clipboard.")
handle_stream(magnet_link)
示例15: kickass_search
# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import copy [as 别名]
def kickass_search(query):
base_url="https://kat.unblocked.gdn/katsearch/page/1/"
url=base_url+query
print("Searching......")
source=requests.get(url).text
soup=bs(source,'lxml')
name=soup.find_all('a', class_="cellMainLink")
results=[]
i=1
for r in name:
print(i,r.text)
i=i+1
print("Enter the Serial Number of the search item you like to download: ")
choice=int(input())
print ("Fetching data.....")
magnet=soup.find_all('a', title="Torrent magnet link")
a=[]
for m in magnet:
a.append(m['href'])
magnet_link=(a[choice-1])
print("Magnet Link of your selected choice has been fetched.")
pyperclip.copy(magnet_link)
print ("Your magnet link is now in your clipboard.")
handle_stream(magnet_link)