MCPcopy
hub / github.com/pandas-dev/pandas / init_klipper_clipboard

Function init_klipper_clipboard

pandas/io/clipboard/__init__.py:249–284  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

247
248
249def init_klipper_clipboard():
250 def copy_klipper(text):
251 text = _stringifyText(text) # Converts non-str values to str.
252 with subprocess.Popen(
253 [
254 "qdbus",
255 "org.kde.klipper",
256 "/klipper",
257 "setClipboardContents",
258 text.encode(ENCODING),
259 ],
260 stdin=subprocess.PIPE,
261 close_fds=True,
262 ) as p:
263 p.communicate(input=None)
264
265 def paste_klipper():
266 with subprocess.Popen(
267 ["qdbus", "org.kde.klipper", "/klipper", "getClipboardContents"],
268 stdout=subprocess.PIPE,
269 close_fds=True,
270 ) as p:
271 stdout = p.communicate()[0]
272
273 # Workaround for https://bugs.kde.org/show_bug.cgi?id=342874
274 # TODO: https://github.com/asweigart/pyperclip/issues/43
275 clipboardContents = stdout.decode(ENCODING)
276 # even if blank, Klipper will append a newline at the end
277 assert len(clipboardContents) > 0
278 # make sure that newline is there
279 assert clipboardContents.endswith("\n")
280 if clipboardContents.endswith("\n"):
281 clipboardContents = clipboardContents[:-1]
282 return clipboardContents
283
284 return copy_klipper, paste_klipper
285
286
287def init_dev_clipboard_clipboard():

Callers 1

determine_clipboardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected