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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import win32com
  5. import win32com.client.makepy as win32com
  6. import win32com.test as win32com
  7. import pythoncom
  8. import sys
  9. import os
  10. genList = [
  11.     ('msword8', '{00020905-0000-0000-C000-000000000046}', 1033, 8, 0)]
  12. genDir = 'Generated4Test'
  13.  
  14. def GetGenPath():
  15.     import win32api
  16.     return os.path.join(win32api.GetFullPathName(win32com.test.__path__[0]), genDir)
  17.  
  18.  
  19. def GenerateFromRegistered(fname, *loadArgs):
  20.     genPath = GetGenPath()
  21.     
  22.     try:
  23.         os.stat(genPath)
  24.     except os.error:
  25.         os.mkdir(genPath)
  26.  
  27.     open(os.path.join(genPath, '__init__.py'), 'w').close()
  28.     print fname, ': generating -',
  29.     f = open(os.path.join(genPath, fname + '.py'), 'w')
  30.     win32com.client.makepy.GenerateFromTypeLibSpec(loadArgs, f, bQuiet = 1, bGUIProgress = 1, bUnicodeToString = NeedUnicodeConversions)
  31.     f.close()
  32.     print 'compiling -',
  33.     fullModName = 'win32com.test.%s.%s' % (genDir, fname)
  34.     exec 'import ' + fullModName
  35.     sys.modules[fname] = sys.modules[fullModName]
  36.     print 'done'
  37.  
  38.  
  39. def GenerateAll():
  40.     for args in genList:
  41.         
  42.         try:
  43.             apply(GenerateFromRegistered, args)
  44.         continue
  45.         except KeyboardInterrupt:
  46.             print '** Interrupted ***'
  47.             break
  48.             continue
  49.             except pythoncom.com_error:
  50.                 print '** Could not generate test code for ', args[0]
  51.                 continue
  52.             
  53.         return None
  54.  
  55.  
  56.  
  57. def CleanAll():
  58.     print 'Cleaning generated test scripts...'
  59.     
  60.     try:
  61.         1 / 0
  62.     except:
  63.         pass
  64.  
  65.     genPath = GetGenPath()
  66.     for args in genList:
  67.         
  68.         try:
  69.             name = args[0] + '.py'
  70.             os.unlink(os.path.join(genPath, name))
  71.         except os.error:
  72.             details = None
  73.             if type(details) == type(()) and details[0] != 2:
  74.                 print 'Could not deleted generated', name, details
  75.             
  76.         except:
  77.             details[0] != 2
  78.  
  79.         
  80.         try:
  81.             name = args[0] + '.pyc'
  82.             os.unlink(os.path.join(genPath, name))
  83.         except os.error:
  84.             details = None
  85.             if type(details) == type(()) and details[0] != 2:
  86.                 print 'Could not deleted generated', name, details
  87.             
  88.         except:
  89.             details[0] != 2
  90.  
  91.         
  92.         try:
  93.             os.unlink(os.path.join(genPath, '__init__.py'))
  94.         except:
  95.             pass
  96.  
  97.         
  98.         try:
  99.             os.unlink(os.path.join(genPath, '__init__.pyc'))
  100.         continue
  101.         continue
  102.  
  103.     
  104.     
  105.     try:
  106.         os.rmdir(genPath)
  107.     except os.error:
  108.         details = None
  109.         print 'Could not delete test directory -', details
  110.  
  111.  
  112. if __name__ == '__main__':
  113.     GenerateAll()
  114.     CleanAll()
  115.  
  116.