Clauses on Command
Keep a suite of your favourite contract clauses at your fingertips.
The problem
Sometimes when drafting an agreement you just want to have your favourite clauses ready to paste in. Instead of raking through terms of previous agreements you have reviewed, you can paste a selection in to a csv file for quick summoning from the terminal. It also allows you to enter a new clauses from the command line, and list all the clauses available.
Tasklist
- Install the required module
- Create our script and csv file
- Run the script with different 'flags'
1. Install the modules
We are going to install 'fuzzywuzzy' so we can search for clauses without getting the exact spelling (it does a 'fuzzy' match).
We are also going to install 'click', which will let us call the script from the command line including flags to select between listing, searching and adding clauses.
2. Create our script and CSV
In the folder you want to keep the files, create the files we need with:
$ touch clauses.csv clauses.py
to create the two empty files we need.
Paste the python script below in to clauses.py and the csv data into clauses.csv
In the CSV file, you can see we've set 3 variable fields:
- The type of clause (e.g. warranty, jurisdiction). This is what the 'fuzzy' search looks for when you use it.
- The clause itself.
- A short description (to help distinguish between two clauses of the same type)
Replace the filler examples with a few of your own favourite clauses to get started.
3. Use the Flags
Using the -s flag
When we use the -s
flag we must follow it up with the term we are searching for, e.g.:
$ python3 clauses.py -s jurisdicton
This give us the following out - note how this works despite the small typo in 'jurisdiction'.

Using the -l flag
Using the -l
flag lists out all of the available clauses and their descriptions.
Then, we can select one by entering the corresponding number, as shown here:

Using the -n flag
The -n
flag allows us to enter a new clause by responding to the prompts.
In the example below, we add a clause then select it from our list.
