mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user