ObpLovelyPython/CDay1/old
1 def cdWalker(cdrom,cdcfile):
2 '''光盘扫描主函式
3 @param cdrom: 光盘访问路径
4 @param cdcfile: 输出的光盘信息记录文件(包含路径,绝对、相对都可以)
5 @return: 无,直接输出成*.cdc 文件
6 @attention: 从v0.7 开始不使用此扫描函式,使用 iniCDinfo()
7 '''
8 export = ""
9 for root, dirs, files in os.walk(cdrom):
10 print formatCDinfo(root,dirs,files)
11 export+= formatCDinfo(root,dirs,files)
12 open(cdcfile, 'w').write(export)
13
14 def formatCDinfo(root,dirs,files):
15 '''光盘信息记录格式化函式
16 @note: 直接利用 os.walk() 函式的输出信息进行重组
17 @param root: 当前根
18 @param dirs: 当前根中的所有目录
19 @param files: 当前根中的所有文件
20 @return: 字串,组织好的当前目录信息
21 '''
22 export = "\n"+root+"\n"
23 for d in dirs:
24 export+= "-d "+root+_smartcode(d)+"\n"
25 for f in files:
26 export+= "-f %s %s \n" % (root,_smartcode(f))
27 export+= "="*70
28 return export
ObpLovelyPython/CDay1/old (last edited 2009-12-25 07:12:55 by localhost)