def test_session_plot_option(self): # Check if the session_plot_option and config_plot_optin return the # same value readable = False tools.set_config_file(world_readable=readable) session_plot_option = session.get_session_plot_options() self.assertEqual(session_plot_option['world_readable'], readable) tools.reset_config_file()
def _plot_option_logic(plot_options): """ Given some plot_options as part of a plot call, decide on final options """ session_plot_options = get_session_plot_options() current_plot_options = get_plot_options() current_plot_options.update(plot_options) if (('filename' in plot_options or 'filename' in session_plot_options) and 'fileopt' not in session_plot_options and 'fileopt' not in plot_options): current_plot_options['fileopt'] = 'overwrite' return current_plot_options
def get_plot_options(): """ Merge default and user-defined plot options. """ plot_options = copy.deepcopy(DEFAULT_PLOT_OPTIONS) session_plot_options = get_session_plot_options() for plot_option_key in plot_options: # checking for not false, but truthy value here is the desired behavior session_value = session_plot_options.get(plot_option_key) if session_value is False or session_value: plot_options[plot_option_key] = session_value return plot_options