如何在Pybel中禁用记录的警告? [英] How to disable logged warnings in 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屋!