python类copy()的实例源码

md_img.py 文件源码 项目:mdimg 作者: zhiyue 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def update_history_menu(self):
        self.historyMenu.clear()
        last = None
        for url in self.history['urls']:
            title = self.history['titles'][url]
            action = QtGui.QAction(title, self, triggered=partial(pyperclip.copy, url))
            self.historyMenu.insertAction(last, action)
            last = action
md_img.py 文件源码 项目:mdimg 作者: zhiyue 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def upload(self, name):
        key = os.path.basename(name)
        q = qiniu.Auth(self.access_key, self.secret_key)
        with open(name, 'rb') as img:
            data = img
            token = q.upload_token(self.bucket)
            ret, info = qiniu.put_data(token, key, data)
            if self.parseRet(ret, info):
                md_url = "![]({}/{})".format(self.domain, key)
                print(md_url)
                title = name
                pyperclip.copy(md_url)
                self.append_history(title, md_url)
__main__.py 文件源码 项目:passpy 作者: bfrascher 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def show(ctx, pass_name, clip, passthrough=False):
    """Decrypt and print a password named `pass-name`.  If `--clip` or
    `-c` is specified, do not print the password but instead copy the
    first line to the clipboard using pyperclip.  On Linux you will
    need to have xclip/xsel and on OSX pbcopy/pbpaste installed.

    """
    try:
        data = ctx.obj.get_key(pass_name)
    # If pass_name is actually a folder in the password store pass
    # lists the folder instead.
    except FileNotFoundError:
        if not passthrough:
            return ctx.invoke(ls, subfolder=pass_name, passthrough=True)
        else:
            click.echo(MSG_FILE_NOT_FOUND.format(pass_name))
            return 1
    except StoreNotInitialisedError:
        click.echo(MSG_STORE_NOT_INITIALISED_ERROR)
        return 1
    except PermissionError:
        click.echo(MSG_PERMISSION_ERROR)
        return 1

    if clip:
        pyperclip.copy(data.split('\n')[0])
        click.echo('Copied {0} to the clipboard.'.format(pass_name))
    else:
        # The key data always ends with a newline.  So no need to add
        # another one.
        click.echo(data, nl=False)
__main__.py 文件源码 项目:passpy 作者: bfrascher 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def generate(ctx, pass_name, pass_length, no_symbols, clip, in_place, force):
    """Generate a new password of length `pass-length` and insert into
    `pass-name`.  If `--no-symbols` or `-n` is specified, do not use
    any non-alphanumeric characters in the generated password.  If
    `--clip` or `-c` is specified, do not print the password but
    instead copy it to the clipboard.  On Linux you will need to have
    xclip/xsel and on OSX pbcopy/pbpaste installed.  Prompt before
    overwriting an existing password, unless `--force` or `-f` is
    specified.  If `--in-place` or `-i` is specified, do not
    interactively prompt, and only replace the first line of the
    password file with the new generated password, keeping the
    remainder of the file intact.

    """
    symbols = not no_symbols
    try:
        password = ctx.obj.gen_key(pass_name, pass_length, symbols,
                                   force, in_place)
    except StoreNotInitialisedError:
        click.echo(MSG_STORE_NOT_INITIALISED_ERROR)
        return 1
    except PermissionError:
        click.echo(MSG_PERMISSION_ERROR)
        return 1
    except FileNotFoundError:
        click.echo(MSG_FILE_NOT_FOUND.format(pass_name))
        return 1

    if password is None:
        return 1

    if clip:
        pyperclip.copy(password)
        click.echo('Copied {0} to the clipboard.'.format(pass_name))
    else:
        click.echo('The generated password for {0} is:'.format(pass_name))
        click.echo(password)
__init__.py 文件源码 项目:QGIS-CKAN-Browser 作者: BergWerkGIS 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def determine_clipboard():
    # Determine the OS/platform and set the copy() and paste() functions accordingly.
    if 'cygwin' in platform.system().lower():
        return init_windows_clipboard(cygwin=True)
    if os.name == 'nt' or platform.system() == 'Windows':
        return init_windows_clipboard()
    if os.name == 'mac' or platform.system() == 'Darwin':
        return init_osx_clipboard()
    if HAS_DISPLAY:
        # Determine which command/module is installed, if any.
        try:
            import gtk  # check if gtk is installed
        except ImportError:
            pass
        else:
            return init_gtk_clipboard()

        try:
            import PyQt4  # check if PyQt4 is installed
        except ImportError:
            pass
        else:
            return init_qt_clipboard()

        if _executable_exists("xclip"):
            return init_xclip_clipboard()
        if _executable_exists("xsel"):
            return init_xsel_clipboard()
        if _executable_exists("klipper") and _executable_exists("qdbus"):
            return init_klipper_clipboard()

    return init_no_clipboard()
__init__.py 文件源码 项目:QGIS-CKAN-Browser 作者: BergWerkGIS 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def set_clipboard(clipboard):
    global copy, paste

    if clipboard == 'osx':
        from .clipboards import init_osx_clipboard
        copy, paste = init_osx_clipboard()
    elif clipboard == 'gtk':
        from .clipboards import init_gtk_clipboard
        copy, paste = init_gtk_clipboard()
    elif clipboard == 'qt':
        from .clipboards import init_qt_clipboard
        copy, paste = init_qt_clipboard()
    elif clipboard == 'xclip':
        from .clipboards import init_xclip_clipboard
        copy, paste = init_xclip_clipboard()
    elif clipboard == 'xsel':
        from .clipboards import init_xsel_clipboard
        copy, paste = init_xsel_clipboard()
    elif clipboard == 'klipper':
        from .clipboards import init_klipper_clipboard
        copy, paste = init_klipper_clipboard()
    elif clipboard == 'no':
        from .clipboards import init_no_clipboard
        copy, paste = init_no_clipboard()
    elif clipboard == 'windows':
        from .windows import init_windows_clipboard
        copy, paste = init_windows_clipboard()
ckan_browser_dialog.py 文件源码 项目:QGIS-CKAN-Browser 作者: BergWerkGIS 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def copy_clipboard(self):
        pyperclip.copy(self.IDC_plainTextLink.toPlainText())
pyperclip.py 文件源码 项目:rice 作者: randy3k 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def set_data(self, data):
        assert isinstance(data, ClipboardData)
        self._data = data
        pyperclip.copy(data.text)
__init__.py 文件源码 项目:visionary 作者: spaceshuttl 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def copy_to_clipboard(generated):
    global copied
    selection = safe_input('Which password would you like to copy? [1/2/3] ').strip()
    if selection in ['1', '2', '3']:
        password = generated[int(selection) - 1]
    else:
        print(color('Invalid option. Pick either 1, 2 or 3.\n', Fore.RED))
        return copy_to_clipboard(generated)
    try:
        pyperclip.copy(password)
        copied = True
        print('\nCopied!\n')
    except pyperclip.exceptions.PyperclipException:
        print(color('Could not copy! If you\'re using linux, make sure xclip is installed.\n', Fore.RED))
__init__.py 文件源码 项目:visionary 作者: spaceshuttl 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def exit(msg=''):
    if copied:
        pyperclip.copy('')
    if msg:
        print(color('\n%s' % msg, Fore.RED))
    print(color('\nExiting securely... You are advised to close this terminal.', Fore.RED))
    raise SystemExit
xarvis.py 文件源码 项目:xarvis 作者: satwikkansal 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def copy_to_clipboard(text):
    current = pyperclip.paste()
    if (not clipboard) or (clipboard and clipboard[-1]!=current):
        clipboard.append(current)
    pyperclip.copy(text)
    clipboard.append(text)
functions.py 文件源码 项目:passman 作者: regexpressyourself 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def clearclip(text=""):
    '''
    Clear the clipboard if nothing has been copied since data 
    was added to it
    '''
    if text == "":
        pyperclip.copy("")
    elif pyperclip.paste() == text:
        pyperclip.copy("")
_pyd3netviz.py 文件源码 项目:pyd3netviz 作者: gte620v 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def to_clipboard(self):
        """ send viz to clipboard """
        pyperclip.copy(self.html)
pyperclip.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def set_data(self, data):
        assert isinstance(data, ClipboardData)
        self._data = data
        pyperclip.copy(data.text)
basic_addons.py 文件源码 项目:chrome_remote_interface_python 作者: wasiher 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def Input__paste(tabs, tab, data):
            try:
                backup = pyperclip.determine_clipboard()[1]() # Not sure if is correct D:
            except:
                backup = None
            pyperclip.copy(data)
            await tab.Input.press_key(tabs.helpers.keyboard.PASTE)
            if backup is not None:
                pyperclip.copy(backup)
main.py 文件源码 项目:img2url 作者: huntzhan 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def entry_point():
    args = docopt(DOC, version=VERSION)

    path = args['<path>']
    doc_type = get_doc_type(args)

    fields = load_config(locate_config())

    # load operator.
    remote = fields.get(CONFIG_REMOTE, 'github')
    if remote not in REGISTERED_REMOTES:
        raise RuntimeError(
            'FATAL: {0} is not a valid remote type.'.format(remote),
        )
    RemoteConfig, RemoteOperation = REGISTERED_REMOTES[remote]

    ret_fname, resource_url = upload_file(
        path, fields, RemoteConfig, RemoteOperation,
    )

    url = translate_url(
        ret_fname,
        resource_url,
        doc_type,
    )

    if not args['--no-clipboard']:
        pyperclip.copy(url)

    print(url)
ytbdwn.py 文件源码 项目:YtbDwn 作者: praneet95 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def Copy_exit(button,choice):       ####called when user selects copy to clipboard
        pyperclip.copy(str(choice.url))
        spam = pyperclip.paste()
        sys.exit()
app.py 文件源码 项目:FitScan 作者: GunfighterJ 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, MainWindow, parent=None):
        super(ClipThread, self).__init__(parent)
        self.window = MainWindow
        pyperclip.copy('')
        self.last_clipboard = ''
        self.active = True
app.py 文件源码 项目:FitScan 作者: GunfighterJ 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def copyFitting(self):
        self.stopClipboard()
        fit = []
        ship = self.shipName if self.shipName else 'Metal Scraps'
        fit.append("[{}, New Fit]".format(ship))
        for key in self.mapped_items:
            for item in self.mapped_items[key]["items"]:
                fit.append(item)
            fit.append('')

        pyperclip.copy('')
        pyperclip.copy("\n".join(fit))
texteditor.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def copytext(self):
        self.Copiedtext = pyperclip.copy(self.contents.get(1.0, END))


问题


面经


文章

微信
公众号

扫码关注公众号