def save_sample_file(fname): if '51job' in fname: print os.getcwd() channel = 'cv_51job' target = os.path.join(os.path.dirname(__file__), '%s/cv_51job_sample' % PREFIX) elif 'zhilian' in fname: channel = 'cv_zhilian' target = os.path.join(os.path.dirname(__file__), '%s/cv_zhilian_sample' % PREFIX) elif 'liepin' in fname: channel = 'cv_liepin' target = os.path.join(os.path.dirname(__file__), '%s/cv_liepin_sample' % PREFIX) else: raise Exception('file name can not recognize') dest = '%s_sample' % channel util.untar(fname, dest) files = [] find_files(dest, files) # 清理 util.check_and_clear(target) for f in files: if os.path.split(f)[1].startswith('.'): continue shutil.move(f, target) # 清除 解压目录, 源文件 os.system('rm -rf %s; rm -rf %s' % (dest, fname))
def save_parse_file(fname): if '51job' in fname: target = os.path.join(os.path.dirname(__file__), '%s/cv_51job_person_parsed' % PREFIX) elif 'zhilian' in fname: target = os.path.join(os.path.dirname(__file__), '%s/cv_zhilian_person_parsed' % PREFIX) elif 'liepin' in fname: target = os.path.join(os.path.dirname(__file__), '%s/cv_liepin_person_parsed' % PREFIX) else: raise Exception('file name can not recognize') util.check_and_clear(target) shutil.move(fname, target+'/parsed.csv')