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

Function init_wsl_clipboard

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

Source from the content-addressed store, hash-verified

503
504
505def init_wsl_clipboard():
506 def copy_wsl(text):
507 text = _stringifyText(text) # Converts non-str values to str.
508 with subprocess.Popen(["clip.exe"], stdin=subprocess.PIPE, close_fds=True) as p:
509 p.communicate(input=text.encode(ENCODING))
510
511 def paste_wsl():
512 with subprocess.Popen(
513 ["powershell.exe", "-command", "Get-Clipboard"],
514 stdout=subprocess.PIPE,
515 stderr=subprocess.PIPE,
516 close_fds=True,
517 ) as p:
518 stdout = p.communicate()[0]
519 # WSL appends "\r\n" to the contents.
520 return stdout[:-2].decode(ENCODING)
521
522 return copy_wsl, paste_wsl
523
524
525# Automatic detection of clipboard mechanisms

Callers 1

determine_clipboardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected