25
25
26
26
import os
27
27
import sys
28
-
29
28
from configparser import ConfigParser
30
29
from pudb .lowlevel import (lookup_module , get_breakpoint_invalid_reason ,
31
30
settings_log )
@@ -123,6 +122,8 @@ def load_config():
123
122
124
123
conf_dict .setdefault ("hide_cmdline_win" , "False" )
125
124
125
+ conf_dict .setdefault ("enable_community_contributed_content" , "False" )
126
+
126
127
def normalize_bool_inplace (name ):
127
128
try :
128
129
if conf_dict [name ].lower () in ["0" , "false" , "off" ]:
@@ -136,6 +137,7 @@ def normalize_bool_inplace(name):
136
137
normalize_bool_inplace ("wrap_variables" )
137
138
normalize_bool_inplace ("prompt_on_quit" )
138
139
normalize_bool_inplace ("hide_cmdline_win" )
140
+ normalize_bool_inplace ("enable_community_contributed_content" )
139
141
140
142
_config_ [0 ] = conf_dict
141
143
return conf_dict
@@ -223,6 +225,11 @@ def _update_config(check_box, new_state, option_newvalue):
223
225
conf_dict .update (new_conf_dict )
224
226
_update_hide_cmdline_win ()
225
227
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
+
226
233
elif option == "current_stack_frame" :
227
234
# only activate if the new state of the radio button is 'on'
228
235
if new_state :
@@ -270,6 +277,14 @@ def _update_config(check_box, new_state, option_newvalue):
270
277
bool (conf_dict ["hide_cmdline_win" ]), on_state_change = _update_config ,
271
278
user_data = ("hide_cmdline_win" , None ))
272
279
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
+
273
288
# {{{ shells
274
289
275
290
shell_info = urwid .Text ("This is the shell that will be "
@@ -345,8 +360,18 @@ def _update_config(check_box, new_state, option_newvalue):
345
360
# {{{ stringifier
346
361
347
362
from pudb .var_view import STRINGIFIERS
363
+ from pudb .contrib .stringifiers import CONTRIB_STRINGIFIERS
348
364
stringifier_opts = list (STRINGIFIERS .keys ())
365
+ if conf_dict ["enable_community_contributed_content" ]:
366
+ stringifier_opts = (
367
+ list (STRINGIFIERS .keys ()) + list (CONTRIB_STRINGIFIERS .keys ()))
349
368
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 )
350
375
stringifier_rb_group = []
351
376
stringifier_edit = urwid .Edit (edit_text = conf_dict ["custom_stringifier" ])
352
377
stringifier_info = urwid .Text (
@@ -357,15 +382,21 @@ def _update_config(check_box, new_state, option_newvalue):
357
382
"be slower than the default, type, or id stringifiers.\n " )
358
383
stringifier_edit_list_item = urwid .AttrMap (stringifier_edit ,
359
384
"input" , "focused input" )
385
+
360
386
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
+ ]+ [
361
392
urwid .RadioButton (stringifier_rb_group , name ,
362
393
conf_dict ["stringifier" ] == name ,
363
394
on_state_change = _update_config ,
364
395
user_data = ("stringifier" , name ))
365
- for name in stringifier_opts
396
+ for name in stringifier_opts if name != "default"
366
397
]+ [
367
398
urwid .RadioButton (stringifier_rb_group , "Custom:" ,
368
- not known_stringifier , on_state_change = _update_config ,
399
+ custom_stringifier , on_state_change = _update_config ,
369
400
user_data = ("stringifier" , None )),
370
401
stringifier_edit_list_item ,
371
402
urwid .Text ("\n To use a custom stringifier, see "
@@ -441,6 +472,7 @@ def _update_config(check_box, new_state, option_newvalue):
441
472
+ [cb_line_numbers ]
442
473
+ [cb_prompt_on_quit ]
443
474
+ [hide_cmdline_win ]
475
+ + [enable_community_contributed_content ]
444
476
445
477
+ [urwid .AttrMap (urwid .Text ("\n Shell:\n " ), "group head" )]
446
478
+ [shell_info ]
0 commit comments