Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da7cc9d

Browse files
committed
polish pass
1 parent e0b5ff6 commit da7cc9d

3 files changed

Lines changed: 24 additions & 25 deletions

File tree

IPython/config/application.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -525,19 +525,19 @@ def _load_config_files(cls, basefilename, path=None, log=None):
525525
filename, exc_info=True)
526526
else:
527527
log.debug("Loaded config file: %s", loader.full_filename)
528-
if config :
528+
if config:
529529
yield config
530530

531-
if not config_found :
532-
raise ConfigFileNotFound('Neither .json, not .py file found.')
531+
if not config_found:
532+
raise ConfigFileNotFound('Neither .json, nor .py config file found.')
533533
raise StopIteration
534534

535535

536536
@catch_config_error
537537
def load_config_file(self, filename, path=None):
538-
"""Load config files (json/py) by filename and path."""
538+
"""Load config files by filename and path."""
539539
filename, ext = os.path.splitext(filename)
540-
for config in self._load_config_files(filename, path=path , log=self.log):
540+
for config in self._load_config_files(filename, path=path, log=self.log):
541541
self.update_config(config)
542542

543543

IPython/config/loader.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,12 @@ def __delattr__(self, key):
292292
class ConfigLoader(object):
293293
"""A object for loading configurations from just about anywhere.
294294
295-
The resulting configuration is packaged as a :class:`Struct`.
295+
The resulting configuration is packaged as a :class:`Config`.
296296
297297
Notes
298298
-----
299299
A :class:`ConfigLoader` does one thing: load a config from a source
300-
(file, command line arguments) and returns the data as a :class:`Struct`.
300+
(file, command line arguments) and returns the data as a :class:`Config` object.
301301
There are lots of things that :class:`ConfigLoader` does not do. It does
302302
not implement complex logic for finding config files. It does not handle
303303
default values or merge multiple configs. These things need to be
@@ -324,10 +324,10 @@ def __init__(self, log=None):
324324
{}
325325
"""
326326
self.clear()
327-
if log is None :
327+
if log is None:
328328
self.log = self._log_default()
329329
self.log.debug('Using default logger')
330-
else :
330+
else:
331331
self.log = log
332332

333333
def clear(self):
@@ -375,7 +375,7 @@ class JSONFileConfigLoader(FileConfigLoader):
375375
"""A Json file loader for config"""
376376

377377
def load_config(self):
378-
"""Load the config from a file and return it as a Struct."""
378+
"""Load the config from a file and return it as a Config object."""
379379
self.clear()
380380
try:
381381
self._find_file()
@@ -386,32 +386,31 @@ def load_config(self):
386386
return self.config
387387

388388
def _read_file_as_dict(self):
389-
with open(self.full_filename) as f :
389+
with open(self.full_filename) as f:
390390
return json.load(f)
391391

392392
def _convert_to_config(self, dictionary):
393393
if 'version' in dictionary:
394394
version = dictionary.pop('version')
395-
else :
395+
else:
396396
version = 1
397-
self.log.warn("Unrecognized JSON config file version, assuming version : {}".format(version))
397+
self.log.warn("Unrecognized JSON config file version, assuming version {}".format(version))
398398

399399
if version == 1:
400400
return Config(dictionary)
401-
else :
402-
raise ValueError('Unknown version of JSON config file : version number {version}'.format(version=version))
401+
else:
402+
raise ValueError('Unknown version of JSON config file: {version}'.format(version=version))
403403

404404

405405
class PyFileConfigLoader(FileConfigLoader):
406406
"""A config loader for pure python files.
407407
408408
This is responsible for locating a Python config file by filename and
409-
profile name, then executing it in a namespace where it could have access
410-
to subconfigs.
409+
path, then executing it to construct a Config object.
411410
"""
412411

413412
def load_config(self):
414-
"""Load the config from a file and return it as a Struct."""
413+
"""Load the config from a file and return it as a Config object."""
415414
self.clear()
416415
try:
417416
self._find_file()
@@ -645,7 +644,7 @@ def load_config(self, argv=None, aliases=None, flags=None):
645644
lhs = aliases[lhs]
646645
if '.' not in lhs:
647646
# probably a mistyped alias, but not technically illegal
648-
self.log.warn("Unrecognized alias: '%s', it will probably have no effect. %s,-- %s"%(lhs,raw, aliases))
647+
self.log.warn("Unrecognized alias: '%s', it will probably have no effect.", raw)
649648
try:
650649
self._exec_config_str(lhs, rhs)
651650
except Exception:

docs/source/development/config.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ A configuration *file* is simply a mechanism for producing that object.
9090
The main IPython configuration file is a plain Python script,
9191
which can perform extensive logic to populate the config object.
9292
IPython 2.0 introduces a JSON configuration file,
93-
which is just a direct JSON serialization of the config dictionary.
94-
The JSON format is easily processed by external software.
93+
which is just a direct JSON serialization of the config dictionary,
94+
which is easily processed by external software.
9595

9696
When both Python and JSON configuration file are present, both will be loaded,
9797
with JSON configuration having higher priority.
@@ -131,7 +131,7 @@ subclass::
131131
# The rest of the class implementation would go here..
132132

133133
In this example, we see that :class:`MyClass` has three attributes, two
134-
of (``name``, ``ranking``) can be configured. All of the attributes
134+
of which (``name``, ``ranking``) can be configured. All of the attributes
135135
are given types and default values. If a :class:`MyClass` is instantiated,
136136
but not configured, these default values will be used. But let's see how
137137
to configure this class in a configuration file::
@@ -189,12 +189,12 @@ attribute of ``c`` is not the actual class, but instead is another
189189
JSON configuration Files
190190
~~~~~~~~~~~~~~~~~~~~~~~~
191191

192-
A JSON configuration file is simply a file that contain a
192+
A JSON configuration file is simply a file that contains a
193193
:class:`~IPython.config.loader.Config` dictionary serialized to JSON.
194194
A JSON configuration file has the same base name as a Python configuration file,
195-
just with a .json extension.
195+
but with a .json extension.
196196

197-
Configuration described in previous section could be written as follow in a
197+
Configuration described in previous section could be written as follows in a
198198
JSON configuration file:
199199

200200
.. sourcecode:: json

0 commit comments

Comments
 (0)