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

Function init_xclip_clipboard

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

Source from the content-addressed store, hash-verified

163
164
165def init_xclip_clipboard():
166 DEFAULT_SELECTION = "c"
167 PRIMARY_SELECTION = "p"
168
169 def copy_xclip(text, primary=False):
170 text = _stringifyText(text) # Converts non-str values to str.
171 selection = DEFAULT_SELECTION
172 if primary:
173 selection = PRIMARY_SELECTION
174 with subprocess.Popen(
175 ["xclip", "-selection", selection], stdin=subprocess.PIPE, close_fds=True
176 ) as p:
177 p.communicate(input=text.encode(ENCODING))
178
179 def paste_xclip(primary=False):
180 selection = DEFAULT_SELECTION
181 if primary:
182 selection = PRIMARY_SELECTION
183 with subprocess.Popen(
184 ["xclip", "-selection", selection, "-o"],
185 stdout=subprocess.PIPE,
186 stderr=subprocess.PIPE,
187 close_fds=True,
188 ) as p:
189 stdout = p.communicate()[0]
190 # Intentionally ignore extraneous output on stderr when clipboard is empty
191 return stdout.decode(ENCODING)
192
193 return copy_xclip, paste_xclip
194
195
196def init_xsel_clipboard():

Callers 1

determine_clipboardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected