def test_print_methods(): """Test method.""" set_opt("verbose", True) f_stream = io.StringIO() with redirect_stdout(f_stream): nb_print("status") nb_data_wait("table1") check.is_in("status", str(f_stream.getvalue())) check.is_in("Getting data from table1", str(f_stream.getvalue())) set_opt("verbose", False) f_stream = io.StringIO() with redirect_stdout(f_stream): nb_print("status") check.is_not_in("status", str(f_stream.getvalue())) check.is_not_in("Getting data from table1", str(f_stream.getvalue())) set_opt("debug", True) f_stream = io.StringIO() with redirect_stdout(f_stream): nb_debug("debug", "debugmssg", "val", 1, "result", True) check.is_in("debug", str(f_stream.getvalue())) check.is_in("debugmssg", str(f_stream.getvalue())) check.is_in("val", str(f_stream.getvalue())) check.is_in("1", str(f_stream.getvalue())) check.is_in("result", str(f_stream.getvalue())) check.is_in("True", str(f_stream.getvalue()))
def run_additional_operation( self, event_ids: Optional[Union[int, Iterable[int]]] = None) -> pd.DataFrame: """ Addition method. Parameters ---------- event_ids : Optional[Union[int, Iterable[int]]], optional Single or interable of event IDs (ints). Returns ------- pd.DataFrame Results with expanded columns. """ # Include this to check the "run()" has happened before this method # can be run if (not self._last_result or self._last_result.all_events is None): # type: ignore print( "Please use 'run()' to fetch the data before using this method.", "\nThen call 'expand_events()'", ) return None # Print a status message - this will not be displayed if # the user has set the global "verbose" option to False. nb_print("We maybe about to wait some time") nb_markdown("Print some message that always displays", "blue, bold") return _do_additional_thing( evt_df=self._last_result.all_events, # type: ignore event_ids=event_ids, )
def _test_yaml_text(host_entity): nb_print("TestYaml") nb_print(host_entity)
def _test_inline_text(host_entity): nb_print("TestInline") nb_print(host_entity)
def _do_additional_thing(evt_df, event_ids): # nb_print is the same as print() except it honors the # 'silent' option. nb_print("Doing something time-consuming...") return evt_df[evt_df["EventID"].isin(event_ids)]