django快速可扩展进度表(tqdm)
django-tqdm的Python项目详细描述
django的快速可扩展进度表(tqdm)。
用法
fromdjango_tqdmimportBaseCommandfromtimeimportsleepclassCommand(BaseCommand):defhandle(self,*args,**options):# Output directlyself.error('Error')self.info('Info')# Output through tqdmt=self.tqdm(total=50)forxinrange(50):sleep(0.03)t.update(1)ifx==10:t.info('X = 10')ifx==20:t.error('X = 20')
高级:
info(text,ending='\n',fatal=False)error(text,ending='\n',fatal=False)write(text,ending='\n',fatal=False,error=False)
如果您将fatal设置为true它将在打印消息后终止命令。
有关TQM的文档,请参见tqdm。
比较
在django tqdm中:
self.info('info')self.error('error')
在香草酒中:
self.stdout.write('info')self.stderr.write('error')
演示
演示2-TQM用法
t=self.tqdm(total=50)forxinrange(50):sleep(0.02)t.update(1)ifx==10:t.info('info')ifx==40:t.error('error')
演示3-带有默认比较设置的Vanilla TQM
t=tqdm(total=50)forxinrange(50):sleep(0.02)t.update(1)ifx==25:t.write('info')ifx==40:t.write('error',file=sys.stderr)
开发
使用clean.sh自动美化代码。
使用tox进行测试和起绒。