Package: conhead
Consistent header management.CLI tool for applying and maintaining consistent headers across source
files.Add headers to files that don’t have them.Update fields in files that already have them.Maintain different header configurations for different file
typesInstallationConhead is available as the Pythonconheadpackage.For example, to install usingpipx:$pipxinstallconhead$conhead--helpUsage:conhead[OPTIONS]SRCConfigurationConfigureconheadviapyproject.toml. Each header template
is configured via a separate[tools.conhead.header.<name>]section. Each section is a header definition and can be applied
to one or more file extensions.Example:[tools.conhead.header.hashhead]extensions=['py','toml','yaml']template="""
    # Copyright {{YEARS}} Organized Organization
    # SPDX-License-Identifier: Apache-2.0

"""[tools.conhead.header.slashhead]extensions=['c','cpp','java']template="""
    // Copyright {{YEARS}} Organized Organization
    // SPDX-License-Identifier: Apache-2.0

"""Template DefinitionA few things to note about the template definition.Each TOMLtools.conhead.headersection has a few options:extensions:A list of extensions that the header definition
applies to.template:The header template for this header definition.
This is the text that is applied to files that have the
indicated extensions.Header TemplatesNotice a few things about the header template.The text of the template is indented for better readability
withing thepyproject.tomlconfiguration file, howeverconheadde-indents this text for you.The template contains a field that is kept up to date in
the target source file. In this case the{{YEARS}}field
writes the current year into every new template. If a file
already contains a header with the year in it, and the year
is different from the current year, it is updated to show
a range of years. For example, a new template would have
the{{YEARS}}field replaced with2020if it was
first written in2020. When the header is then updated
in2022, this field is rewritten as2020-2022.If you need to write some text that contains certain
characters used to describe fields, you must escape them.
Examples are\{,\}and\\. These characters will
appear in the rendered header without the preceding slash.UsageLet’s say there is a python file without a header athello.py:defhello():print("Greetings!")You can apply thehashheadheader template defined inpyproject.tomland view the results by:$conheadhello.pyWARNING:missingheader:hello.py$cathello.py# Copyright 2022 Organized Organization
# SPDX-License-Identifier: Apache-2.0defhello():print("Greetings!")conheadwill recognize the header if you apply it tohello.pyagain and will not write a second header.$conheadhello.py$cathello.py# Copyright 2022 Organized Organization
# SPDX-License-Identifier: Apache-2.0defhello():print("Greetings!")Pre-commitconheadispre-commitready. To use
with pre-commit, add the repo to your.pre-commit-config.yaml.For example:-repo:https://github.com/slobberchops/conheadrev:v0.4.0hooks:-id:conheadLinksChanges:https://github.com/slobberchops/conhead/blob/main/CHANGES.rstPyPI Releases:https://pypi.org/project/conhead/Source Code:https://github.com/slobberchops/conheadIssue Tracker:https://github.com/slobberchops/conhead/issues