@@ -109,10 +109,10 @@ def _log_level_changed(self, name, old, new):
109109 new = getattr (logging , new )
110110 self .log_level = new
111111 self .log .setLevel (new )
112-
112+
113113 # the alias map for configurables
114114 aliases = Dict ({'log-level' : 'Application.log_level' })
115-
115+
116116 # flags for loading Configurables or store_const style flags
117117 # flags are loaded from this dict by '--key' flags
118118 # this must be a dict of two-tuples, the first element being the Config/dict
@@ -124,28 +124,28 @@ def _flags_changed(self, name, old, new):
124124 assert len (value ) == 2 , "Bad flag: %r:%s" % (key ,value )
125125 assert isinstance (value [0 ], (dict , Config )), "Bad flag: %r:%s" % (key ,value )
126126 assert isinstance (value [1 ], basestring ), "Bad flag: %r:%s" % (key ,value )
127-
128-
127+
128+
129129 # subcommands for launching other applications
130130 # if this is not empty, this will be a parent Application
131- # this must be a dict of two-tuples,
131+ # this must be a dict of two-tuples,
132132 # the first element being the application class/import string
133133 # and the second being the help string for the subcommand
134134 subcommands = Dict ()
135135 # parse_command_line will initialize a subapp, if requested
136136 subapp = Instance ('IPython.config.application.Application' , allow_none = True )
137-
137+
138138 # extra command-line arguments that don't set config values
139139 extra_args = List (Unicode )
140-
140+
141141
142142 def __init__ (self , ** kwargs ):
143143 SingletonConfigurable .__init__ (self , ** kwargs )
144144 # Ensure my class is in self.classes, so my attributes appear in command line
145145 # options and config files.
146146 if self .__class__ not in self .classes :
147147 self .classes .insert (0 , self .__class__ )
148-
148+
149149 self .init_logging ()
150150
151151 def _config_changed (self , name , old , new ):
@@ -157,7 +157,7 @@ def init_logging(self):
157157 """Start logging for this application.
158158
159159 The default is to log to stdout using a StreaHandler. The log level
160- starts at loggin.WARN, but this can be adjusted by setting the
160+ starts at loggin.WARN, but this can be adjusted by setting the
161161 ``log_level`` attribute.
162162 """
163163 self .log = logging .getLogger (self .__class__ .__name__ )
@@ -174,36 +174,36 @@ def init_logging(self):
174174
175175 def initialize (self , argv = None ):
176176 """Do the basic steps to configure me.
177-
177+
178178 Override in subclasses.
179179 """
180180 self .parse_command_line (argv )
181-
182-
181+
182+
183183 def start (self ):
184184 """Start the app mainloop.
185-
185+
186186 Override in subclasses.
187187 """
188188 if self .subapp is not None :
189189 return self .subapp .start ()
190-
190+
191191 def print_alias_help (self ):
192192 """Print the alias part of the help."""
193193 if not self .aliases :
194194 return
195-
195+
196196 lines = []
197197 classdict = {}
198198 for cls in self .classes :
199199 # include all parents (up to, but excluding Configurable) in available names
200200 for c in cls .mro ()[:- 3 ]:
201201 classdict [c .__name__ ] = c
202-
202+
203203 for alias , longname in self .aliases .iteritems ():
204204 classname , traitname = longname .split ('.' ,1 )
205205 cls = classdict [classname ]
206-
206+
207207 trait = cls .class_traits (config = True )[traitname ]
208208 help = cls .class_get_trait_help (trait ).splitlines ()
209209 # reformat first line
@@ -213,20 +213,20 @@ def print_alias_help(self):
213213 lines .extend (help )
214214 # lines.append('')
215215 print os .linesep .join (lines )
216-
216+
217217 def print_flag_help (self ):
218218 """Print the flag part of the help."""
219219 if not self .flags :
220220 return
221-
221+
222222 lines = []
223223 for m , (cfg ,help ) in self .flags .iteritems ():
224224 prefix = '--' if len (m ) > 1 else '-'
225225 lines .append (prefix + m )
226226 lines .append (indent (dedent (help .strip ())))
227227 # lines.append('')
228228 print os .linesep .join (lines )
229-
229+
230230 def print_options (self ):
231231 if not self .flags and not self .aliases :
232232 return
@@ -240,12 +240,12 @@ def print_options(self):
240240 self .print_flag_help ()
241241 self .print_alias_help ()
242242 print
243-
243+
244244 def print_subcommands (self ):
245245 """Print the subcommand part of the help."""
246246 if not self .subcommands :
247247 return
248-
248+
249249 lines = ["Subcommands" ]
250250 lines .append ('-' * len (lines [0 ]))
251251 lines .append ('' )
@@ -258,15 +258,15 @@ def print_subcommands(self):
258258 lines .append (indent (dedent (help .strip ())))
259259 lines .append ('' )
260260 print os .linesep .join (lines )
261-
261+
262262 def print_help (self , classes = False ):
263263 """Print the help for each Configurable class in self.classes.
264-
264+
265265 If classes=False (the default), only flags and aliases are printed.
266266 """
267267 self .print_subcommands ()
268268 self .print_options ()
269-
269+
270270 if classes :
271271 if self .classes :
272272 print "Class parameters"
@@ -275,7 +275,7 @@ def print_help(self, classes=False):
275275 for p in wrap_paragraphs (self .keyvalue_description ):
276276 print p
277277 print
278-
278+
279279 for cls in self .classes :
280280 cls .class_print_help ()
281281 print
@@ -315,21 +315,21 @@ def update_config(self, config):
315315 # Save the combined config as self.config, which triggers the traits
316316 # events.
317317 self .config = newconfig
318-
318+
319319 def initialize_subcommand (self , subc , argv = None ):
320320 """Initialize a subcommand with argv."""
321321 subapp ,help = self .subcommands .get (subc )
322-
322+
323323 if isinstance (subapp , basestring ):
324324 subapp = import_item (subapp )
325-
325+
326326 # clear existing instances
327327 self .__class__ .clear_instance ()
328328 # instantiate
329329 self .subapp = subapp .instance ()
330330 # and initialize subapp
331331 self .subapp .initialize (argv )
332-
332+
333333 def parse_command_line (self , argv = None ):
334334 """Parse the command line arguments."""
335335 argv = sys .argv [1 :] if argv is None else argv
@@ -340,7 +340,7 @@ def parse_command_line(self, argv=None):
340340 if re .match (r'^\w(\-?\w)*$' , subc ) and subc in self .subcommands :
341341 # it's a subcommand, and *not* a flag or class parameter
342342 return self .initialize_subcommand (subc , subargv )
343-
343+
344344 if '-h' in argv or '--help' in argv or '--help-all' in argv :
345345 self .print_description ()
346346 self .print_help ('--help-all' in argv )
@@ -350,7 +350,7 @@ def parse_command_line(self, argv=None):
350350 if '--version' in argv :
351351 self .print_version ()
352352 self .exit (0 )
353-
353+
354354 loader = KVArgParseConfigLoader (argv = argv , aliases = self .aliases ,
355355 flags = self .flags )
356356 try :
@@ -383,7 +383,7 @@ def load_config_file(self, filename, path=None):
383383 else :
384384 self .log .debug ("Loaded config file: %s" , loader .full_filename )
385385 self .update_config (config )
386-
386+
387387 def generate_config_file (self ):
388388 """generate default config file from Configurables"""
389389 lines = ["# Configuration file for %s." % self .name ]
@@ -404,10 +404,10 @@ def exit(self, exit_status=0):
404404
405405def boolean_flag (name , configurable , set_help = '' , unset_help = '' ):
406406 """Helper for building basic --trait, --no-trait flags.
407-
407+
408408 Parameters
409409 ----------
410-
410+
411411 name : str
412412 The name of the flag.
413413 configurable : str
@@ -416,20 +416,20 @@ def boolean_flag(name, configurable, set_help='', unset_help=''):
416416 help string for --name flag
417417 unset_help : unicode
418418 help string for --no-name flag
419-
419+
420420 Returns
421421 -------
422-
422+
423423 cfg : dict
424424 A dict with two keys: 'name', and 'no-name', for setting and unsetting
425425 the trait, respectively.
426426 """
427427 # default helpstrings
428428 set_help = set_help or "set %s=True" % configurable
429429 unset_help = unset_help or "set %s=False" % configurable
430-
430+
431431 cls ,trait = configurable .split ('.' )
432-
432+
433433 setter = {cls : {trait : True }}
434434 unsetter = {cls : {trait : False }}
435435 return {name : (setter , set_help ), 'no-' + name : (unsetter , unset_help )}
0 commit comments