如何在Pybel中禁用记录的警告? [英] How to disable logged warnings in Pybel?

查看:160
本文介绍了如何在Pybel中禁用记录的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Pybel-一种围绕OpenBabel API的Python包装程序,并且我试图禁用以下警告:

I am using Pybel - a Python wrapper around the OpenBabel API, and I am trying to disable warnings such as these:

==============================
*** Open Babel Warning  in ParseComplex
  Illegal aromatic element b-

当从 ChEMBL

推荐答案

您可以从openbabel模块获取openbabel记录器(类OBMessageHandler)的句柄.诀窍是首先从pybel模块中访问openbabel模块,获取OBMessageHandler类,然后实例化记录器(

You can obtain a handle to the openbabel logger (the class OBMessageHandler) off of the openbabel module. The trick is to first access the openbabel module off of the pybel module, grab the OBMessageHandler class, and instantiate the logger (docs):

import pybel

ob_log_handler = pybel.ob.OBMessageHandler()

使用手柄,您可以将log_level设置为 0 以禁用所有非关键消息(

Using the handle, you can set the log_level to 0 to disable all but critical messages (docs):

ob_log_handler.SetOutputLevel(0)

您可以使用以下枚举(此处的文档)选择您的日志记录级别.默认值为 1 ,该日志记录所有警告:

You can use the following enumerations (docs here) to choose your level of logging. The default is 1, which logs all warnings:

  • 0 :严重
  • 1 :警告(默认)
  • 2 :信息
  • 3 :审核(当分子被破坏/感知时)
  • 4 :调试
  • 0: Critical
  • 1: Warning (default)
  • 2: Info
  • 3: Audit (when molecules are destroyed/perceived)
  • 4: Debug

这篇关于如何在Pybel中禁用记录的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆