Skip to content

sync

Sync selected metadata files with given input file.

sync

sync(somesy_input: SomesyInput)

Sync selected metadata files with given input file.

Source code in src/somesy/commands/sync.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def sync(somesy_input: SomesyInput):
    """Sync selected metadata files with given input file."""
    conf, metadata = somesy_input.config, somesy_input.project

    pp_metadata = pretty_repr(metadata.model_dump(exclude_defaults=True))
    logger.debug(f"Project metadata: {pp_metadata}")

    # update these only if they exist:

    if conf.pyproject_file.is_file() and not conf.no_sync_pyproject:
        _sync_file(metadata, conf.pyproject_file, Pyproject)

    if conf.package_json_file.is_file() and not conf.no_sync_package_json:
        _sync_file(metadata, conf.package_json_file, PackageJSON)

    if conf.julia_file.is_file() and not conf.no_sync_julia:
        _sync_file(metadata, conf.julia_file, Julia)

    if conf.fortran_file.is_file() and not conf.no_sync_fortran:
        _sync_file(metadata, conf.fortran_file, Fortran)

    if conf.pom_xml_file.is_file() and not conf.no_sync_pom_xml:
        _sync_file(metadata, conf.pom_xml_file, POM)

    if conf.mkdocs_file.is_file() and not conf.no_sync_mkdocs:
        _sync_file(metadata, conf.mkdocs_file, MkDocs)

    if conf.rust_file.is_file() and not conf.no_sync_rust:
        _sync_file(metadata, conf.rust_file, Rust)

    # create these by default if they are missing:
    if not conf.no_sync_cff:
        _sync_file(metadata, conf.cff_file, CFF)

    if not conf.no_sync_codemeta:
        _sync_file(metadata, conf.codemeta_file, CodeMeta)