Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
This commit is contained in:
Paolo Tosco
2022-03-17 13:41:36 +01:00
committed by GitHub
parent 0945850816
commit 2d7eb89ffc

View File

@@ -197,19 +197,19 @@ def patchPandasrepr(self, **kwargs):
global defPandasGetAdjustment
import pandas.io.formats.html
if not hasattr(pandas.io.formats.html.HTMLFormatter, "_rdkitpatched"):
defHTMLFormatter_write_cell = pd.io.formats.html.HTMLFormatter._write_cell
pd.io.formats.html.HTMLFormatter._write_cell = _patched_HTMLFormatter_write_cell
pandas.io.formats.html.HTMLFormatter._rdkitpatched = True
get_adjustment_attr = getAdjustmentAttr()
if get_adjustment_attr:
defPandasGetAdjustment = getattr(pd.io.formats.format, get_adjustment_attr)
setattr(pd.io.formats.format, get_adjustment_attr, _patched_get_adjustment)
res = defPandasRepr(self, **kwargs)
if get_adjustment_attr:
setattr(pd.io.formats.format, get_adjustment_attr, defPandasGetAdjustment)
pd.io.formats.html.HTMLFormatter._write_cell = defHTMLFormatter_write_cell
return res
defHTMLFormatter_write_cell = pd.io.formats.html.HTMLFormatter._write_cell
pd.io.formats.html.HTMLFormatter._write_cell = _patched_HTMLFormatter_write_cell
try:
get_adjustment_attr = getAdjustmentAttr()
if get_adjustment_attr:
defPandasGetAdjustment = getattr(pd.io.formats.format, get_adjustment_attr)
setattr(pd.io.formats.format, get_adjustment_attr, _patched_get_adjustment)
res = defPandasRepr(self, **kwargs)
if get_adjustment_attr:
setattr(pd.io.formats.format, get_adjustment_attr, defPandasGetAdjustment)
return res
finally:
pd.io.formats.html.HTMLFormatter._write_cell = defHTMLFormatter_write_cell
def patchPandasHTMLrepr(self, **kwargs):