Skip to content

Instantly share code, notes, and snippets.

@tedmiston
Last active May 9, 2018 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tedmiston/94f264b03512590c8b0e690ead5c8541 to your computer and use it in GitHub Desktop.
Save tedmiston/94f264b03512590c8b0e690ead5c8541 to your computer and use it in GitHub Desktop.
Fetch GitHub's MIT license template, populating this year and your name

Generate MIT License

Fetch GitHub's MIT license template, populating this year and your name.

Setup

Create virtualenv:

$ pipenv install

Quickstart

Create license:

$ pipenv run python generate_mit_license.py

Print license:

$ cat LICENSE
"""
Fetch GitHub's MIT license template, populating this year and your name.
"""
import getpass
import pwd
from datetime import date
import requests
template = requests.get('https://api.github.com/licenses/mit').json()['body']
year = date.today().strftime('%Y')
name = pwd.getpwnam(getpass.getuser()).pw_gecos
license_ = template.replace('[year]', year).replace('[fullname]', name)
open('LICENSE', 'w').write(license_)
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
[dev-packages]
[requires]
python_version = "3.7"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment