Package: unbeheader
The Unbeheader 🪡😵Never fail to maintain your file headers.Unbeheader is a CLI tool to keep file headers up-to-date and to check that they remain so. The Unbeheader allows you to define file header templates in.header.yamlconfiguration files and then apply them to all the files in the project. Unbeheader knows how to update headers indifferent file types, including Python, JavaScript and CSS files.A header template will be rendered like this in Python files:# This file is part of Thelema.# Copyright (C) 1904 - 1947 Ordo Templi OrientisLike this in JavaScript files:// This file is part of Thelema.// Copyright (C) 1904 - 1947 Ordo Templi OrientisAnd like this in CSS files:/* This file is part of Thelema.* Copyright (C) 1904 - 1947 Ordo Templi Orientis*/Getting startedInstallationUnbeheader is available on PyPI asunbeheaderand can be installed withpip:pipinstallunbeheaderUsageIt's possible to run Unbeheader in two modes:fixandcheck. Thefixmode will update all files in the project with the correct header. Thecheckmode will check that all files in the project have the correct header and exit with a non-zero status code if any file is missing or has an incorrect header.NOTE:Neitherfixorcheckmodes will work unless Unbeheader can find a.header.yamlconfiguration file. Read more on theConfigurationsection.To run Unbeheader infixmode simply run theunbeheadcommand:unbehead# Update all the files in the Git repositoryunbehead--path.# Update all the files under the current directoryunbehead--path/path/to/directory# Update all the files under a directoryunbehead--path/path/to/file.py# Update a single fileBy default, Unbeheader will pass the current year to generate the{dates}placeholder in the header template. To pass a different year, use the--yearflag:unbehead--year1947To run Unbeheader incheckmode, use the--checkflag:unbehead--checkIt is possible to disable colors in the output by setting theCIenvironment variable to a truthy value:exportCI=1ConfigurationUnbeheader reads its configuration from.header.yamlfiles placed in the file tree of the project. It is possible to override configuration values by placing.header.yamlfiles in subdirectories. This is useful when different headers are needed for different parts of the project. It is also possible to exclude a directory by placing an empty.no-headerfile in it.Here is an example of a project structure with various.header.yamland.no-headerfiles:./
├── artifacts/
│  └── .no-header   # This directory will be ignored
├── thelema/
│  └── .header.yaml  # This overrides the default configuration
└── .header.yaml     # This is the default configurationThis.header.yamlfile contains the header template, template values to interpolate and other settings for Unbeheader. The following is an example of a.header.yamlfile:root:truestart_year:1904owner:Ordo Templi Orientissubstring:This file is part oftemplate:|-{comment_start} This file is part of Thelema.{comment_middle} Copyright (C) {dates} {owner}{comment_end}Setting value keys:root: When set totrue, it will stop Unbeheader from looking for.header.yamlfiles in parent directories. It defaults tofalse.substring: The substring that Unbeheader will look for to determine if a file has a header or not. If the substring is not found, Unbeheader will assume that the file has no header. It defaults toThis file is part of.Template value keys:owner: The owner of the project, used to generate the{owner}placeholder. This key is required.start_year: The start year of the header, used to generate the{dates}placeholder. It defaults to the year passed to theunbeheadcommand.Finally, thetemplatekey is a multi-line string that will be used to generate the header template. The template accepts the interpolation of certain placeholders. These are:{comment_start}: The comment start string for the file type (e.g.#for Python files).{comment_middle}: The comment middle string for the file type (e.g.*for CSS files).{comment_end}: The comment end string for the file type (e.g.*/for CSS files).{dates}: The start and end years of the header (e.g.1904 - 1947).{owner}: The owner of the project (e.g.Ordo Templi Orientis).DevelopmentIn order to develop Unbeheader, you will need to install the project and its dependencies in a virtualenv. This guide assumes that you have the following tools installed and available in your path:git(available in most systems)make(available in most systems)poetry(installation guide)pyenv(installation guide)First, clonethe repositorylocally with:gitclonehttps://github.com/unconventionaldotdev/unbeheadercdunbeheaderBefore creating the virtualenv, you probably want to be using the same version of Python that the development of the project is targeting. This is the first version specified in the.python-versionfile and you can install it withpyenv:pyenvinstallYou may now create the virtualenv and install the project with its dependencies in it withpoetry:poetryinstallOnce installed, you can invoke theunbeheadcommand with:poetryrun--unbeheadFor convenience, you may want to spawn a shell within the virtualenv with:poetryshell
unbeheadContributingThis project uses GitHub Actions to run the tests and linter on every pull request to themasterandstablebranches. You are still encouraged to run the tests and linter locally before pushing your changes.Linter checks can be run with:poetryrun--makelintTests can be run with:poetryrun--maketestTests can be run against all supported Python versions with:tox