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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import win32com.client as win32com
  5.  
  6. def DumpDB(db, bDeep = 1):
  7.     DumpTables(db, bDeep)
  8.     DumpRelations(db, bDeep)
  9.     DumpAllContainers(db, bDeep)
  10.  
  11.  
  12. def DumpTables(db, bDeep = 1):
  13.     for tab in db.TableDefs:
  14.         tab = db.TableDefs(tab.Name)
  15.         print 'Table %s - Fields: %d, Attributes:%d' % (tab.Name, len(tab.Fields), tab.Attributes)
  16.         if bDeep:
  17.             DumpFields(tab.Fields)
  18.             continue
  19.     
  20.  
  21.  
  22. def DumpFields(fields):
  23.     for field in fields:
  24.         print '  %s, size=%d, reqd=%d, type=%d, defVal=%s' % (field.Name, field.Size, field.Required, field.Type, str(field.DefaultValue))
  25.     
  26.  
  27.  
  28. def DumpRelations(db, bDeep = 1):
  29.     for relation in db.Relations:
  30.         print 'Relation %s - %s->%s' % (relation.Name, relation.Table, relation.ForeignTable)
  31.     
  32.  
  33.  
  34. def DumpAllContainers(db, bDeep = 1):
  35.     for cont in db.Containers:
  36.         print 'Container %s - %d documents' % (cont.Name, len(cont.Documents))
  37.         if bDeep:
  38.             DumpContainerDocuments(cont)
  39.             continue
  40.     
  41.  
  42.  
  43. def DumpContainerDocuments(container):
  44.     for doc in container.Documents:
  45.         import time
  46.         timeStr = time.ctime(int(doc.LastUpdated))
  47.         print '  %s - updated %s (' % (doc.Name, timeStr), doc.LastUpdated, ')'
  48.     
  49.  
  50.  
  51. def TestEngine(engine):
  52.     import sys
  53.     if len(sys.argv) > 1:
  54.         dbName = sys.argv[1]
  55.     else:
  56.         dbName = 'e:\\temp\\TestPython.mdb'
  57.     db = engine.OpenDatabase(dbName)
  58.     DumpDB(db)
  59.  
  60.  
  61. def test():
  62.     for progid in ('DAO.DBEngine.36', 'DAO.DBEngine.35', 'DAO.DBEngine.30'):
  63.         
  64.         try:
  65.             ob = win32com.client.gencache.EnsureDispatch(progid)
  66.         except pythoncom.com_error:
  67.             print progid, 'does not seem to be installed'
  68.             continue
  69.  
  70.         TestEngine(ob)
  71.     
  72.  
  73. if __name__ == '__main__':
  74.     test()
  75.  
  76.