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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. success = False
  6. in_ironpython = 'IronPython' in sys.version
  7. if in_ironpython:
  8.     
  9.     try:
  10.         from ironpython_clipboard import GetClipboardText, SetClipboardText
  11.         success = True
  12.     except ImportError:
  13.         pass
  14.     except:
  15.         None<EXCEPTION MATCH>ImportError
  16.     
  17.  
  18. None<EXCEPTION MATCH>ImportError
  19.  
  20. try:
  21.     from win32_clipboard import GetClipboardText, SetClipboardText
  22.     success = True
  23. except ImportError:
  24.     raise 
  25.  
  26.  
  27. def send_data(lists):
  28.     SetClipboardText(make_tab(lists))
  29.  
  30.  
  31. def set_clipboard_text(toclipboard):
  32.     SetClipboardText(str(toclipboard))
  33.  
  34.  
  35. def make_tab(lists):
  36.     if hasattr(lists, 'tolist'):
  37.         lists = lists.tolist()
  38.     
  39.     ut = []
  40.     for rad in lists:
  41.         if type(rad) in [
  42.             list,
  43.             tuple]:
  44.             []([]([ '%s' % x for x in rad ]))
  45.             continue
  46.         '\t'.join
  47.         ut.append('%s' % rad)
  48.     
  49.     return '\n'.join(ut)
  50.  
  51.  
  52. def make_list_of_list(txt):
  53.     
  54.     def make_num(x):
  55.         
  56.         try:
  57.             return int(x)
  58.         except ValueError:
  59.             
  60.             try:
  61.                 return float(x)
  62.             except ValueError:
  63.                 
  64.                 try:
  65.                     return complex(x)
  66.                 except ValueError:
  67.                     return x
  68.                 
  69.  
  70.                 None<EXCEPTION MATCH>ValueError
  71.             
  72.  
  73.             None<EXCEPTION MATCH>ValueError
  74.  
  75.         return x
  76.  
  77.     ut = []
  78.     flag = False
  79.     for x in txt.split('\r\n'):
  80.         if x != '':
  81.             continue
  82.         _[1][x]
  83.     
  84.     return (ut, flag)
  85.  
  86.  
  87. def get_clipboard_text_and_convert(paste_list = False):
  88.     txt = GetClipboardText()
  89.     if txt:
  90.         if paste_list and '\t' in txt:
  91.             (array, flag) = make_list_of_list(txt)
  92.             if flag:
  93.                 txt = repr(array)
  94.             else:
  95.                 txt = 'array(%s)' % repr(array)
  96.             txt = [](_[1])
  97.         
  98.     
  99.     return txt
  100.  
  101.