Read the project setup.cfg file to determine Versioneer config.
(root)
| 336 | |
| 337 | |
| 338 | def get_config_from_root(root): |
| 339 | """Read the project setup.cfg file to determine Versioneer config.""" |
| 340 | # This might raise OSError (if setup.cfg is missing), or |
| 341 | # configparser.NoSectionError (if it lacks a [versioneer] section), or |
| 342 | # configparser.NoOptionError (if it lacks "VCS="). See the docstring at |
| 343 | # the top of versioneer.py for instructions on writing your setup.cfg . |
| 344 | setup_cfg = os.path.join(root, "setup.cfg") |
| 345 | parser = configparser.ConfigParser() |
| 346 | with open(setup_cfg, "r") as cfg_file: |
| 347 | parser.read_file(cfg_file) |
| 348 | VCS = parser.get("versioneer", "VCS") # mandatory |
| 349 | |
| 350 | # Dict-like interface for non-mandatory entries |
| 351 | section = parser["versioneer"] |
| 352 | |
| 353 | cfg = VersioneerConfig() |
| 354 | cfg.VCS = VCS |
| 355 | cfg.style = section.get("style", "") |
| 356 | cfg.versionfile_source = section.get("versionfile_source") |
| 357 | cfg.versionfile_build = section.get("versionfile_build") |
| 358 | cfg.tag_prefix = section.get("tag_prefix") |
| 359 | if cfg.tag_prefix in ("''", '""', None): |
| 360 | cfg.tag_prefix = "" |
| 361 | cfg.parentdir_prefix = section.get("parentdir_prefix") |
| 362 | cfg.verbose = section.get("verbose") |
| 363 | return cfg |
| 364 | |
| 365 | |
| 366 | class NotThisMethod(Exception): |
no test coverage detected
searching dependent graphs…