2525
2626import os
2727import sys
28-
2928from configparser import ConfigParser
3029from pudb .lowlevel import (lookup_module , get_breakpoint_invalid_reason ,
3130 settings_log )
@@ -123,6 +122,8 @@ def load_config():
123122
124123 conf_dict .setdefault ("hide_cmdline_win" , "False" )
125124
125+ conf_dict .setdefault ("enable_community_contributed_content" , "False" )
126+
126127 def normalize_bool_inplace (name ):
127128 try :
128129 if conf_dict [name ].lower () in ["0" , "false" , "off" ]:
@@ -136,6 +137,7 @@ def normalize_bool_inplace(name):
136137 normalize_bool_inplace ("wrap_variables" )
137138 normalize_bool_inplace ("prompt_on_quit" )
138139 normalize_bool_inplace ("hide_cmdline_win" )
140+ normalize_bool_inplace ("enable_community_contributed_content" )
139141
140142 _config_ [0 ] = conf_dict
141143 return conf_dict
@@ -223,6 +225,11 @@ def _update_config(check_box, new_state, option_newvalue):
223225 conf_dict .update (new_conf_dict )
224226 _update_hide_cmdline_win ()
225227
228+ elif option == "enable_community_contributed_content" :
229+ new_conf_dict ["enable_community_contributed_content" ] = (
230+ not check_box .get_state ())
231+ conf_dict .update (new_conf_dict )
232+
226233 elif option == "current_stack_frame" :
227234 # only activate if the new state of the radio button is 'on'
228235 if new_state :
@@ -270,6 +277,14 @@ def _update_config(check_box, new_state, option_newvalue):
270277 bool (conf_dict ["hide_cmdline_win" ]), on_state_change = _update_config ,
271278 user_data = ("hide_cmdline_win" , None ))
272279
280+ enable_community_contributed_content = urwid .CheckBox (
281+ "Enable community contributed content. This will give you access to more "
282+ "stringifiers, shells and themes. \n "
283+ "Changing this setting requires a restart of PuDB." ,
284+ bool (conf_dict ["enable_community_contributed_content" ]),
285+ on_state_change = _update_config ,
286+ user_data = ("enable_community_contributed_content" , None ))
287+
273288 # {{{ shells
274289
275290 shell_info = urwid .Text ("This is the shell that will be "
@@ -345,8 +360,18 @@ def _update_config(check_box, new_state, option_newvalue):
345360 # {{{ stringifier
346361
347362 from pudb .var_view import STRINGIFIERS
363+ from pudb .contrib .stringifiers import CONTRIB_STRINGIFIERS
348364 stringifier_opts = list (STRINGIFIERS .keys ())
365+ if conf_dict ["enable_community_contributed_content" ]:
366+ stringifier_opts = (
367+ list (STRINGIFIERS .keys ()) + list (CONTRIB_STRINGIFIERS .keys ()))
349368 known_stringifier = conf_dict ["stringifier" ] in stringifier_opts
369+ contrib_stringifier = conf_dict ["stringifier" ] in CONTRIB_STRINGIFIERS
370+ fallback_to_default_stringifier = (contrib_stringifier and not
371+ conf_dict ["enable_community_contributed_content" ])
372+ use_default_stringifier = ((conf_dict ["stringifier" ] == "default" ) or
373+ fallback_to_default_stringifier )
374+ custom_stringifier = not (known_stringifier or contrib_stringifier )
350375 stringifier_rb_group = []
351376 stringifier_edit = urwid .Edit (edit_text = conf_dict ["custom_stringifier" ])
352377 stringifier_info = urwid .Text (
@@ -357,15 +382,21 @@ def _update_config(check_box, new_state, option_newvalue):
357382 "be slower than the default, type, or id stringifiers.\n " )
358383 stringifier_edit_list_item = urwid .AttrMap (stringifier_edit ,
359384 "input" , "focused input" )
385+
360386 stringifier_rbs = [
387+ urwid .RadioButton (stringifier_rb_group , "default" ,
388+ use_default_stringifier ,
389+ on_state_change = _update_config ,
390+ user_data = ("stringifier" , "default" ))
391+ ]+ [
361392 urwid .RadioButton (stringifier_rb_group , name ,
362393 conf_dict ["stringifier" ] == name ,
363394 on_state_change = _update_config ,
364395 user_data = ("stringifier" , name ))
365- for name in stringifier_opts
396+ for name in stringifier_opts if name != "default"
366397 ]+ [
367398 urwid .RadioButton (stringifier_rb_group , "Custom:" ,
368- not known_stringifier , on_state_change = _update_config ,
399+ custom_stringifier , on_state_change = _update_config ,
369400 user_data = ("stringifier" , None )),
370401 stringifier_edit_list_item ,
371402 urwid .Text ("\n To use a custom stringifier, see "
@@ -441,6 +472,7 @@ def _update_config(check_box, new_state, option_newvalue):
441472 + [cb_line_numbers ]
442473 + [cb_prompt_on_quit ]
443474 + [hide_cmdline_win ]
475+ + [enable_community_contributed_content ]
444476
445477 + [urwid .AttrMap (urwid .Text ("\n Shell:\n " ), "group head" )]
446478 + [shell_info ]
0 commit comments