Retrieve the veto definer file and save it locally

    Parameters
    -----------
    cp : ConfigParser instance
    out_dir : path
    tags : list of strings
        Used to retrieve subsections of the ini file for
        configuration options.
169576
def save_veto_definer(cp, out_dir, tags=None):
    
    if tags is None:
        tags = []
    make_analysis_dir(out_dir)
    veto_def_url = cp.get_opt_tags("workflow-segments",
                                 "segments-veto-definer-url", tags)
    veto_def_base_name = os.path.basename(veto_def_url)
    veto_def_new_path = os.path.abspath(os.path.join(out_dir,
                                        veto_def_base_name))
    # Don't need to do this if already done
    resolve_url(veto_def_url,out_dir)

    # and update location
    cp.set("workflow-segments", "segments-veto-definer-file", veto_def_new_path)
    return veto_def_new_path
932321
def get_config_file():
    # type: () -> AnyStr
    """"""
    parser = argparse.ArgumentParser(description="Read configuration file.")
    parser.add_argument('-ini', help="Full path of configuration file")
    args = parser.parse_args()
    ini_file = args.ini
    if not FileClass.is_file_exists(ini_file):
        print("Usage: -ini <full path to the configuration file.>")
        exit(-1)
    return ini_file
1352884
def _read_config(cfg_file):
    
    config = ConfigParser()
    # maintain case of options
    config.optionxform = lambda option: option
    if not os.path.exists(cfg_file):
        # Create an empty config
        config.add_section(_MAIN_SECTION_NAME)
        config.add_section(_ENVIRONMENT_SECTION_NAME)
    else:
        config.read(cfg_file)
    return config
715807
def _parse_file_section(self, cfg_handler):
        

        _number_rxp = re.compile(r'^\d+:(.)')
        # project files configuration
        for section in cfg_handler.sections():
            if section.startswith('file:'):
                path = section[5:]
                path = _number_rxp.sub(r'\1', path)

                project_file = FileConfig(path, cfg_handler[section])

                if not project_file.date_format:
                    project_file.date_format = self.date_format

                if project_file.enabled:
                    try:
                        project_file.validate()
                    except ValueError as exc:
                        print("Incorrect configuration for file \"%s\": %s" % (project_file.filename, exc.args[0]), file=sys.stderr)
                    else:
                        self.files.append(project_file)
204024
def get_config_directory():
    
    # avoid circular import
    from .commands.stacker import Stacker
    command = Stacker()
    namespace = command.parse_args()
    return os.path.dirname(namespace.config.name)
561069
def load_cfg(self, src_dir):
        

        # last files override previous ones
        cfg_files = [os.path.expanduser(USER_CFG_FILE),
                     os.path.abspath(os.path.join(src_dir, '.dirsync'))]

        cfg = ConfigParser()
        cfg.read(cfg_files)

        if not cfg.has_section('defaults'):
            return

        defaults = {}
        for name, val in cfg.items('defaults'):
            try:
                opt = OPTIONS[name][1]
            except KeyError:
                if name == 'action':
                    if val in OPTIONS:
                        defaults['action'] = val
                    else:
                        raise ValueError('Invalid value for "action" option '
                                         'in configuration file: %s' % val)
                continue

            curdef = opt.get('default', '')
            if isinstance(curdef, bool):
                newdef = val not in ('0', 'False', 'false')
            elif isinstance(curdef, string_types):
                newdef = val
            else:
                newdef = val.strip('\n').split('\n')

            defaults[name] = newdef

        self.set_defaults(**defaults)
463783
def fromConfigFile(filename = DEFAULT_CONFIG_FILE):
    
    parser = SafeConfigParser()
    section = 'fenixedu'
    parser.read(filename)

    client_id = parser.get(section, 'client_id')
    redirect_uri = parser.get(section, 'redirect_uri')
    client_secret = parser.get(section, 'client_secret')

    base_url = parser.get(section, 'base_url')
    api_endpoint = parser.get(section, 'api_endpoint')
    api_version = parser.get(section, 'api_version')

    return FenixEduConfiguration(client_id = client_id,
                                  redirect_uri = redirect_uri,
                                  client_secret = client_secret,
                                  base_url = base_url,
                                  api_endpoint = api_endpoint,
                                  api_version = api_version)
992001
def _getConfig(general_config_dir: str = None):
    
    stp_config = STPConfig()
    plenum_config = import_module("plenum.config")
    config = stp_config
    config.__dict__.update(plenum_config.__dict__)

    if general_config_dir:
        config.GENERAL_CONFIG_DIR = general_config_dir

    if not config.GENERAL_CONFIG_DIR:
        raise Exception('GENERAL_CONFIG_DIR must be set')

    extend_with_external_config(config, (config.GENERAL_CONFIG_DIR,
                                         config.GENERAL_CONFIG_FILE))

    # "unsafe" is a set of attributes that can set certain behaviors that
    # are not safe, for example, 'disable_view_change' disables view changes
    # from happening. This might be useful in testing scenarios, but never
    # in a live network.
    if not hasattr(config, 'unsafe'):
        setattr(config, 'unsafe', set())
    return config
907441
def read_config(config_path=CONFIG_PATH):
    
    if not os.path.isfile(config_path):
        raise IOError("No config file found at %s" % config_path)
    config_parser = configparser.ConfigParser()
    config_parser.read(config_path)
    config = _config_parser_to_defaultdict(config_parser)
    return config
939426
def _parse_config_files(self, filenames=None):
        
        from setuptools.extern.six.moves.configparser import ConfigParser

        # Ignore install directory options if we have a venv
        if six.PY3 and sys.prefix != sys.base_prefix:
            ignore_options = [
                'install-base', 'install-platbase', 'install-lib',
                'install-platlib', 'install-purelib', 'install-headers',
                'install-scripts', 'install-data', 'prefix', 'exec-prefix',
                'home', 'user', 'root']
        else:
            ignore_options = []

        ignore_options = frozenset(ignore_options)

        if filenames is None:
            filenames = self.find_config_files()

        if DEBUG:
            self.announce("Distribution.parse_config_files():")

        parser = ConfigParser()
        for filename in filenames:
            with io.open(filename, encoding='utf-8') as reader:
                if DEBUG:
                    self.announce("  reading {filename}".format(**locals()))
                (parser.read_file if six.PY3 else parser.readfp)(reader)
            for section in parser.sections():
                options = parser.options(section)
                opt_dict = self.get_option_dict(section)

                for opt in options:
                    if opt != '__name__' and opt not in ignore_options:
                        val = self._try_str(parser.get(section, opt))
                        opt = opt.replace('-', '_')
                        opt_dict[opt] = (filename, val)

            # Make the ConfigParser forget everything (so we retain
            # the original filenames that options come from)
            parser.__init__()

        # If there was a "global" section in the config file, use it
        # to set Distribution options.

        if 'global' in self.command_options:
            for (opt, (src, val)) in self.command_options['global'].items():
                alias = self.negative_opt.get(opt)
                try:
                    if alias:
                        setattr(self, alias, not strtobool(val))
                    elif opt in ('verbose', 'dry_run'):  # ugh!
                        setattr(self, opt, strtobool(val))
                    else:
                        setattr(self, opt, val)
                except ValueError as msg:
                    raise DistutilsOptionError(msg)
100237
def pools_config_content_from_file(config_path)
      ini_file = IniFile.load(config_path)

      ret_val = []
      ini_file.each_section do |section|
        ret_val << [section, ini_file[section]]
      end
      ret_val
    end
904604
def gather_file_data(config):
    
    file_regex = re.compile(config['file_regex'])
    category_regex = re.compile(config['category_regex'])
    policies = {}

    for root, dirs, files in os.walk(config['c7n_policy_directory']):
        for file in files:
            if file_regex.match(file):
                file_path = root + '/' + file
                logging.debug('Processing file %s', file_path)
                with open(file_path, 'r') as stream:
                    try:
                        if category_regex.search(file_path):
                            category = 'Security & Governance'
                        else:
                            category = 'Cost Controls'

                        policies = yaml.load(stream)
                        for policy in policies['policies']:
                            logging.debug(
                                'Processing policy %s', policy['name'])
                            policy['file_url'] = get_file_url(
                                file_path, config)
                            resource_type = policy['resource']
                            if category not in c7n_data:
                                c7n_data[category] = {}
                            if resource_type not in c7n_data[category]:
                                c7n_data[category][resource_type] = []
                            c7n_data[category][resource_type].append(policy)
                    except yaml.YAMLError as exc:
                        logging.error(exc)
314904
def search_configuration_files(findstr, replacestr = None):
    ''''''

    F = open(configurationFilesLocation, "r")
    lines = F.readlines()
    F.close()
    allerrors = {}
    alloutput = {}

    for line in lines:
        line = line.strip()
        if line:
            if line.endswith("generate_fragments.py"):
                # Do not parse the Python script but check that it exists
                if not(os.path.exists(line)):
                    allerrors[line] = "File/directory %s does not exist." % line
            else:
                cmd = ["grep", "-n", "-i",  findstr, line]
                output = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
                errors = output[1]
                output = output[0]
                if errors:
                    errors = errors.strip()
                    allerrors[line] = errors
                if output:
                    output = output.strip()
                    alloutput[line] = output.split("\n")
    return alloutput, allerrors
1016322
def _cfgs_to_read(self):
        
        # use these files to extend/overwrite the conf_values.
        # Last red file always overwrites existing values!
        cfg = Config.DEFAULT_CONFIG_FILE_NAME
        filenames = [
            self.default_config_file,
            cfg,  # conf_values in current directory
            os.path.join(os.path.expanduser('~' + os.path.sep), cfg),  # config in user dir
            '.pyemma.cfg',
        ]

        # look for user defined files
        if self.cfg_dir:
            from glob import glob
            filenames.extend(glob(self.cfg_dir + os.path.sep + "*.cfg"))
        return filenames
1145952
def locate_config(self):
        '''  '''
        for f in self.__potential:
            f = FileHelper.abspath(f)
            if os.path.isfile(f):
                return f
        return None
922373
def save_config(self, out_file_name):
        

        def get_hidden_parameter(item):

            numer_of_sub_elements = item.childCount()

            if numer_of_sub_elements == 0:
                dictator = {item.name : item.visible}
            else:
                dictator = {item.name:{}}
                for child_id in range(numer_of_sub_elements):
                    dictator[item.name].update(get_hidden_parameter(item.child(child_id)))
            return dictator

        out_file_name = str(out_file_name)
        if not os.path.exists(os.path.dirname(out_file_name)):
            os.makedirs(os.path.dirname(out_file_name))

        # build a dictionary for the configuration of the hidden parameters
        dictator = {}
        for index in range(self.tree_scripts.topLevelItemCount()):
            script_item = self.tree_scripts.topLevelItem(index)
            dictator.update(get_hidden_parameter(script_item))

        dictator = {"gui_settings": self.gui_settings, "scripts_hidden_parameters":dictator}

        # update the internal dictionaries from the trees in the gui
        for index in range(self.tree_scripts.topLevelItemCount()):
            script_item = self.tree_scripts.topLevelItem(index)
            self.update_script_from_item(script_item)

        dictator.update({'instruments': {}, 'scripts': {}, 'probes': {}})

        for instrument in self.instruments.values():
            dictator['instruments'].update(instrument.to_dict())
        for script in self.scripts.values():
            dictator['scripts'].update(script.to_dict())

        for instrument, probe_dict in self.probes.items():
            dictator['probes'].update({instrument: ','.join(list(probe_dict.keys()))})

        with open(out_file_name, 'w') as outfile:
            tmp = json.dump(dictator, outfile, indent=4)
778958
private Path getSplitPath(FileSplit inputSplit, JobConf conf) throws IOException {
    Path path = inputSplit.getPath();
    if (inputSplit instanceof OrcSplit) {
      OrcSplit orcSplit = (OrcSplit) inputSplit;
      List<Long> deltas = orcSplit.getDeltas();
      if (!orcSplit.hasBase() && deltas.size() >= 2) {
        throw new IOException("Cannot read valid StructTypeInfo from delta only file: " + path);
      }
    }
    LOG.debug("Input split path: {}", path);
    return path;
  }