python类paste()的实例源码

puppet_v4.py 文件源码 项目:puppet 作者: Raytone-D 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def copy_data(self, hCtrl, key=0):    # background mode
        "?CVirtualGridCtrl|Custom<n>??????????????????"
        if key:
            self.switch_tab(self.two_way, key)    # ?????('W')???('E')???('R')

        start = time.time()
        print("??????????????...")
        # ?????????????3?...orz
        for i in range(10):
            time.sleep(0.3)
            op.SendMessageW(hCtrl, MSG['WM_COMMAND'], MSG['COPY_DATA'], NODE['FORM'][-1])
            ret = pyperclip.paste().splitlines()
            if len(ret) > 1:
                break

        temp = (x.split('\t') for x in ret)
        header = next(temp)
        if '????' in header:
            header.insert(header.index('????'), '??')
            header.remove('????')
        print('IT TAKE {} SECONDS TO GET REAL-TIME DATA'.format(time.time() - start))
        return tuple(dict(zip(header, x)) for x in temp)
twitter.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def twitter_tweet(self):
    print("1. write tweet")
    print("2. copy from clipboard")

    if six.PY2:
        choice = raw_input('Enter choice:')
    else:
        choice = input('Enter choice:')

    if int(choice) == 1:
        if six.PY2:
            tweet = raw_input('Enter tweet here:')
        else:
            tweet = input('Enter tweet here:')
    else:
        tweet = pyperclip.paste()

    driver = twitter_login(self)
    post_box = driver.find_element_by_id('tweet-box-home-timeline')
    post_box.send_keys(tweet)
    submit = driver.find_element_by_css_selector(
        'button.tweet-action.EdgeButton.EdgeButton--primary.js-tweet-btn')
    submit.click()
    print("Posted")

    return driver
cmd2.py 文件源码 项目:cmd2 作者: python-cmd2 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_paste_buffer():
    """Get the contents of the clipboard / paste buffer.

    :return: str - contents of the clipboard
    """
    pb_str = pyperclip.paste()

    # If value returned from the clipboard is unicode and this is Python 2, convert to a "normal" Python 2 string first
    if six.PY2 and not isinstance(pb_str, str):
        import unicodedata
        pb_str = unicodedata.normalize('NFKD', pb_str).encode('ascii', 'ignore')

    return pb_str
cmd2.py 文件源码 项目:cmd2 作者: python-cmd2 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def write_to_paste_buffer(txt):
    """Copy text to the clipboard / paste buffer.

    :param txt: str - text to copy to the clipboard
    """
    pyperclip.copy(txt)
cmd2.py 文件源码 项目:cmd2 作者: python-cmd2 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def replace_with_file_contents(fname):
    """Action to perform when successfully matching parse element definition for inputFrom parser.

    :param fname: str - filename
    :return: str - contents of file "fname"
    """
    try:
        with open(os.path.expanduser(fname[0])) as source_file:
            result = source_file.read()
    except IOError:
        result = '< %s' % fname[0]  # wasn't a file after all

    # TODO: IF pyparsing input parser logic gets fixed to support empty file, add support to get from paste buffer
    return result
cloudcb.py 文件源码 项目:cloud-clipboard 作者: krsoninikhil 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def copy():
    """
    Returns the current text on clipboard.
    """
    data = pyperclip.paste()
    ## before using pyperclip
    # if os.name == "posix":
    #     p = subprocess.Popen(["xsel", "-bo"], stdout=subprocess.PIPE)
    #     data = p.communicate()[0].decode("utf-8")
    # elif os.name == "nt":
    #     data = None
    # else:
    #     print("We don't yet support %s Operating System." % os.name)
    #     exit()
    return data
cloudcb.py 文件源码 项目:cloud-clipboard 作者: krsoninikhil 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def upload(username, password):
    """
    Sends the copied text to server.
    """
    payload = {"text": copy(), "device": ""}
    res = requests.post(
        server_url+"copy-paste/",
        data = payload,
        auth = (username, password)
    )
    if res.status_code == 200:
        print("Succeses! Copied to Cloud-Clipboard.")
    else:
        print("Error: ", res.text)
cloudcb.py 文件源码 项目:cloud-clipboard 作者: krsoninikhil 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def paste(data):
    """
    Copies 'data' to local clipboard which enables pasting.
    """
    # p = subprocess.Popen(["xsel", "-bi"], stdout=subprocess.PIPE,
    #                      stdin=subprocess.PIPE)
    # p = p.communicate(data.encode("utf-8"))
    # if p[1] is not None:
    #     print("Error in accessing local clipboard")
    pyperclip.copy(data)
cloudcb.py 文件源码 项目:cloud-clipboard 作者: krsoninikhil 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def download(username, password):
    """
    Downloads from server and updates the local clipboard.
    """
    res = requests.get(server_url+"copy-paste/", auth=(username, password))
    if res.status_code == 200:
        paste(json.loads(res.text)["text"])
    else:
        print("Cannot download the data.")
cloudcb.py 文件源码 项目:cloud-clipboard 作者: krsoninikhil 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def usage():
    print("Error: Unknown argument")
    print("Usage: cloudcb.py copy|paste|register <email> <password>")
pyperclip.py 文件源码 项目:Liljimbo-Chatbot 作者: chrisjim316 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_data(self):
        text = pyperclip.paste()

        # When the clipboard data is equal to what we copied last time, reuse
        # the `ClipboardData` instance. That way we're sure to keep the same
        # `SelectionType`.
        if self._data and self._data.text == text:
            return self._data

        # Pyperclip returned something else. Create a new `ClipboardData`
        # instance.
        else:
            return ClipboardData(
                text=text,
                type=SelectionType.LINES if '\n' in text else SelectionType.LINES)
pyperclip.py 文件源码 项目:leetcode 作者: thomasyimgit 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_data(self):
        text = pyperclip.paste()

        # When the clipboard data is equal to what we copied last time, reuse
        # the `ClipboardData` instance. That way we're sure to keep the same
        # `SelectionType`.
        if self._data and self._data.text == text:
            return self._data

        # Pyperclip returned something else. Create a new `ClipboardData`
        # instance.
        else:
            return ClipboardData(
                text=text,
                type=SelectionType.LINES if '\n' in text else SelectionType.LINES)
push_list_gen.py 文件源码 项目:MumiGiveP 作者: wabilin 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def push_list_from_clipboard():
    push_type_dict = {
        u"?": 1,
        u"?": 2,
        u"\u2192": 3
    }

    def construct_push(line):
        words = line.split(' ')
        if len(words) < 2:
            return None

        push = re.sub('\\s', '', words[0])
        if push not in push_type_dict:
            return None
        push = push_type_dict[push]

        u_id = re.sub('\\s', '', words[1])
        if u_id[-1] != ':':
            return None
        u_id = re.sub(':', '', u_id).encode('ascii')

        return {'push': push, 'id': u_id}

    content = pyperclip.paste()
    lines = re.split('\r\n|\r|\n', content)

    return [x for x in map(construct_push, lines) if x]
__init__.py 文件源码 项目:QGIS-CKAN-Browser 作者: BergWerkGIS 项目源码 文件源码 阅读 24 收藏 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 项目源码 文件源码 阅读 22 收藏 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()
sixense.py 文件源码 项目:sixense 作者: a0726h77 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def main():
    global recent_value

    while True:
        tmp_value = pyperclip.paste()
        if tmp_value != recent_value:
            recent_value = tmp_value
            myDetect(recent_value)
        time.sleep(0.1)
pyperclip.py 文件源码 项目:rice 作者: randy3k 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_data(self):
        text = pyperclip.paste()

        # When the clipboard data is equal to what we copied last time, reuse
        # the `ClipboardData` instance. That way we're sure to keep the same
        # `SelectionType`.
        if self._data and self._data.text == text:
            return self._data

        # Pyperclip returned something else. Create a new `ClipboardData`
        # instance.
        else:
            return ClipboardData(
                text=text,
                type=SelectionType.LINES if '\n' in text else SelectionType.LINES)
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 项目源码 文件源码 阅读 22 收藏 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("")
pyperclip.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_data(self):
        text = pyperclip.paste()

        # When the clipboard data is equal to what we copied last time, reuse
        # the `ClipboardData` instance. That way we're sure to keep the same
        # `SelectionType`.
        if self._data and self._data.text == text:
            return self._data

        # Pyperclip returned something else. Create a new `ClipboardData`
        # instance.
        else:
            return ClipboardData(
                text=text,
                type=SelectionType.LINES if '\n' in text else SelectionType.LINES)
main.py 文件源码 项目:Lookup-Dictionary 作者: GDGVIT 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        text = pyperclip.paste()
        self.setupUi(self, text,error)
ytbdwn.py 文件源码 项目:YtbDwn 作者: praneet95 项目源码 文件源码 阅读 23 收藏 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 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def process(self):
        while self.active:
            tmp_val = pyperclip.paste()
            if tmp_val != self.last_clipboard:
                self.last_clipboard = tmp_val
                self.copied.emit(tmp_val)
                # self.window.handleClipboard(tmp_val)
            time.sleep(0.1)
texteditor.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def Pastetext(self):
        self.contents.insert(INSERT, pyperclip.paste())
__init__.py 文件源码 项目:ci_edit 作者: google 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def determine_clipboard():
    # Determine the OS/platform and set
    # the copy() and paste() functions accordingly.
    if 'cygwin' in platform.system().lower():
        # FIXME: pyperclip currently does not support Cygwin,
        # see https://github.com/asweigart/pyperclip/issues/55
        pass
    elif 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 文件源码 项目:ci_edit 作者: google 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def set_clipboard(clipboard):
    global copy, paste

    clipboard_types = {'osx': init_osx_clipboard,
                       'gtk': init_gtk_clipboard,
                       'qt': init_qt_clipboard,
                       'xclip': init_xclip_clipboard,
                       'xsel': init_xsel_clipboard,
                       'klipper': init_klipper_clipboard,
                       'windows': init_windows_clipboard,
                       'no': init_no_clipboard}

    copy, paste = clipboard_types[clipboard]()
myclipboard.py 文件源码 项目:safetalk 作者: zjuchenyuan 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def clipboard_read():
    return paste()
pyperclip.py 文件源码 项目:safetalk 作者: zjuchenyuan 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def determine_clipboard():
    # Determine the OS/platform and set
    # the copy() and paste() functions accordingly.
    if 'cygwin' in platform.system().lower():
        # FIXME: pyperclip currently does not support Cygwin,
        # see https://github.com/asweigart/pyperclip/issues/55
        pass
    elif 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()
pyperclip.py 文件源码 项目:safetalk 作者: zjuchenyuan 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def set_clipboard(clipboard):
    global copy, paste

    clipboard_types = {'osx': init_osx_clipboard,
                       'gtk': init_gtk_clipboard,
                       'qt': init_qt_clipboard,
                       'xclip': init_xclip_clipboard,
                       'xsel': init_xsel_clipboard,
                       'klipper': init_klipper_clipboard,
                       'windows': init_windows_clipboard,
                       'no': init_no_clipboard}

    copy, paste = clipboard_types[clipboard]()
yh_clienttrader.py 文件源码 项目:easytrader 作者: yuzhucu 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _read_clipboard(self):
        for _ in range(15):
            try:
                win32api.keybd_event(17, 0, 0, 0)
                win32api.keybd_event(67, 0, 0, 0)
                win32api.keybd_event(67, 0, win32con.KEYEVENTF_KEYUP, 0)
                win32api.keybd_event(17, 0, win32con.KEYEVENTF_KEYUP, 0)
                time.sleep(0.2)
                return pyperclip.paste()
            except Exception as e:
                log.error('open clipboard failed: {}, retry...'.format(e))
                time.sleep(1)
        else:
            raise Exception('read clipbord failed')


问题


面经


文章

微信
公众号

扫码关注公众号