class_docstr: Thin wrapper around `git-config` with support for a dataset configuration.
  
  The general idea is to have an object that is primarily used to read/query
  configuration option.  Upon creation, current configuration is read via one
  (or max two, in the case of the presence of dataset-specific configuration)
  calls to `git config`.  If this class is initialized with a Dataset
  instance, it supports reading and writing configuration from
  ``.datalad/config`` inside a dataset too. This file is committed to Git and
  hence useful to ship certain configuration items with a dataset.
  
  The API aims to provide the most significant read-access API of a
  dictionary, the Python ConfigParser, and GitPython's config parser
  implementations.
  
  This class is presently not capable of efficiently writing multiple
  configurations items at once.  Instead, each modification results in a
  dedicated call to `git config`. This author thinks this is OK, as he
  cannot think of a situation where a large number of items need to be
  written during normal operation.
  
  Each instance carries a public `overrides` attribute. This dictionary
  contains variables that override any setting read from a file. The overrides
  are persistent across reloads.
  
  Any DATALAD_* environment variable is also presented as a configuration
  item. Settings read from environment variables are not stored in any of the
  configuration files, but are read dynamically from the environment at each
  `reload()` call. Their values take precedence over any specification in
  configuration files, and even overrides.
  
  Parameters
  ----------
  dataset : Dataset, optional
    If provided, all `git config` calls are executed in this dataset's
    directory. Moreover, any modifications are, by default, directed to
    this dataset's configuration file (which will be created on demand)
  overrides : dict, optional
    Variable overrides, see general class documentation for details.
  source : {'any', 'local', 'branch', 'branch-local'}, optional
    Which sources of configuration setting to consider. If 'branch',
    configuration items are only read from a dataset's persistent
    configuration file in current branch, if any is present
    (the one in ``.datalad/config``, not
    ``.git/config``); if 'local', any non-committed source is considered
    (local and global configuration in Git config's terminology);
    if 'branch-local', persistent configuration in current dataset branch
    and local, but not global or system configuration are considered; if 'any'
    all possible sources of configuration are considered.
    Note: 'dataset' and 'dataset-local' are deprecated in favor of 'branch'
    and 'branch-local'.
class_docstr_tok: ["Thin","wrapper","around","`","git-config","`","with","support","for","a","dataset","configuration",".","The","general","idea","is","to","have","an","object","that","is","primarily","used","to","read\/query","configuration","option",".","Upon","creation",",","current","configuration","is","read","via","one","(","or","max","two",",","in","the","case","of","the","presence","of","dataset-specific","configuration",")","calls","to","`","git","config","`",".","If","this","class","is","initialized","with","a","Dataset","instance",",","it","supports","reading","and","writing","configuration","from","``",".datalad\/config","``","inside","a","dataset","too",".","This","file","is","committed","to","Git","and","hence","useful","to","ship","certain","configuration","items","with","a","dataset",".","The","API","aims","to","provide","the","most","significant","read-access","API","of","a","dictionary",",","the","Python","ConfigParser",",","and","GitPython","'s","config","parser","implementations",".","This","class","is","presently","not","capable","of","efficiently","writing","multiple","configurations","items","at","once",".","Instead",",","each","modification","results","in","a","dedicated","call","to","`","git","config","`",".","This","author","thinks","this","is","OK",",","as","he","can","not","think","of","a","situation","where","a","large","number","of","items","need","to","be","written","during","normal","operation",".","Each","instance","carries","a","public","`","overrides","`","attribute",".","This","dictionary","contains","variables","that","override","any","setting","read","from","a","file",".","The","overrides","are","persistent","across","reloads",".","Any","DATALAD_","*","environment","variable","is","also","presented","as","a","configuration","item",".","Settings","read","from","environment","variables","are","not","stored","in","any","of","the","configuration","files",",","but","are","read","dynamically","from","the","environment","at","each","`","reload","(",")","`","call",".","Their","values","take","precedence","over","any","specification","in","configuration","files",",","and","even","overrides",".","Parameters","--","--","--","--","--","dataset",":","Dataset",",","optional","If","provided",",","all","`","git","config","`","calls","are","executed","in","this","dataset's","directory",".","Moreover",",","any","modifications","are",",","by","default",",","directed","to","this","dataset","'s","configuration","file","(","which","will","be","created","on","demand",")","overrides",":","dict",",","optional","Variable","overrides",",","see","general","class","documentation","for","details",".","source",":","{","'any","'",",","'local","'",",","'branch","'",",","'branch-local","'","}",",","optional","Which","sources","of","configuration","setting","to","consider",".","If","'branch","'",",","configuration","items","are","only","read","from","a","dataset","'s","persistent","configuration","file","in","current","branch",",","if","any","is","present","(","the","one","in","``",".datalad\/config","``",",","not","``",".git\/config","``",")",";","if","'local","'",",","any","non-committed","source","is","considered","(","local","and","global","configuration","in","Git","config","'s","terminology",")",";","if","'branch-local","'",",","persistent","configuration","in","current","dataset","branch","and","local",",","but","not","global","or","system","configuration","are","considered",";","if","'any'","all","possible","sources","of","configuration","are","considered",".","Note",":","'dataset","'","and","'dataset-local","'","are","deprecated","in","favor","of","'branch'","and","'branch-local","'","."]
docstr: Like `get()`, but with an optional default value
  
  If the default is not None, the given default value will be returned in
  case the option did not exist. This behavior imitates GitPython's
  config parser.
docstr_tok: ["Like","`","get","(",")","`",",","but","with","an","optional","default","value","If","the","default","is","not","None",",","the","given","default","value","will","be","returned","in","case","the","option","did","not","exist",".","This","behavior","imitates","GitPython's","config","parser","."]
code: def get_value(self, section, option, default=None):
      """Like `get()`, but with an optional default value
  
      If the default is not None, the given default value will be returned in
      case the option did not exist. This behavior imitates GitPython's
      config parser.
      """
      try:
          return self[".".join((section, option))]
      except KeyError as e:
          # this strange dance is needed because gitpython does it this way
          if default is not None:
              return default
          else:
              raise e
  
imports: import json
  import logging
  import os
  import re
  import threading
  import warnings
  from collections import namedtuple
  from fasteners import InterProcessLock
  from functools import lru_cache, wraps
  from pathlib import Path
  import datalad
  from datalad.consts import DATASET_CONFIG_FILE
  from datalad.runner import CommandError, GitRunner, KillOutput, StdOutErrCapture
  from datalad.utils import getpwd, on_windows
label_desc: Use image node_id 24 for calling the ConfigManager obj's underlying member method code with example usage: obj.get_value(section, option, default) and returns: self, default