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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import os
  6. import pythoncom
  7. import win32com
  8. import winerror
  9. from win32com.server.util import wrap
  10.  
  11. try:
  12.     __file__
  13. except NameError:
  14.     __file__ = sys.argv[0]
  15.  
  16.  
  17. class CPippo:
  18.     _reg_clsid_ = '{05AC1CCE-3F9B-4d9a-B0B5-DFE8BE45AFA8}'
  19.     _reg_desc_ = 'Pippo Python test object'
  20.     _reg_progid_ = 'Python.Test.Pippo'
  21.     _typelib_guid_ = '{41059C57-975F-4B36-8FF3-C5117426647A}'
  22.     _typelib_version_ = (1, 0)
  23.     _com_interfaces_ = [
  24.         'IPippo']
  25.     
  26.     def __init__(self):
  27.         self.MyProp1 = 10
  28.  
  29.     
  30.     def Method1(self):
  31.         return wrap(CPippo())
  32.  
  33.     
  34.     def Method2(self, in1, inout1):
  35.         return (in1, inout1 * 2)
  36.  
  37.  
  38.  
  39. def BuildTypelib():
  40.     newer = newer
  41.     import distutils.dep_util
  42.     this_dir = os.path.dirname(__file__)
  43.     idl = os.path.abspath(os.path.join(this_dir, 'pippo.idl'))
  44.     tlb = os.path.splitext(idl)[0] + '.tlb'
  45.     if newer(idl, tlb):
  46.         print 'Compiling %s' % (idl,)
  47.         rc = os.system('midl "%s"' % (idl,))
  48.         if rc:
  49.             raise RuntimeError, 'Compiling MIDL failed!'
  50.         rc
  51.         for fname in 'dlldata.c pippo_i.c pippo_p.c pippo.h'.split():
  52.             os.remove(os.path.join(this_dir, fname))
  53.         
  54.     
  55.     print 'Registering %s' % (tlb,)
  56.     tli = pythoncom.LoadTypeLib(tlb)
  57.     pythoncom.RegisterTypeLib(tli, tlb)
  58.  
  59.  
  60. def UnregisterTypelib():
  61.     k = CPippo
  62.     
  63.     try:
  64.         pythoncom.UnRegisterTypeLib(k._typelib_guid_, k._typelib_version_[0], k._typelib_version_[1], 0, pythoncom.SYS_WIN32)
  65.         print 'Unregistered typelib'
  66.     except pythoncom.error:
  67.         details = None
  68.         if details[0] == winerror.TYPE_E_REGISTRYACCESS:
  69.             pass
  70.         else:
  71.             raise 
  72.         details[0] == winerror.TYPE_E_REGISTRYACCESS
  73.  
  74.  
  75.  
  76. def main(argv = None):
  77.     if argv is None:
  78.         argv = sys.argv[1:]
  79.     
  80.     if '--unregister' in argv:
  81.         UnregisterTypelib()
  82.     else:
  83.         BuildTypelib()
  84.     import win32com.server.register as win32com
  85.     win32com.server.register.UseCommandLine(CPippo)
  86.  
  87. if __name__ == '__main__':
  88.     main(sys.argv)
  89.  
  90.