def get_default_option_rules(): """Return the default option rules. Args: msg_func (func, optional): function to print status messages Returns: list of OptionRule. Raises: MissingFileError: If default.opts can not be found. """ default_opts_path = os.path.join(sysutil.repo_root_path(), 'etc', 'default.opts') bde_root = os.environ.get('BDE_ROOT') found_default_opts = False found_default_internal_opts = False if not os.path.isfile(default_opts_path): logutil.warn('Cannot find default.opts at %s. ' 'Trying to use $BDE_ROOT/etc/default.opts instead.' % default_opts_path) if bde_root: default_opts_path = os.path.join(bde_root, 'etc', 'default.opts') if os.path.isfile(default_opts_path): found_default_opts = True else: found_default_opts = True if not found_default_opts: raise blderror.MissingFileError('Cannot find default.opts.') option_rules = optionsparser.parse_option_rules_file(default_opts_path) if bde_root: default_internal_opts_path = os.path.join(bde_root, 'etc', 'default_internal.opts') if os.path.isfile(default_internal_opts_path): found_default_internal_opts = True option_rules += optionsparser.parse_option_rules_file( default_internal_opts_path) else: logutil.warn('The BDE_ROOT environment variable is set, ' 'but $BDE_ROOT/etc/default_internal.opts does ' 'not exist.') logutil.msg("Using default option rules from", default_opts_path) if found_default_internal_opts: logutil.msg("Using default option rules from", default_internal_opts_path) return option_rules
def get_default_option_rules(): """Return the default option rules. Args: msg_func (func, optional): function to print status messages Returns: list of OptionRule. Raises: MissingFileError: If default.opts can not be found. """ default_opts_path = os.path.join(sysutil.repo_root_path(), 'etc', 'default.opts') bde_root = os.environ.get('BDE_ROOT') found_default_opts = False found_default_internal_opts = False if not os.path.isfile(default_opts_path): logutil.warn('Cannot find default.opts at %s. ' 'Trying to use $BDE_ROOT/etc/default.opts instead.' % default_opts_path) if bde_root: default_opts_path = os.path.join(bde_root, 'etc', 'default.opts') if os.path.isfile(default_opts_path): found_default_opts = True else: found_default_opts = True if not found_default_opts: raise blderror.MissingFileError('Cannot find default.opts.') option_rules = optionsparser.parse_option_rules_file(default_opts_path) if bde_root: default_internal_opts_path = os.path.join(bde_root, 'etc', 'default_internal.opts') if os.path.isfile(default_internal_opts_path): found_default_internal_opts = True option_rules += optionsparser.parse_option_rules_file( default_internal_opts_path) else: logutil.warn('The BDE_ROOT environment variable is set, ' 'but $BDE_ROOT/etc/default_internal.opts does ' 'not exist.') logutil.msg("Using default option rules from", default_opts_path) if found_default_internal_opts: logutil.msg("Using default option rules from", default_internal_opts_path) return option_rules
def get_default_option_rules(): """Return the default option rules. Returns: list of OptionRule. Raises: MissingFileError: If default.opts can not be found. """ default_opts_path = os.path.join(sysutil.repo_root_path(), "etc", "default.opts") bde_root = os.environ.get("BDE_ROOT") found_default_opts = False found_default_internal_opts = False if not os.path.isfile(default_opts_path): logutil.warn("Cannot find default.opts at %s. " "Trying to use $BDE_ROOT/etc/default.opts instead." % default_opts_path) if bde_root: default_opts_path = os.path.join(bde_root, "etc", "default.opts") if os.path.isfile(default_opts_path): found_default_opts = True else: found_default_opts = True if not found_default_opts: raise blderror.MissingFileError("Cannot find default.opts.") option_rules = optionsparser.parse_option_rules_file(default_opts_path) if bde_root: default_internal_opts_path = os.path.join(bde_root, "etc", "default_internal.opts") if os.path.isfile(default_internal_opts_path): found_default_internal_opts = True option_rules += optionsparser.parse_option_rules_file( default_internal_opts_path) else: logutil.warn('The BDE_ROOT environment variable is set to "%s", ' 'but $BDE_ROOT/etc/default_internal.opts ("%s") does ' "not exist." % (bde_root, default_internal_opts_path)) logutil.msg("Using default option rules from", default_opts_path) if found_default_internal_opts: logutil.msg("Using default option rules from", default_internal_opts_path) return option_rules
def _load_opts(path): """Load option rules from a file. """ if os.path.isfile(path): return optionsparser.parse_option_rules_file(path) else: return []
def _load_opts(path): """Load option rules from a file. """ if os.path.isfile(path): return optionsparser.parse_option_rules_file(path) else: return []