The World of Mayukh Bose

<< Back to Main Page Mayukh's world: e-mail me | about
Mayukh's World: addlice.py Monday, October 23, 2017
Contents
  • What is addlice?
  • Download
  • Requirements
  • Configuration
  • Using the Program
  • Credits
  • My Free Software
  • Delphi/C++ Builder
  • Pocket PC
  • FreeSpeech Chat
  • C/C++ Freebies
  • Perl
  • Python
  • Ruby
  • My Python Code
  • ADO and Python
  • Addlice
  • IE Controller
  • Python Tutorials and Software e-mail me

    Addlice.py - Add Licenses to Source Code

    What is addlice?
    Addlice is a program that enables the user to quickly add copyright notices and licenses to a file or group of files. Addlice can be used at the end of a project to add licenses to all files in the project. The program is smart enough to recognize the programming language based on the extension of a file name and only adds licenses to programs that do not already have a copyright notice at the beginning of the file.

    Addlice comes preprogrammed with BSD-style, GNU GPL and MIT-style licenses. Additionally, it can also use licenses from any text file that you specify.

    This program is an useful addition to any developers toolkit and best of all, it is released under a BSD-style license, which means you are free to modify it as needed.

    If you find this program useful, or have any suggestions for improvements, please e-mail me and let me know. Maybe you will see your name in the credits section :). Also, please consider linking to this page, if you find this program useful.

    Download the Program
    You can download the program by clicking on this link. You will need to have WinZIP, tar/gzip or some other similar program in order to decompress the source code.

    Requirements
    Addlice is implemented in python and therefore requires a python interpreter to be installed in the system. The program uses some functions that are only found in python 2.3 or later, so you must have an interpreter that is at least version 2.3, otherwise the program will refuse to run.

    The program itself can run under any operating system that python runs under.

    Configuration
    The configuration file is called addlice.ini. Users of UNIX like systems (Linux, FreeBSD, OpenBSD, NetBSD etc.) may wish to rename this to $HOME/.addlice, if they prefer to keep the config file in their home directory. The config file has two fields that need to be filled, i.e. the owner and organization. Please change the values of these two fields to your requirements. These two values will be used when creating your license.

    The following directories will be searched in order:
    1. Current working directory\addlice.ini
    2. C:\addlice.ini
    3. $HOME/.addlice

    Using the Program
    The addlice program may be used as follows:

    addlice.py license_type filepath [filepath ...]

    license_type can be one of the following values:
    bsd, gpl, mit, /path/to/your/license.txt

    bsd - This produces a BSD-style license, using the owner and organization from the configuration file (addlice.ini)

    gpl - This produces a GNU GPL version 2 license. using the owner and organization from the configuration file (addlice.ini)

    mit - This produces an MIT style license, using the owner and organization from the configuration file (addlice.ini)

    /path/to/your/license.txt - This produces a license using the text specified in the file /path/to/your/license.txt

    filepath can be either a filename or a directory path. If it is a directory path, then the program recursively walks up the directory tree and looks for files to update. Multiple filepaths may be specified in the commmand line.

    The program looks for files with particular file extensions and then reads them to see if they already have a copyright notice or not. It does this by looking for the word "copyright" in the first 10 lines. If it doesn't find a copyright notice, it then adds one automatically, formatted for the appropriate programming language. The following file extensions are treated as follows:
    .c/C/cpp/.h - C/C++ source code
    .pl/.pm - Perl source code
    .php/.inc - PHP source code
    .py - Python source code
    .java - Java source code

    The copyright notices are added as program comments at the top of the file. If the program is identified as python or perl source code, the program also checks if the first line begins with "#!" and leaves it there if it does.

    WARNING WARNING WARNING WARNING WARNING
    The program overwrites any files that meet the above parameters. It is advisable that you make backup copies of the files before making this program modify them.

    Credits
    My family for always being there for me, Suzanne Young, Haik, G-man, Hoosh, Narges, the crazy Devshed crew, the list goes on....

    Finally, a big thank you to you, the user. Remember, if it wasn't for you, this program may have never been useful in the first place.