(root)
return cfg
Read the project setup.cfg file to determine Versioneer config.
Read the project setup.cfg file to determine Versioneer config.
Read the project setup . cfg file to determine Versioneer config .
def get_config_from_root(root):
    """Read the project setup.cfg file to determine Versioneer config."""
    # This might raise EnvironmentError (if setup.cfg is missing), or
    # configparser.NoSectionError (if it lacks a [versioneer] section), or
    # configparser.NoOptionError (if it lacks "VCS="). See the docstring at
    # the top of versioneer.py for instructions on writing your setup.cfg .
    setup_cfg = os.path.join(root, "setup.cfg")
    parser = configparser.SafeConfigParser()
    with open(setup_cfg, "r") as f:
        parser.readfp(f)
    VCS = parser.get("versioneer", "VCS")  # mandatory

    def get(parser, name):
        if parser.has_option("versioneer", name):
            return parser.get("versioneer", name)
        return None

    cfg = VersioneerConfig()
    cfg.VCS = VCS
    cfg.style = get(parser, "style") or ""
    cfg.versionfile_source = get(parser, "versionfile_source")
    cfg.versionfile_build = get(parser, "versionfile_build")
    cfg.tag_prefix = get(parser, "tag_prefix")
    if cfg.tag_prefix in ("''", '""'):
        cfg.tag_prefix = ""
    cfg.parentdir_prefix = get(parser, "parentdir_prefix")
    cfg.verbose = get(parser, "verbose")
    return cfg
def get_config_from_root ( root ) : # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os . path . join ( root , "setup.cfg" ) parser = configparser . SafeConfigParser ( ) with open ( setup_cfg , "r" ) as f : parser . readfp ( f ) VCS = parser . get ( "versioneer" , "VCS" ) # mandatory def get ( parser , name ) : if parser . has_option ( "versioneer" , name ) : return parser . get ( "versioneer" , name ) return None cfg = VersioneerConfig ( ) cfg . VCS = VCS cfg . style = get ( parser , "style" ) or "" cfg . versionfile_source = get ( parser , "versionfile_source" ) cfg . versionfile_build = get ( parser , "versionfile_build" ) cfg . tag_prefix = get ( parser , "tag_prefix" ) if cfg . tag_prefix in ( "''" , '""' ) : cfg . tag_prefix = "" cfg . parentdir_prefix = get ( parser , "parentdir_prefix" ) cfg . verbose = get ( parser , "verbose" ) return cfg