当前位置: 首页>>代码示例>>Python>>正文


Python clipboard.get方法代码示例

本文整理汇总了Python中clipboard.get方法的典型用法代码示例。如果您正苦于以下问题:Python clipboard.get方法的具体用法?Python clipboard.get怎么用?Python clipboard.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clipboard的用法示例。


在下文中一共展示了clipboard.get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pull

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def pull(self):
        repo = self._get_repo()

        remote=self.view['remote'].text
        if remote in self.remotes_iterator():
            uri=repo.remotes.get(remote,'')
        else:
            print remote, 'adding'
            uri=remote
            #Set the origin
            config = repo.repo.get_config()
            config.set(('remote','origin'),'url',uri)
            config.write_to_path()
        repo.pull(origin_uri=uri)
        console.hud_alert('pulled from ',remote) 
        self.refresh() 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:18,代码来源:gitui.py

示例2: save_mode

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def save_mode(type_, self):
    self.press('c', X.ControlMask)
    svg = get(TARGET)
    if not 'svg' in svg:
        return

    directory = data_dirs[type_]
    files = list(directory.iterdir())
    names = [f.stem for f in files]
    _, index, name = rofi(
        'Save as',
        names,
        rofi_theme_params,
        fuzzy=False
    )

    if index != -1:
        # File exists
        _, index, yn = rofi(
            f'Overwrite {name}?',
            ['y', 'n'],
            rofi_theme_params + ['-auto-select'],
            fuzzy=False
        )
        if yn == 'n':
            return

    (directory / f'{name}.svg').write_text(get(TARGET)) 
开发者ID:gillescastel,项目名称:inkscape-shortcut-manager,代码行数:30,代码来源:styles.py

示例3: clipboard_get

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def clipboard_get():
        """
        Get the clipboard content.
        :return: clipboard content
        :rtype: six.text_type
        """
        return clipboard.get() 
开发者ID:ywangd,项目名称:stash,代码行数:9,代码来源:libdist.py

示例4: run

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def run(self):
		clip = clipboard.get()
		self.status = 'complete'
		return ElementValue(type = self.get_output_type(), value = clip) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:6,代码来源:GetClipboardText.py

示例5: paste

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def paste(self):
        import clipboard
        i=editor.get_selection()
        t=editor.get_text()
        editor.replace_text(i[0],i[1], clipboard.get())
        editor.set_selection(i[0],i[1]-len(t)+len(editor.get_text())) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:8,代码来源:editmenu.py

示例6: clone_action

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def clone_action(self,sender):
        import clipboard
        remote='https://github.com/'
        local=''
        if clipboard.get().startswith('http'):
            remote=clipboard.get()
            local=os.path.split(urlparse.urlparse(remote).path)[-1]
            local= local.split('.git')[0]  
        d=UIDialog(root=self.view,title='Clone repo',items={'remote url':remote,'local path':local},ok_action=self.clone) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:11,代码来源:gitui.py

示例7: git_download_from_args

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def git_download_from_args(args):
    if len(args) == 2:
        url = args[1]
    else:
        url = clipboard.get()
    git_download(url) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:8,代码来源:GitHubGet.py

示例8: main

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def main():
    speech.stop()
    if not appex.is_running_extension():
        console.hud_alert('Reading clipboard')
        text = clipboard.get()
        url = None
    else:
        text = appex.get_text()
        url = appex.get_url()

    if url == None:
        try:
            url = [ mgroups[0] for mgroups in GRUBER_URLINTEXT_PAT.findall(text) ][0]
        except:
            pass

    if url != None:
        console.hud_alert('Reading: ' + url)
        h = html2text.HTML2Text()
        try:
            r = requests.get(
            url=url,
            headers={"User-agent": "Mozilla/5.0{0:06}".format(random.randrange(999999))})
        except requests.ConnectionError as e:
            console.alert('Unable to connect to url.')
            return True
        html_content = r.text.decode('utf-8')
        text = html2text.html2text(html_content)
    else:
        console.hud_alert('Reading text: ' + str(text))

    if text:
        speech.say(text)
        stop = console.alert('Done?', hide_cancel_button=True, button1='OK')
        speech.stop()
    else:
        console.hud_alert('No text found.') 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:39,代码来源:speak.py

示例9: main

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def main():
    # get text from app share or clipboard
    if appex.is_running_extension():
        text = appex.get_text()
    else:
        text = clipboard.get()

    # get file save info
    save_dir_name = get_save_dir()
    file_name = 'txt-{:%Y%m%d-%H%M%S}.txt'.format(datetime.datetime.now())
    save_dir = os.path.join(BASE_DIR, save_dir_name)
    file_path = os.path.join(save_dir, file_name)

    # check dirs and save
    if not os.path.exists(save_dir ):
        os.makedirs(save_dir)
    with open(file_path, 'w') as f:
        f.write(text)
        f.close()

    # wrapup
    console.hud_alert('Saved to: ' + os.path.join(save_dir_name, file_name))
    if appex.is_running_extension():
        appex.finish()

########################################### 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:28,代码来源:save-text.py

示例10: main

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def main():
    text = None
    label = 'Shared text'
    if appex.is_running_extension():
        text = appex.get_text()
    if not text:
        try:
            import editor
            editor_file = editor.get_path()
            if editor_file:
                sel = console.alert('Editor or clipboard?', button1='Editor', button2='Clipboard')
                if sel == 1:
                    editor_text = editor.get_text()
                    sel_st, sel_end = editor.get_selection()
                    label = os.path.basename(editor_file)
                    if sel_end != sel_st:
                        text = editor_text[sel_st:sel_end]
                    elif editor_text:
                        text = editor_text
        except ImportError:
            pass
    if not text:
        label = 'Clipboard'
        text = clipboard.get().strip()
    if text:
        converted = markdown(text)
        html = TEMPLATE.replace('{{CONTENT}}', converted)

        clip = console.alert('Replace clipboard?', button1='Yes', button2='No', hide_cancel_button=True)
        if clip ==1:
            clipboard.set(html)
            console.hud_alert('HTML copied to clipboard.')
        wv = MyWebView(name='Markdown - %s' % label)
        wv.load_html(html)
        wv.present('full_screen')
    else:
        console.hud_alert('No text found.')
        appex.finish() 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:40,代码来源:md2html.py

示例11: main

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def main():
    console.hud_alert('Saving clipboard to Evernote.')
    text = clipboard.get().strip()
    _eurl = "evernote://x-callback-url/new-note?type=clipboard&title=DRAFT&text="
    app=UIApplication.sharedApplication()
    eurl=nsurl(_eurl)
    app.openURL_(eurl) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:9,代码来源:clipboard-to-evernote.py

示例12: dropbox_setup

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def dropbox_setup(username, stdin, stdout):
    """helper-interface to setup dropbox."""
    _stash = core.get_stash()
    Text = _stash.text_color  # alias
    stdout.write(Text("=" * 40 + "\nDropbox-setup\n" + "=" * 25 + "\n", "blue"))
    header = "This interface will help you setup the dropbox access"
    header += " for '{n}'.".format(n=Text(username, "blue"))
    abort = Text("abort", "yellow")
    choices = ("I already have an authorization-code", "I dont have an authorizaion-code", abort)
    choice = _menu(header, choices, stdin, stdout)
    if choice == 2:
        raise KeyboardInterrupt("Setup aborted.")
    elif choice == 0:
        pass
    elif choice == 1:
        stdout.write("Please read this. After reading, press enter to continue.\n")
        text1 = "To allow StaSh access to your dropbox, "
        text2 = "you will have to perform the following steps:\n"
        stdout.write(text1 + text2)
        stdout.write("  1) Create a dropbox account (if you dont have one yet)\n")
        stdout.write("  2) Upgrade your Account to a dropbox-developer account.\n")
        stdout.write("  3) Create a dropbox-app.\n")
        stdout.write("  4) Generate an access token.\n")
        stdout.write("  5) Enter the access token.\n")
        stdout.write(Text("Continue?", "yellow"))
        stdin.readline()
        while True:
            header = "Select action"
            choices = ("Register to dropbox", "Go to the developer-page", "proceed", abort)
            choice = _menu(header, choices, stdin, stdout)
            if choice == 0:
                _open_url("https://www.dropbox.com/register")
            elif choice == 1:
                _open_url("https://developer.dropbox.com")
            elif choice == 2:
                break
            elif choice == 3:
                raise KeyboardInterrupt("Setup aborted.")
    stdout.write("Enter the access token (leave empty to use clipboard):\n>")
    access_token = stdin.readline().strip()
    if len(access_token) == 0:
        access_token = clipboard.get()
        stdout.write("Using clipboard (length={l}).\n".format(l=len(access_token)))
    stdout.write("Testing token... ")
    try:
        db = dropbox.Dropbox(access_token)
        db.files_list_folder("")
    except (dropbox.exceptions.ApiError, dropbox.exceptions.BadInputError):
        sys.stdout.write(Text("Error", "red"))
        sys.stdout.write(".\nAuthorization failed! Please try again.\n")
        raise KeyboardInterrupt("Setup failed!")
    stdout.write(Text("Done", "green"))
    stdout.write(".\nSaving... ")
    save_dropbox_data(username, access_token)
    stdout.write(Text("Done", "green"))
    stdout.write(".\n")
    return True 
开发者ID:ywangd,项目名称:stash,代码行数:59,代码来源:dbutils.py

示例13: push_action

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def push_action(self,sender):
       # pdb.set_trace()
        user, sep, pw =  (None,None,None)
        repo = self._get_repo()
        
        remote=self.view['remote'].text
        if remote in self.remotes_iterator():
            remote = repo.remotes.get(remote,'')

        branch_name = os.path.join('refs','heads', repo.active_branch)  #'refs/heads/%s' % repo.active_branch
        # tODO  use remote branch_name 


        netloc = urlparse.urlparse(remote).netloc

        keychainservice = 'shellista.git.{0}'.format(netloc)

        #define some callbacks for use by uidialog
        def push_callback(user,pw):
            print  "Attempting to push to: {0}, branch: {1}".format(remote, branch_name)
            console.show_activity()
            if user:
               try:
                  parsedurl=urlparse.urlparse(remote)
                  host_with_auth='{}:{}@{}'.format( 
                                  user,pw,parsedurl.netloc)
                  url=urlparse.urlunparse(
                      parsedurl._replace( netloc=host_with_auth))
                  porcelain.push(repo.path, url, branch_name)
                  keychain.set_password(keychainservice, user, pw)
               except urllib2.URLError:
                  console.hide_activity()
                  console.hud_alert('push failed','error')
                  return
            else:
                porcelain.push(repo.repo, result.url, branch_name)
            console.hide_activity()
            console.hud_alert('push complete')
        def push_callback_dict(d):
            push_callback(d['username'],d['password'])
            
        #Attempt to retrieve user
        try:
            user = dict(keychain.get_services())[keychainservice]
            pw = keychain.get_password(keychainservice, user)
            if pw:
                push_callback(user,pw)
            else:
                raise KeyError
        except KeyError:
            self.get_pass(netloc,push_callback_dict) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:53,代码来源:gitui.py

示例14: main

# 需要导入模块: import clipboard [as 别名]
# 或者: from clipboard import get [as 别名]
def main():
    
    # get text from app share or clipboard
    text = appex.get_url() if appex.is_running_extension() else clipboard.get().strip()

    # get url
    url = ''
    try:
        url = [ mgroups[0] for mgroups in GRUBER_URLINTEXT_PAT.findall(text) ][0]
    except:
        url = console.input_alert("URL", "", url)
    if url:
        if not url.startswith('http'):
            url = 'http://' + url
    else:
        console.hud_alert('No URL found.')
        sys.exit()

    sel = console.alert('Save: %s ?' % url, button1='File', button2='Clipboard')

    # get url info
    url_items = url.split("?")[0].split("/")
    # if url ends with /, last item is an empty string
    file_name = url_items[-1] if url_items[-1] else url_items[-2]
    
    try:
        content = urllib2.urlopen(url).read()
    except urllib2.URLError as e:
        console.alert('Unable to read url.')
        sys.exit(1)

    if sel == 1:
        # get file save info
        save_dir_name = get_save_dir()
        save_dir = os.path.join(BASE_DIR, save_dir_name)
        file_path = os.path.join(save_dir, file_name)
        try:
            # check dirs and save
            if not os.path.exists(save_dir):
                os.makedirs(save_dir)
            with open(file_path, 'w') as f:
                f.write(content)
            # wrapup
            msg = 'Saved to: %s' % file_path
        except Exception as e:
            msg = str(e)
        console.alert(msg, button1='OK', hide_cancel_button=True)
    elif sel == 2:
        clipboard.set(content)


    if appex.is_running_extension():
        appex.finish()

########################################### 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:57,代码来源:save-url.py


注:本文中的clipboard.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。