⇤ ← Revision 1 as of 2007-08-22 15:32:14
Size: 1065
Comment:
|
Size: 1029
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 17: | Line 17: |
cfg.set("Info", 'FAT', 'CDFS') |
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"))