Skip to content

Commit e9537df

Browse files
authored
Merge pull request #147 from level12/106-config-resolution-permissions
Ignore non-existent or inaccessible files in config discovery
2 parents 295f5df + c65b963 commit e9537df

File tree

8 files changed

+258
-323
lines changed

8 files changed

+258
-323
lines changed

keg/cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ def config_command():
126126
for val in config.config_file_paths():
127127
click.echo(' {}'.format(val))
128128

129+
if config.config_paths_unreadable:
130+
click.echo(_('Could not access the following config paths:'))
131+
for path, exc in config.config_paths_unreadable:
132+
click.echo(' {}: {}'.format(path, str(exc)))
133+
129134
click.echo(_('Config objects used:'))
130135
for val in config.configs_found:
131136
click.echo(' {}'.format(val))

keg/config.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,19 @@ def init_app(self, app_config_profile, app_import_name, app_root_path, use_test_
6565
self.dirs = appdirs.AppDirs(app_import_name, appauthor=False, multipath=True)
6666
self.app_import_name = app_import_name
6767
self.app_root_path = app_root_path
68+
self.config_paths_unreadable = []
6869

6970
if config_file_objs:
7071
self.config_file_objs = config_file_objs
7172
else:
73+
self.config_file_objs = []
7274
possible_config_fpaths = self.config_file_paths()
73-
self.config_file_objs = pymodule_fpaths_to_objects(possible_config_fpaths)
75+
fpaths_to_objects = pymodule_fpaths_to_objects(possible_config_fpaths)
76+
for fpath, objects, exc in fpaths_to_objects:
77+
if objects is None:
78+
self.config_paths_unreadable.append((fpath, exc))
79+
else:
80+
self.config_file_objs.append((fpath, objects))
7481

7582
if self.profile is None:
7683
self.profile = self.determine_selected_profile()

keg/i18n/es/LC_MESSAGES/keg.mo

-3.24 KB
Binary file not shown.

0 commit comments

Comments
 (0)