From 7a368ebbb8cc3769cab96737bd0e49c9a31b70a1 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 26 Mar 2023 23:45:53 +0200 Subject: [PATCH] [#240] Migrated `clipboard` plugin from `pyperclip` to `pyclip`. Closes: #240 --- CHANGELOG.md | 9 +++++++++ docs/source/conf.py | 2 +- platypush/plugins/clipboard/__init__.py | 15 ++++++++------- platypush/plugins/clipboard/manifest.yaml | 2 +- setup.py | 4 ++-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19a982e4aa..ccb10e6d69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. Given the high speed of development in the first phase, changes are being reported only starting from v0.20.2. +## [Unreleased] + +### Fixed + +- Migrated the `clipboard` integration from `pyperclip` to `pyclip` (see + [#240](https://git.platypush.tech/platypush/platypush/issues/240)). + `pyperclip` is unmaintained and largely broken, and `pyclip` seems to be a + viable drop-in alternative. + ## [0.24.5] - 2023-02-22 ### Added diff --git a/docs/source/conf.py b/docs/source/conf.py index d27aa7cba5..60c0362bcd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -216,7 +216,7 @@ autodoc_mock_imports = [ 'bluetooth', 'gevent.wsgi', 'Adafruit_IO', - 'pyperclip', + 'pyclip', 'pydbus', 'inputs', 'inotify', diff --git a/platypush/plugins/clipboard/__init__.py b/platypush/plugins/clipboard/__init__.py index c1364b05fd..c9cef49d5b 100644 --- a/platypush/plugins/clipboard/__init__.py +++ b/platypush/plugins/clipboard/__init__.py @@ -12,7 +12,8 @@ class ClipboardPlugin(RunnablePlugin): monitor and get the current clipboard content. Requires: - - **pyperclip** (``pip install pyperclip``) + + - **pyclip** (``pip install pyclip``) Triggers: @@ -32,27 +33,27 @@ class ClipboardPlugin(RunnablePlugin): :param text: Text to copy :type text: str """ - import pyperclip + import pyclip - pyperclip.copy(text) + pyclip.copy(text) @action def paste(self): """ Get the current content of the clipboard """ - import pyperclip + import pyclip - return pyperclip.paste() + return pyclip.paste(text=True) def main(self): - import pyperclip + import pyclip last_error_time = 0 while not self.should_stop(): try: - text = pyperclip.paste() + text = pyclip.paste(text=True) if text and text != self._last_text: get_bus().post(ClipboardEvent(text=text)) self._last_text = text diff --git a/platypush/plugins/clipboard/manifest.yaml b/platypush/plugins/clipboard/manifest.yaml index 3f81330e52..c63da55bde 100644 --- a/platypush/plugins/clipboard/manifest.yaml +++ b/platypush/plugins/clipboard/manifest.yaml @@ -3,6 +3,6 @@ manifest: platypush.message.event.clipboard.ClipboardEvent: on clipboard update. install: pip: - - pyperclip + - pyclip package: platypush.plugins.clipboard type: plugin diff --git a/setup.py b/setup.py index fb44a3d0e3..bd31e73abe 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ def readfile(fname): def pkg_files(dir): paths = [] # noinspection PyShadowingNames - for (path, _, files) in os.walk(dir): + for path, _, files in os.walk(dir): for file in files: paths.append(os.path.join('..', path, file)) return paths @@ -238,7 +238,7 @@ setup( # Support for SSH integration 'ssh': ['paramiko'], # Support for clipboard integration - 'clipboard': ['pyperclip'], + 'clipboard': ['pyclip'], # Support for luma.oled display drivers 'luma-oled': ['luma.oled @ git+https://github.com/rm-hull/luma.oled'], # Support for DBus integration