|
6 | 6 | from bpython.keys import cli_key_dispatch as key_dispatch
|
7 | 7 |
|
8 | 8 |
|
| 9 | +MAGIC_METHODS = ", ".join("__%s__" % s for s in [ |
| 10 | + "init", "repr", "str", "lt", "le", "eq", "ne", "gt", "ge", "cmp", "hash", |
| 11 | + "nonzero", "unicode", "getattr", "setattr", "get", "set","call", "len", |
| 12 | + "getitem", "setitem", "iter", "reversed", "contains", "add", "sub", "mul", |
| 13 | + "floordiv", "mod", "divmod", "pow", "lshift", "rshift", "and", "xor", "or", |
| 14 | + "div", "truediv", "neg", "pos", "abs", "invert", "complex", "int", "float", |
| 15 | + "oct", "hex", "index", "coerce", "enter", "exit"] |
| 16 | +) |
| 17 | + |
9 | 18 | class Struct(object):
|
10 | 19 | """Simple class for instantiating objects we can add arbitrary attributes
|
11 | 20 | to and use for various arbitrary things."""
|
@@ -45,6 +54,8 @@ def loadini(struct, configfile):
|
45 | 54 | 'arg_spec': True,
|
46 | 55 | 'auto_display_list': True,
|
47 | 56 | 'color_scheme': 'default',
|
| 57 | + 'complete_magic_methods' : True, |
| 58 | + 'magic_methods' : MAGIC_METHODS, |
48 | 59 | 'dedent_after': 1,
|
49 | 60 | 'flush_output': True,
|
50 | 61 | 'highlight_show_source': True,
|
@@ -124,6 +135,11 @@ def loadini(struct, configfile):
|
124 | 135 | struct.cli_suggestion_width = config.getfloat('cli',
|
125 | 136 | 'suggestion_width')
|
126 | 137 |
|
| 138 | + struct.complete_magic_methods = config.getboolean('general', |
| 139 | + 'complete_magic_methods') |
| 140 | + methods = config.get('general', 'magic_methods') |
| 141 | + struct.magic_methods = [meth.strip() for meth in methods.split(",")] |
| 142 | + |
127 | 143 | struct.gtk_font = config.get('gtk', 'font')
|
128 | 144 |
|
129 | 145 | color_scheme_name = config.get('general', 'color_scheme')
|
|
0 commit comments