| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1969,7 +1969,7 @@ def init_wins(scr, cols): | |||
| 1969 | 1969 | ||
| 1970 | 1970 | # TODO: | |
| 1971 | 1971 | # | |
| 1972 | - # This should show to be configured keys from bpython.ini | ||
| 1972 | + # This should show to be configured keys from ~/.bpython/config | ||
| 1973 | 1973 | # | |
| 1974 | 1974 | statusbar = Statusbar(scr, main_win, | |
| 1975 | 1975 | ".:: <C-d> Exit <C-r> Rewind <%s> Save <%s> Pastebin ::." % (OPTS.save_key, OPTS.pastebin_key), | |
@@ -2130,7 +2130,7 @@ def main(args=None): | |||
| 2130 | 2130 | 'NOTE: If bpython sees an argument it does ' | |
| 2131 | 2131 | 'not know, execution falls back to the ' | |
| 2132 | 2132 | 'regular Python interpreter.') | |
| 2133 | - parser.add_option('--config', '-c', default='~/.bpython.ini', | ||
| 2133 | + parser.add_option('--config', '-c', default='~/.bpython/config', | ||
| 2134 | 2134 | help='use CONFIG instead of default config file') | |
| 2135 | 2135 | parser.add_option('--interactive', '-i', action='store_true', | |
| 2136 | 2136 | help='Drop to bpython shell after running file ' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | from ConfigParser import ConfigParser, NoSectionError, NoOptionError | |
| 4 | 4 | from itertools import chain | |
| 5 | 5 | from bpython.keys import key_dispatch | |
| 6 | + import errno | ||
| 6 | 7 | ||
| 7 | 8 | class Struct(object): | |
| 8 | 9 | """Simple class for instantiating objects we can add arbitrary attributes | |
@@ -13,6 +14,9 @@ class Struct(object): | |||
| 13 | 14 | class CP(ConfigParser): | |
| 14 | 15 | def safeget(self, section, option, default): | |
| 15 | 16 | """safet get method using default values""" | |
| 17 | + bools_t = ['true', 'yes', 'y', 'on'] | ||
| 18 | + bools_f = ['false', 'no', 'n', 'off'] | ||
| 19 | + | ||
| 16 | 20 | try: | |
| 17 | 21 | v = self.get(section, option) | |
| 18 | 22 | except NoSectionError: | |
@@ -21,6 +25,13 @@ def safeget(self, section, option, default): | |||
| 21 | 25 | v = default | |
| 22 | 26 | if isinstance(v, bool): | |
| 23 | 27 | return v | |
| 28 | + try: | ||
| 29 | + if v.lower() in bools_t: | ||
| 30 | + return True | ||
| 31 | + if v.lower() in bools_f: | ||
| 32 | + return False | ||
| 33 | + except AttributeError: | ||
| 34 | + pass | ||
| 24 | 35 | try: | |
| 25 | 36 | return int(v) | |
| 26 | 37 | except ValueError: | |
@@ -30,10 +41,15 @@ def safeget(self, section, option, default): | |||
| 30 | 41 | def loadini(struct, configfile): | |
| 31 | 42 | """Loads .ini configuration file and stores its values in struct""" | |
| 32 | 43 | ||
| 33 | - configfile = os.path.expanduser(configfile) | ||
| 44 | + config_path = os.path.expanduser(configfile) | ||
| 45 | + if not os.path.isfile(config_path) and configfile == '~/.bpython/config': | ||
| 46 | + # FIXME: I decided ~/.bpython.ini was a crappy place for a config file, | ||
| 47 | + # so this is just a fallback if the default is passed - remove this | ||
| 48 | + # eventually please. | ||
| 49 | + config_path = os.path.expanduser('~/.bpython.ini') | ||
| 34 | 50 | ||
| 35 | 51 | config = CP() | |
| 36 | - config.read(configfile) | ||
| 52 | + config.read(config_path) | ||
| 37 | 53 | ||
| 38 | 54 | struct.tab_length = config.safeget('general', 'tab_length', 4) | |
| 39 | 55 | struct.auto_display_list = config.safeget('general', 'auto_display_list', | |
@@ -66,7 +82,7 @@ def loadini(struct, configfile): | |||
| 66 | 82 | } | |
| 67 | 83 | else: | |
| 68 | 84 | path = os.path.expanduser('~/.bpython/%s.theme' % (color_scheme_name,)) | |
| 69 | - load_theme(struct, path, configfile) | ||
| 85 | + load_theme(struct, path, config_path) | ||
| 70 | 86 | ||
| 71 | 87 | ||
| 72 | 88 | # checks for valid key configuration this part still sucks | |
@@ -130,12 +146,19 @@ def migrate_rc(path): | |||
| 130 | 146 | v = bools[v.lower()] | |
| 131 | 147 | config.set('general', k, v) | |
| 132 | 148 | f.close() | |
| 133 | - f = open(os.path.expanduser('~/.bpython.ini'), 'w') | ||
| 149 | + try: | ||
| 150 | + os.makedirs(os.path.expanduser('~/.bpython')) | ||
| 151 | + except OSError, e: | ||
| 152 | + if e.errno == errno.EEXIST: | ||
| 153 | + pass | ||
| 154 | + else: | ||
| 155 | + raise | ||
| 156 | + f = open(os.path.expanduser('~/.bpython/config'), 'w') | ||
| 134 | 157 | config.write(f) | |
| 135 | 158 | f.close() | |
| 136 | 159 | os.rename(path, os.path.expanduser('~/.bpythonrc.bak')) | |
| 137 | 160 | print ("The configuration file for bpython has been changed. A new " | |
| 138 | - ".bpython.ini file has been created in your home directory.") | ||
| 161 | + "config file has been created as ~/.bpython/config") | ||
| 139 | 162 | print ("The existing .bpythonrc file has been renamed to .bpythonrc.bak " | |
| 140 | 163 | "and it can be removed.") | |
| 141 | 164 | print "Press enter to continue." | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | .\" First parameter, NAME, should be all caps | |
| 3 | 3 | .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection | |
| 4 | 4 | .\" other parameters are allowed: see man(7), man(1) | |
| 5 | - .TH BPYTHON.INI 5 "August 13, 2008" | ||
| 5 | + .TH BPYTHON-CONFIG 5 "August 13, 2008" | ||
| 6 | 6 | .\" Please adjust this date whenever revising the manpage. | |
| 7 | 7 | .\" | |
| 8 | 8 | .\" Some roff macros, for reference: | |
@@ -16,12 +16,12 @@ | |||
| 16 | 16 | .\" .sp <n> insert n+1 empty lines | |
| 17 | 17 | .\" for manpage-specific macros, see man(7) | |
| 18 | 18 | .SH NAME | |
| 19 | - bpython.ini \- user configuration file for bpython | ||
| 19 | + config \- user configuration file for bpython | ||
| 20 | 20 | .SH SYNOPSIS | |
| 21 | - .B ~/.bpython.ini | ||
| 21 | + .B ~/.bpython/config | ||
| 22 | 22 | .SH DESCRIPTION | |
| 23 | 23 | The | |
| 24 | - .B bpython.ini | ||
| 24 | + .B config | ||
| 25 | 25 | contains various options controlling the behaviour of | |
| 26 | 26 | .B bpython | |
| 27 | 27 | . | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,8 @@ | |||
| 3 | 3 | # which stands for: | |
| 4 | 4 | # blacK, Red, Green, Yellow, Blue, Magenta, Cyan, White, Default | |
| 5 | 5 | # Capital letters represent bold | |
| 6 | - # Copy to ~/.bpython/foo.theme and set "color_scheme = foo" in ~/.bpython.ini | ||
| 6 | + # Copy to ~/.bpython/foo.theme and set "color_scheme = foo" in | ||
| 7 | + # ~/.bpython/config | ||
| 7 | 8 | ||
| 8 | 9 | [syntax] | |
| 9 | 10 | keyword = M | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,7 @@ | |||
| 1 | - | ||
| 2 | - # This is a standard python .ini file | ||
| 1 | + # This is a standard python config file | ||
| 3 | 2 | # Valid values can be True, False, integer numbers, strings | |
| 4 | - # By default bpython will look for ~/.bpython.ini or you can specify a file as | ||
| 5 | - # the first argument on the command line | ||
| 3 | + # By default bpython will look for ~/.bpython/config or you can specify a file | ||
| 4 | + # with the -c option on the command line | ||
| 6 | 5 | ||
| 7 | 6 | # General section tag | |
| 8 | 7 | [general] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ | |||
| 31 | 31 | packages = ["bpython"], | |
| 32 | 32 | data_files = [ | |
| 33 | 33 | (os.path.join(man_dir, 'man1'), ['doc/bpython.1']), | |
| 34 | - (os.path.join(man_dir, 'man5'), ['doc/bpython.ini.5']), | ||
| 34 | + (os.path.join(man_dir, 'man5'), ['doc/bpython-config.5']), | ||
| 35 | 35 | ('share/applications', ['data/bpython.desktop']) | |
| 36 | 36 | ], | |
| 37 | 37 | entry_points = { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments