本文整理汇总了Python中xerox.copy函数的典型用法代码示例。如果您正苦于以下问题:Python copy函数的具体用法?Python copy怎么用?Python copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
parser = optparse.OptionParser()
using_help = '''
the service that you want to use. For example: gist for Github's Gist,
pastebin for PasteBin.com
'''
parser.add_option('-u', '--using', dest='using',
help=using_help)
(options, args) = parser.parse_args()
using = options.using
if not using:
using = 'pastebin'
obj = SharePastesFactory.create(using)
try:
url = obj.api_call(xerox.paste())
xerox.copy(url)
except xerox.base.XclipNotFound:
print 'xclip not found. Install xclip for SharePastes to work.'
sys.exit(1)
try:
from pync import Notifier
Notifier.notify('URL added to your clipboard %s.' % url,
title='SharePastes')
except:
pass
开发者ID:vaidik,项目名称:sharepastes,代码行数:29,代码来源:runner.py
示例2: action
def action(args):
# TODO Handle STDOUT on get
keyword = args.keyword
namespace = args.namespace
conn = util.connect_database()
if not conn:
exit('Unable to access %s; exiting' % util.DB_LOCATION)
clippings = util.get_clippings(
conn,
key=keyword,
namespace=namespace
)
msg = value = None
if len(clippings) == 0: # Key not found
if namespace:
msg = "Unknown namespace/key: %s/%s" % (namespace, keyword)
else:
msg = "Unknown key: %s" % keyword
elif len(clippings) == 1:
value = clippings[0][1]
msg = "Set clipboard to %s" % value
xerox.copy(value)
else:
msg = 'Multiple choices:\n' + '\n'.join(
["\t%s/%s: %s" % (c[0], keyword, c[1]) for c in clippings]
)
return msg
开发者ID:snark,项目名称:pink,代码行数:30,代码来源:get.py
示例3: set_clipboard
def set_clipboard(text, datatype=None):
"""
Arg datatype currently not used. Will generally assumed to be unicode text.
From http://stackoverflow.com/questions/579687/how-do-i-copy-a-string-to-the-clipboard-on-windows-using-python
"""
if 'xerox' in sys.modules.keys():
xerox.copy(text)
elif 'pyperclip' in sys.modules.keys():
pyperclip.copy(text)
elif 'gtk' in sys.modules.keys():
clipboard = gtk.clipboard_get()
text = clipboard.set_text(text)
elif 'win32clipboard' in sys.modules.keys():
wcb = win32clipboard
wcb.OpenClipboard()
wcb.EmptyClipboard()
# wcb.SetClipboardText(text) # doesn't work
# SetClipboardData Usage:
# >>> wcb.SetClipboardData(<type>, <data>)
# wcb.SetClipboardData(wcb.CF_TEXT, text.encode('utf-8')) # doesn't work
wcb.SetClipboardData(wcb.CF_UNICODETEXT, unicode(text)) # works
wcb.CloseClipboard() # User cannot use clipboard until it is closed.
else:
# If code is run from within e.g. an ipython qt console, invoking Tk root's mainloop() may hang the console.
r = Tk()
# r.withdraw()
r.clipboard_clear()
r.clipboard_append(text)
r.mainloop() # the Tk root's mainloop() must be invoked.
r.destroy()
开发者ID:thomsen3,项目名称:gelutils,代码行数:30,代码来源:clipboard.py
示例4: main
def main():
args = parse_args()
tab = not args.spaces
code = add_indentation(get_code(args), tab)
if args.stdout: print code
else: xerox.copy(code)
开发者ID:matiasdoyle,项目名称:mdc,代码行数:8,代码来源:mdc.py
示例5: callback
def callback(event):
# moved to a name with Screen Shot in it
if event.mask is 128 and file_str in str(event.name):
# split the extension
fileExtension = os.path.splitext(event.name)[1]
newName = str(hash_for_file(event.name))[0:6] + fileExtension
upload_file(event.name, scp_path + newName)
xerox.copy(protocol + hostname + web_path + newName)
开发者ID:bwheatley,项目名称:maiscreenz,代码行数:8,代码来源:maiscreenz.py
示例6: convert_zalgo
def convert_zalgo(text, intensity=50, copy=False):
input_text = u' '.join(text)
zalgotext = zalgo.zalgo(input_text, intensity)
if copy:
xerox.copy(u'' + zalgotext)
return zalgotext
开发者ID:Miserlou,项目名称:Zalgo,代码行数:8,代码来源:__main__.py
示例7: test_copy_and_paste
def test_copy_and_paste(self):
# copy
self.assertIsInstance(self.text, str)
xerox.copy(self.text)
# paste
got = xerox.paste()
self.assertIsInstance(got, str)
self.assertEqual(got, self.text)
开发者ID:solarce,项目名称:xerox,代码行数:9,代码来源:test_xerox.py
示例8: parse
def parse(return_output=True, file_path=None):
if not file_path:
try:
file_path = sys.argv[1]
except IndexError:
# assume `email.html`
file_path = 'email.html'
# check file exists
if not exists(file_path):
raise IOError('File does not exist')
# check extension and mimetype
filename, ext = splitext(file_path)
mime_type = MimeTypes().guess_type(file_path)[0]
if ext.lower() not in ['.htm', '.html'] or mime_type != 'text/html':
raise Exception('File does not appear to be an HTML file.')
# process file
with open(file_path, 'r') as html_file:
data = html_file.read()
# extract body
soup = BeautifulSoup(data, 'html.parser')
body = soup.body.contents[1]
# strip comments
[comment.extract() for comment in body.findAll(
text=lambda text: isinstance(text, Comment))]
# replace image tags with the name of the image
body_soup = BeautifulSoup(str(body), 'html.parser')
for img in body_soup.findAll('img'):
img.replace_with(img['name'])
# add trouble link row
trouble_row = body_soup.new_tag('tr')
trouble_column = body_soup.new_tag('td')
trouble_column.string = 'trouble'
trouble_row.append(trouble_column)
body_soup.tr.insert_before(trouble_row)
# add inline css to each td
for td in body_soup.find_all('td'):
td['style'] = 'text-align: left; vertical-align: top;'
# right align trouble link text
body_soup.tr.td['style'] = 'text-align: right; vertical-align: top;'
output = unicode(body_soup)
# copy HTML to clipboard FTW
xerox.copy(output)
sys.stdout.write('HTML copied to clipboard' + '\n')
if return_output:
return output
开发者ID:alsoicode,项目名称:html-email-parser,代码行数:57,代码来源:parse.py
示例9: on_key_press
def on_key_press( self, symbol, modifiers ):
# whether we handle the text here
self.texthandled = 0
# kill the alert if you push anything
self.alerttime = 0
# some global key strokes
if symbol == key.F11:
if self.fullscreenwait == 0:
self.set_fullscreen( not self.fullscreen )
self.fullscreenwait = 1 # wait a second before allowing switching back
self.activate()
self.set_focus(None)
self.texthandled = 1
elif (symbol == key.Q or symbol == key.W) and modifiers & key.MOD_CTRL:
pyglet.app.exit()
# check for command mode...
elif self.commandmode:
if symbol == key.RETURN:
# if we pressed enter after entering a command...
self.setcommand( False )
self.texthandled = 1
# check for inputting things in some other focus box...
elif self.focus:
# if we are focused on some input device, don't let
# any other commands be available except to possibly escape from it,
# also basic copy and paste.
if symbol == key.ESCAPE:
self.set_focus( None )
self.texthandled = 1
elif symbol == key.C and modifiers & key.MOD_CTRL:
xerox.copy( self.focus.getselectedtext() )
self.texthandled = 1
elif symbol == key.V and modifiers & key.MOD_CTRL:
self.focus.dealwithtext( xerox.paste() )
self.texthandled = 1
# otherwise look at what it could mean for the global guy
else:
if ( symbol == key.Q or symbol == key.ESCAPE ):
self.texthandled = 1
self.alert( "ctrl+Q or ctrl+W to quit" )
elif symbol == key.SLASH:
self.texthandled = 1
self.setcommand() # get command mode ready
elif symbol == key.W:
self.alert(self.lastalert,10)
elif symbol == key.S:
self.savefile()
elif symbol == key.E:
self.loadfile( "scratch" )
print "key press ", symbol, " are we handled? ", self.texthandled
return pyglet.event.EVENT_HANDLED
开发者ID:lowagner,项目名称:pynances,代码行数:56,代码来源:pyglances.py
示例10: main
def main(poster, file):
payload = {}
payload["poster"] = poster
content, syntax = get_data_from_file(file)
payload["content"] = content
payload["syntax"] = syntax
res = requests.post('http://paste.ubuntu.com', data=payload)
link = res.url
print ('link is {}'.format(link))
xerox.copy(link)
print ('It\'s copied to the clipboard !')
开发者ID:dhruvagarwal,项目名称:pastebin_linkmaker,代码行数:11,代码来源:main.py
示例11: run
def run(self):
youdao = Youdao()
#youdao.get_translation(msg)
print "start youdao_copy"
xerox.copy("你好")
word = None
word_new =None
err_old = None
try :
word = xerox.paste()
except BaseException,err:
print err
开发者ID:chenzhongtao,项目名称:work_summary,代码行数:12,代码来源:youdao_copy.py
示例12: main
def main():
if (len(sys.argv) != 2):
exit("Which file?")
if APP_KEY == '' or APP_SECRET == '':
exit("You need to set your APP_KEY and APP_SECRET!")
lnd = LinkAndDelete(APP_KEY, APP_SECRET)
path = lnd.upload(sys.argv[1])
if (path):
path = path.replace(PUBLIC_DIR,"/")
url = "http://dl.dropbox.com/u/" + repr(lnd.getUID()) + path
Notifier.notify("LinkAndDelete","Loaded successfuly\n" + url,"GetLinkAndDelete")
xerox.copy(url)
os.remove(sys.argv[1])
开发者ID:kendersec,项目名称:LinkAndDelete,代码行数:13,代码来源:getLinkAndDelete.py
示例13: pw
def pw(query, database_path, copy, echo, open, strict):
"""Search for USER and KEY in GPG-encrypted password database."""
# install silent Ctrl-C handler
def handle_sigint(*_):
click.echo()
sys.exit(1)
signal.signal(signal.SIGINT, handle_sigint)
# load database
db = Database.load(database_path)
# parse query (split at right-most "@"" sign, since user names are typically email addresses)
user_pattern, _, key_pattern = query.rpartition('@')
# search database
results = db.search(key_pattern, user_pattern)
results = list(results)
if strict and len(results) != 1:
click.echo('error: multiple or no records found (but using --strict mode)', file=sys.stderr)
sys.exit(1)
# sort results according to key (stability of sorted() ensures that the order of accounts for any given key remains untouched)
results = sorted(results, key=lambda e: e.key)
# print results
output = ''
for idx, entry in enumerate(results):
# key and user
key = style_match(key_pattern).join(entry.key.split(key_pattern)) if key_pattern else entry.key
user = style_match(user_pattern).join(entry.user.split(user_pattern)) if user_pattern else entry.user
output += key
if user:
output += ': ' + user
# password
if echo:
output += ' | ' + style_password(entry.password)
if copy and idx == 0:
xerox.copy(entry.password)
output += ' | ' + style_success('*** PASSWORD COPIED TO CLIPBOARD ***')
# other info
if entry.link:
if open and idx == 0:
import webbrowser
webbrowser.open(entry.link)
output += ' | ' + entry.link
if entry.notes:
output += ' | ' + entry.notes
output += '\n'
click.echo(output.rstrip('\n')) # echo_via_pager has some unicode problems & can remove the colors
开发者ID:hexxter,项目名称:pw,代码行数:51,代码来源:cli.py
示例14: test_echo_vs_copy
def test_echo_vs_copy():
# no copy nor echo
expected = "phones.myphone"
xerox.copy("")
result = invoke_cli("--no-copy", "--no-echo", "myphone")
assert not result.exception and result.exit_code == 0
assert result.output.strip() == expected.strip()
assert xerox.paste() == ""
# only echo
expected = "phones.myphone | 0000"
xerox.copy("")
result = invoke_cli("--no-copy", "--echo", "myphone")
assert not result.exception and result.exit_code == 0
assert result.output.strip() == expected.strip()
assert xerox.paste() == ""
# only echo
expected = "phones.myphone | *** PASSWORD COPIED TO CLIPBOARD ***"
xerox.copy("")
result = invoke_cli("--copy", "--no-echo", "myphone")
assert not result.exception and result.exit_code == 0
assert result.output.strip() == expected.strip()
assert xerox.paste() == "0000"
# both copy and echo
expected = "phones.myphone | 0000 | *** PASSWORD COPIED TO CLIPBOARD ***"
xerox.copy("")
result = invoke_cli("--copy", "--echo", "myphone")
assert not result.exception and result.exit_code == 0
assert result.output.strip() == expected.strip()
assert xerox.paste() == "0000"
开发者ID:hexxter,项目名称:pw,代码行数:32,代码来源:test_cli.py
示例15: main
def main():
try:
plaintext = ""
if len(sys.argv) == 1:
plaintext = raw_input('Enter text -:\n')
else:
plaintext = sys.argv[1]
ciphertext = plaintext.encode('rot13')
print ciphertext
xerox.copy(ciphertext)
print 'Copied to clipboard!!'
except Exception as exception:
print "Error : {exception}".format(exception=exception.message)
开发者ID:dhruvagarwal,项目名称:decrypto,代码行数:15,代码来源:rot13.py
示例16: main
def main():
try:
text = ""
if (len(sys.argv) == 1):
text = raw_input('Enter text -:\n')
else:
text = sys.argv[1]
text_hash = hashlib.md5(text).hexdigest()
print text_hash
xerox.copy(text_hash)
print 'Copied to clipboard!!'
except Exception as exception:
print "Error : {exception}".format(exception=exception.message)
开发者ID:Anmol-Singh-Jaggi,项目名称:Decrypto,代码行数:15,代码来源:md5.py
示例17: postImage
def postImage(service, image):
try:
with open(image) as rfile:
response = json.loads(requests.post(
url=service["post_url"],
files={ "files[]": rfile }
).text)
file_info = response["files"][0]
url = os.path.join(service["view_url"], file_info["url"])
if getOption("notify"):
notify("Uploaded screenshot: {}".format(url))
xerox.copy(url)
print(url)
except Exception as e:
if getOption("notify"):
notify("Error while uploading check, internet connection and service server".format(e))
print(traceback.format_exc(e))
开发者ID:UndeadMastodon,项目名称:putter,代码行数:17,代码来源:Putter.py
示例18: do_ParameterTest
def do_ParameterTest(self,
expect,
klass,
expectKind=None, # None=one prop, Exception=exception, dict=many props
owner='user',
value=None, req=None,
expectJson=None,
**kwargs):
name = kwargs.setdefault('name', 'p1')
# construct one if needed
if isinstance(klass, type):
prop = klass(**kwargs)
else:
prop = klass
self.assertEqual(prop.name, name)
self.assertEqual(prop.label, kwargs.get('label', prop.name))
if expectJson is not None:
gotJson = json.dumps(prop.getSpec())
if gotJson != expectJson:
try:
import xerox
formated = self.formatJsonForTest(gotJson)
print "You may update the test with (copied to clipboard):\n" + formated
xerox.copy(formated)
input()
except ImportError:
print "Note: for quick fix, pip install xerox"
self.assertEqual(gotJson, expectJson)
sched = self.makeScheduler(properties=[prop])
if not req:
req = {name: value, 'reason': 'because'}
try:
bsid, brids = yield sched.force(owner, builderNames=['a'], **req)
except Exception, e:
if expectKind is not Exception:
# an exception is not expected
raise
if not isinstance(e, expect):
# the exception is the wrong kind
raise
defer.returnValue(None) # success
开发者ID:bshawk,项目名称:buildbot,代码行数:46,代码来源:test_schedulers_forcesched.py
示例19: get
def get(ctx, tags):
"""
Get a gif matching the given set of tags and copy its URL to the clipboard.
"""
tags = set(tags)
metadata = get_metadata(
ctx.obj['dropbox'], get_base_path(ctx.obj['config'])
)
matches = [
item for item, item_tags in metadata.items()
if item_tags >= tags
]
if matches:
gif = random.choice(matches)
gif_url = get_gif_url(get_base_url(ctx.obj['config']), gif)
xerox.copy(gif_url)
else:
print("No gif found :(")
开发者ID:sephii,项目名称:macgifer,代码行数:19,代码来源:commands.py
示例20: output_from_argparse
def output_from_argparse(output, parsed_args): # TODO: argparse functions need better name.
parsed_args = parsed_args.copy()
commands = parsed_args.get('to_command')
if commands is None:
commands = []
if parsed_args.get('say'):
commands.append("say")
for c in commands:
hexchat.command(" ".join((c, output)))
if parsed_args.get('guard_inputbox_cmd') and (parsed_args.get('to_inputbox') or parsed_args.get('to_inputbox_replace')):
ibx.set(" ".join((parsed_args['guard_inputbox_cmd'][0], output)))
elif parsed_args.get("to_inputbox"):
ibx.add_at_cursor(output)
elif parsed_args.get("to_inputbox_replace"):
ibx.set(output)
if parsed_args.get("to_clipboard") and HAVE_XEROX:
xerox.copy(output)
开发者ID:divanshujain,项目名称:hexchat-addons,代码行数:20,代码来源:floodcontrol.py
注:本文中的xerox.copy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论