def _test(): """test funciton""" from pprint import pprint _testpath = 'test_path' if not os.path.exists(_testpath): os.mkdir(_testpath) _str_test1 = """dfasfdasfasfasfasfdas fasdfdsafdasfasfasfdaxzvnczxm,hedui fs dfaskfjasdop koasfjiodsn f""" _str_test2 = """17:45 luomio@luomio-laptop ~ $ zcat grade.txt.gz | checkgid Display all 114 possibilities? (y or n) 17:45 luomio@luomio-laptop ~ $ zcat grade.txt.gz | md5sum Display all 114 possibilities? (y or n) 17:45 luomio@luomio-laptop ~ $ zcat grade.txt.gz | md5sum a91521cf2c50748ab42e2823e14aec5b - 17:45 luomio@luomio-laptop ~""" _test_file_group1 = ['test1.txt', 'test2.txt', 'test3.txt'] _test_file_group2 = ['file1.txt', 'file2.txt', 'file3.txt'] for _fname in _test_file_group1: with open(_testpath + os.sep + _fname, 'w') as _fp: _fp.write(_str_test1) for _fname in _test_file_group2: with open(_testpath + os.sep + _fname, 'w') as _fp: _fp.write(_str_test2) pprint(os.listdir(_testpath)) delete_dup(_testpath) pprint(os.listdir(_testpath)) for _fp in os.listdir(_testpath): os.remove(_testpath + os.sep + _fp) print """After cleandup""" pprint(os.listdir(_testpath)) os.rmdir(_testpath)
def clean(): """cleanup after download finished""" # 1.添加后缀 print 'Adding extension ...' for fname in os.listdir(Config.DIRECTORY): add_extension(Config.DIRECTORY + os.sep + fname, '.jpg') print 'done.' print 'Deleting duplicate files...' delete_dup(Config.DIRECTORY)