()
| 285 | |
| 286 | |
| 287 | def init_dev_clipboard_clipboard(): |
| 288 | def copy_dev_clipboard(text): |
| 289 | text = _stringifyText(text) # Converts non-str values to str. |
| 290 | if text == "": |
| 291 | warnings.warn( |
| 292 | "Pyperclip cannot copy a blank string to the clipboard on Cygwin. " |
| 293 | "This is effectively a no-op.", |
| 294 | stacklevel=find_stack_level(), |
| 295 | ) |
| 296 | if "\r" in text: |
| 297 | warnings.warn( |
| 298 | "Pyperclip cannot handle \\r characters on Cygwin.", |
| 299 | stacklevel=find_stack_level(), |
| 300 | ) |
| 301 | |
| 302 | with open("/dev/clipboard", "w", encoding="utf-8") as fd: |
| 303 | fd.write(text) |
| 304 | |
| 305 | def paste_dev_clipboard() -> str: |
| 306 | with open("/dev/clipboard", encoding="utf-8") as fd: |
| 307 | content = fd.read() |
| 308 | return content |
| 309 | |
| 310 | return copy_dev_clipboard, paste_dev_clipboard |
| 311 | |
| 312 | |
| 313 | def init_no_clipboard(): |
no outgoing calls
no test coverage detected