def get_options_from_file(self, options):
options_file = self.python_options.get('<STR_LIT>') or self._variables.get('<STR_LIT>')<EOL>if not options_file:<EOL><INDENT>self._variables['<STR_LIT>'] = None<EOL>return<EOL><DEDENT>options_path = self._variables.get('<STR_LIT>')<EOL>options_dict, options_file_path = None, None<EOL>try:<EOL><INDENT>if options_path or os.path.isabs(options_file):<EOL><INDENT>options_file_path, options_dict = read_configuration(options_file, options_path)<EOL><DEDENT>else:<EOL><INDENT>for path in (os.getcwd(), os.path.expanduser('<STR_LIT>'), '<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>options_file_path, options_dict = read_configuration(options_file, path)<EOL>break<EOL><DEDENT>except RuntimeError as e:<EOL><INDENT>error = e<EOL><DEDENT><DEDENT><DEDENT><DEDENT>except (RuntimeError, TypeError) as e:<EOL><INDENT>self._write_error(str(e))<EOL><DEDENT>self._variables['<STR_LIT>'] = options_file_path<EOL>if options_dict:<EOL><INDENT>for k in list(self.python_options):<EOL><INDENT>default = options_dict.get(k)<EOL>if default is not None:<EOL><INDENT>options[k] = self.eval_option_value(default)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>self._write_error(str(error))<EOL><DEDENT>
Search and read a configuration file to override options.
Available formats are python, yaml and json (file extension rules).
By default, there is no configuration file and this method exits immediately.
To define a configuration file, use:
- variable OPTIONS_FILE,
- optional special parameter --options_file
search order is:
- hardcoded if file is an absolute path,
- hardcoded path in variable OPTIONS_PATH if existing,
- local directory,
- ~/.clingon/,
- /etc/clingon/,
If a configuration file is found, sets the variable
options_file_path to effective_path/effective_file.