Utility to add/remove licenses to/from source files

Overview

Licenser

Utility to add/remove licenses to/from source files. Supports processing any combination of globs, files, and directories (recurse). Pruning options allow skipping non-licensing files.

Workflow

licenser uses file identification techniques to infer the format of the license. Mainly, resolves how text is commented for that particular source file. Then, string matching is used to detect the presence of the license in source files. This allows licenser to be an idempotent operation.

Licenser workflow

Grammar of source file comments

Commented text in source code can be represented by the location and form of the comment symbols (symbol) and whitespaces (ws). More generally, most commenting syntaxes conform to the following form:


   

    
     
      
...

      
        
         
        
       
      
     
    
   

Prefix lines

This model consists of fixed comment symbols and whitespaces that are prefixed to each line of text: =


   
    
     
      
...

      
       
         
        
       
      
     
    
   

Open/close block

This model consists of enclosing comment symbols applied to the entire text: = , = , and =


   
    

     
      
       
...

       
         
         
           
          
         
        
       
      
     
    
   

Design

FileIdentificator

Checks several file properties to identify its type:

  • file extension
  • magic number
  • script she-bang
  • filename

Commenter

Given a text and a file type, adds/removes commenting symbols to/from the text.

Licenser

Adds/removes license to/from files. License is mostly placed at top of file except for scripts which it is placed after she-bang lines.

Requirements

Usage

python3 licenser.py --help

List the C++ source files to add license to:

python3 licenser.py --list-files --license-file raw_license.txt --recurse --sources /search/dir1 /search/dir2 "*.cc"

Add license to C++ source files:

python3 licenser.py --license-file raw_license.txt --recurse --sources /search/dir1 /search/dir2 "*.cc"

Remove license from C++ source files:

python3 licenser.py --delete --license-file raw_license.txt --recurse --sources /search/dir1 /search/dir2 "*.cc"
You might also like...
jfc is an utility to make reviewing ArXiv papers for your Journal Club easier.
jfc is an utility to make reviewing ArXiv papers for your Journal Club easier.

jfc is an utility to make reviewing ArXiv papers for your Journal Club easier.

Modest utility collection for development with AIOHTTP framework.

aiohttp-things Modest utility collection for development with AIOHTTP framework. Documentation https://aiohttp-things.readthedocs.io Installation Inst

Collection of code auto-generation utility scripts for the Horizon `Boot` system module

boot-scripts This is a collection of code auto-generation utility scripts for the Horizon Boot system module, intended for use in Atmosphère. Usage Us

Python utility for discovering interesting CFPreferences values on iDevices

Description Simple utility to search for interesting preferences in iDevices. Installation python3 -m pip install -U --user cfprefsmon Example In this

This is Cool Utility tools that you can use in python.

This is Cool Utility tools that you can use in python. There are a few tools that you might find very useful, you can use this on pretty much any project and some utils might help you a lot and save so much time since it’s a simple function.

Build capture utility for Linux

CX-BUILD Compilation Database alternative Build Prerequisite the CXBUILD uses linux system call trace utility called strace which was customized. So I

MongoDB utility to inflate the contents of small collection to a new larger collection

MongoDB Data Inflater ("data-inflater") The data-inflater tool is a MongoDB utility to automate the creation of a new large database collection using

Yet another retry utility in Python

Yet another retry utility in Python, avereno being the Malagasy word for retry.

The git for the Python Story Utility Package library.

SUP The git for the Python Story Utility Package library. Installation: Install SUP by simply running pip install psup in your terminal. Check out our

Owner
Eduardo Ponce Mojica
Eduardo Ponce Mojica
Utility to extract Fantasy Grounds Unity Line-of-sight and lighting files from a Univeral VTT file exported from Dungeondraft

uvtt2fgu Utility to extract Fantasy Grounds Unity Line-of-sight and lighting files from a Univeral VTT file exported from Dungeondraft This program wo

Andre Kostur 29 Dec 5, 2022
A small utility that sorts your files.

FileSorter A small utility that sorts your files. TODO: Scan directory to find files(thanks @corruptmemry for this!) Split extensions to determine fil

null 2 Jun 16, 2022
A utility tool to create .env files

A utility tool to create .env files dump-env takes an .env.template file and some optional environmental variables to create a new .env file from thes

wemake.services 89 Dec 8, 2022
We provide useful util functions. When adding a util function, please add a description of the util function.

Utils Collection Motivation When we implement codes, we often search for util functions that are already implemented. Here, we are going to share util

null 6 Sep 9, 2021
These scripts look for non-printable unicode characters in all text files in a source tree

find-unicode-control These scripts look for non-printable unicode characters in all text files in a source tree. find_unicode_control.py should work w

Siddhesh Poyarekar 25 Aug 30, 2022
A script to check for common mistakes in LaTeX source files of scientific papers.

LaTeX Paper Linter This script checks for common mistakes in LaTeX source files of scientific papers. Usage python3 paperlint.py <file.tex> [-i/x <inc

Michael Schwarz 12 Nov 16, 2022
A Python utility belt containing simple tools, a stdlib like feel, and extra batteries. Hashing, Caching, Timing, Progress, and more made easy!

Ubelt is a small library of robust, tested, documented, and simple functions that extend the Python standard library. It has a flat API that all behav

Jon Crall 638 Dec 13, 2022
isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.

isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type. It provides a command line utility, Python library and plugins for various editors to quickly sort all your imports.

Python Code Quality Authority 5.5k Jan 8, 2023
This utility lets you draw using your laptop's touchpad on Linux.

FingerPaint This utility lets you draw using your laptop's touchpad on Linux. Pressing any key or clicking the touchpad will finish the drawing

Wazzaps 95 Dec 17, 2022
Utility to play with ADCS, allows to request tickets and collect information about related objects.

certi Utility to play with ADCS, allows to request tickets and collect information about related objects. Basically, it's the impacket copy of Certify

Eloy 185 Dec 29, 2022