Encode `conf_dict` to string.
183656
def _encode_config(conf_dict):
    """"""
    out = []

    # get variables in order defined in settings._ALLOWED_MERGES
    for var in settings._ALLOWED_MERGES:
        out.append(conf_dict[var])

    # convert bools to chars
    out = map(
        lambda x: "t" if x else "f",
        out
    )

    return "".join(out)
322576
def _deflate(cls):
        """"""
        data = {k: v for k, v in vars(cls).items() if not k.startswith("_")}
        return {Constants.CONFIG_KEY: data}
701617
def dict_conf(filename):
  

  f, ext = os.path.splitext(filename)
  ext = ext.lower()

  if ext == "conf" or ext == "ini":
    # python config via config parser

    config = ConfigParser()
    config.optionxform=str
    config.read(filename)
    rv = {}
    for section in config.sections():
      rv[section] = {}
      for key,value in config.items(section):
        rv[section][key] = value.strip('"').strip("'").decode("string_escape")
    return rv
  else:
    # other type of config, use munge
    if munge_config:
      src = munge_config.parse_url(filename)
      return src.cls().load(open(filename)).get("vodka")
    else:
      raise Exception("'%s' type of config encountered, install munge" % ext)
1147292
def from_dict(self, d):
        
        for key in d:
            if key == 'data':
                for dkey in d['data']:
                    if dkey in self._encode_fields:
                        setattr(self, str(dkey), base64.b64decode(d['data'][dkey]))
                    else:
                        setattr(self, str(dkey), d['data'][dkey])
            else:
                setattr(self, str(key), d[key])
711644
def _encode_dict_as_string(value):
        """"""
        # Strip the first and last newlines
        if value.startswith("{\n"):
            value = "{" + value[2:]
        if value.endswith("\n}"):
            value = value[:-2] + "}"
        # escape double quotes and newlines
        return value.replace('"', '\\"').replace("\\n", "\\\\n").replace("\n", "\\n")
16282
def from_dict(cls, d):
        
        conf = {}
        for k in d["config"]:
            v = d["config"][k]
            if isinstance(v, dict):
                conf[str(k)] = get_dict_handler(d["config"]["type"])(v)
            else:
                conf[str(k)] = v
        return get_class(str(d["class"]))(config=conf)
123282
def normalize_conf(conf):
    '''
    '''
    conf = conf.copy()
    # check for type error
    check_config(conf)
    # convert some fileds into python suitable format
    from_json_format(conf)
    if 'dmode' not in conf:
        conf['dmode'] = calc_dir_mode(conf['fmode'])
    return conf
205719
def to_argv(config):
    """"""
    argv = []
    for k, v in config.items():
        if "-" in k:
            raise ValueError("Use '_' instead of '-' in `{}`".format(k))
        if v is None:
            continue
        if not isinstance(v, bool) or v:  # for argparse flags
            argv.append("--{}".format(k.replace("_", "-")))
        if isinstance(v, string_types):
            argv.append(v)
        elif isinstance(v, bool):
            pass
        else:
            argv.append(json.dumps(v, cls=_SafeFallbackEncoder))
    return argv
360611
def conv_dict(self):
        """"""
        return dict(integer=self.integer, real=self.real, no_type=self.no_type)
676496
def __convert_env(env, encoding):
    """"""
    d = dict(os.environ, **(oget(env, {})))

    # workaround for Windows+Python3 environment
    if not SHOULD_NOT_ENCODE_ARGS:
        return dict((k.encode(encoding), v.encode(encoding)) for k, v in d.items())
    else:
        return d
642392
function encodeConfig(output, config) {
    var result = {
        values: config.getValues().toJS(),

        get: function(key, defaultValue) {
            return objectPath.get(result.values, key, defaultValue);
        },

        set: function(key, value) {
            return objectPath.set(result.values, key, value);
        }
    };

    deprecate.field(output, 'config.options', result, 'options',
        result.values, '"config.options" property is deprecated, use "config.get(key)" instead');

    deprecate.field(output, 'config.options.generator', result.values, 'generator',
        output.getGenerator(), '"options.generator" property is deprecated, use "output.name" instead');

    deprecate.field(output, 'config.options.generator', result.values, 'output',
        output.getRoot(), '"options.output" property is deprecated, use "output.root()" instead');

    return result;
}
335734
def _encode_request(self, request):
        """"""
        return pickle.dumps(request_to_dict(request, self.spider), protocol=-1)
628500
def get_configuration_dict(self, secret_attrs=False):
        """"""
        rd = {'name': self.name,
              'path': self.path,
              'git_dir': self.git_dir,
              'assumed_doc_version': self.assumed_doc_version,
              'doc_dir': self.doc_dir,
              'git_ssh': self.git_ssh, }
        if secret_attrs:
            rd['pkey'] = self.pkey
        with self._index_lock:
            si = self._doc_index
        r = _invert_dict_list_val(si)
        key_list = list(r.keys())
        rd['number of documents'] = len(key_list)
        key_list.sort()
        m = []
        for k in key_list:
            v = r[k]
            fp = k[2]
            assert fp.startswith(self.doc_dir)
            rp = fp[len(self.doc_dir) + 1:]
            m.append({'keys': v, 'relpath': rp})
        rd['documents'] = m
        return rd
276180
def get_config_string(params, units=None):
    
    compact_str_items = []
    # first make a list of compact strings for each parameter
    for k, v in params.items():
        unit = ""
        if isinstance(units, dict): #check if not None not enough, units could be mocked which causes errors
            unit = units.get(k, "")
        compact_str_items.append(k + "=" + str(v) + unit)
    # and finally join them
    compact_str = ", ".join(compact_str_items)
    return compact_str
331116
def pretty_dict_str(d, indent=2):
    """"""
    b = StringIO()
    write_pretty_dict_str(b, d, indent=indent)
    return b.getvalue()
228121
def to_dict(self):
        """"""
        config = {}
        for attr in dir(self):
            if not attr.startswith('_'):
                value = getattr(self, attr)
                if not hasattr(value, '__call__'):
                    config[attr] = value
        return config
599059
def _decode_config(conf_str):
    
    conf_str = conf_str.strip()

    # convert "tttff" -> [True, True, True, False, False]
    conf = map(
        lambda x: True if x.upper() == "T" else False,
        list(conf_str)
    )

    return dict(zip(settings._ALLOWED_MERGES, conf))