Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

swh:1:snp:fd22f80b54ad40aa01ea8be83f3828c1228d614f
  • Code
  • Branches (1)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    No releases to show
  • 707fda0
  • /
  • gsdeformer
  • /
  • utils_config.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
content badge
swh:1:cnt:0552592651fdde6c1d8932248e0dbc80c32d307c
directory badge
swh:1:dir:5e59cb9591658b084a01b862dbe7631b767a4fd0
revision badge
swh:1:rev:2eb7f6d3bf60cacd4f3969a9d68949cb3a34da95
snapshot badge
swh:1:snp:fd22f80b54ad40aa01ea8be83f3828c1228d614f

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 2eb7f6d3bf60cacd4f3969a9d68949cb3a34da95 authored by jhuangBU on 10 May 2026, 11:43:06 UTC
doc: revise README
Tip revision: 2eb7f6d
utils_config.py
import argparse
from pathlib import Path
from typing import TypeVar, Type, List, cast

from omegaconf import OmegaConf

T = TypeVar("T")


def parse_args(ctype: Type[T], args=None) -> T:
    """
    CLI interface function for laod_config
    sample: python test.py --config conf.yaml test.a=1 test.b=false
    """
    parser = argparse.ArgumentParser()
    parser.add_argument("--config", type=Path, default=None, help="yaml config file")
    parser.add_argument("overrides", nargs="*", default=[], help="config file overrides")
    args = parser.parse_args(args)
    return load_config(ctype, args.config, args.overrides)


def load_config(ctype: Type[T], config: Path, overrides: List[str]) -> T:
    """
    load configuration from yaml config file & CLI overrides, based on CLI input
    precedence: CLI override > yaml config > dataclass default
    """
    confs = []
    confs.append(OmegaConf.structured(ctype))
    if config:
        confs.append(OmegaConf.load(config))
    if overrides:
        confs.append(OmegaConf.from_dotlist(overrides))
    conf = OmegaConf.merge(*confs)
    return cast(T, conf)

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API