home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1707 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.5 KB  |  46 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import subprocess
  5. import sys
  6. from IPython.ipapi import TryNext
  7.  
  8. def win32_clipboard_get():
  9.     
  10.     try:
  11.         import win32clipboard
  12.     except ImportError:
  13.         message = 'Getting text from the clipboard requires the pywin32 extensions: http://sourceforge.net/projects/pywin32/'
  14.         raise TryNext(message)
  15.  
  16.     win32clipboard.OpenClipboard()
  17.     text = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT)
  18.     win32clipboard.CloseClipboard()
  19.     return text
  20.  
  21.  
  22. def osx_clipboard_get():
  23.     p = subprocess.Popen([
  24.         'pbpaste',
  25.         '-Prefer',
  26.         'ascii'], stdout = subprocess.PIPE)
  27.     (text, stderr) = p.communicate()
  28.     text = text.replace('\r', '\n')
  29.     return text
  30.  
  31.  
  32. def tkinter_clipboard_get():
  33.     
  34.     try:
  35.         import Tkinter
  36.     except ImportError:
  37.         message = 'Getting text from the clipboard on this platform requires Tkinter.'
  38.         raise TryNext(message)
  39.  
  40.     root = Tkinter.Tk()
  41.     root.withdraw()
  42.     text = root.clipboard_get()
  43.     root.destroy()
  44.     return text
  45.  
  46.