Differences between revisions 7 and 8
Revision 7 as of 2008-10-02 02:31:38
Size: 1028
Editor: lizzie
Comment:
Revision 8 as of 2009-12-25 07:13:47
Size: 1028
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

   1 def iniCDinfo(cdrom,cdcfile):
   2     '''光盘信息.ini格式化函式
   3     @note: 直接利用 os.walk() 函式的输出信息由ConfigParser.RawConfigParser进行重组处理成 .ini 格式文本输出并记录
   4     @param cdrom: 光盘访问路径
   5     @param cdcfile: 输出的光盘信息记录文件(包含路径,绝对、相对都可以)
   6     @return: 无,直接输出成组织好的类.ini 的*.cdc 文件
   7     '''
   8     walker = {}
   9     for root, dirs, files in os.walk(cdrom):
  10         walker[root]=(dirs,files)     # 这里是个需要理解的地方
  11     cfg = rcp()
  12     cfg.add_section("Info")
  13     cfg.add_section("Comment")
  14     cfg.set("Info", 'ImagePath', cdrom)
  15     cfg.set("Info", 'Volume', cdcfile)
  16     dirs = walker.keys()
  17     i = 0
  18     for d in dirs:
  19         i+=1
  20         cfg.set("Comment", str(i),d)
  21     for p in walker:
  22         cfg.add_section(p)
  23         for f in walker[p][1]:
  24             cfg.set(p, f, os.stat("%s/%s"%(p,f)).st_size)    
  25     cfg.write(open(cdcfile,"w"))

ObpLovelyPython/CDay1/new (last edited 2009-12-25 07:13:47 by localhost)