<commit_before>#!/usr/bin/env python

import os
import re
import sys
from datetime import datetime

import click
import requests
from requests.compat import urljoin

BASE_LIST_URL = 'https://api.github.com/licenses'
BASE_SEARCH_URL = 'https://api.github.com/licenses/'
HEADERS = {
	"Accept" : "application/vnd.github.drax-preview+json",
}

DIR_PATH = os.path.abspath(os.path.dirname(__file__))
PARENT_DIR = os.path.abspath(os.path.join(DIR_PATH, os.pardir))
FILEPATH = os.path.abspath(os.path.join(PARENT_DIR, 'LICENSE'))

def build_license_content(content, name):
	"""Creates the license by replacing year and name in the original text."""
	year = datetime.now().year
	content = re.sub('\[year\]', str(year), content)
	content = re.sub('\[fullname\]', name, content)
	return content

def create_license_file(license_content):
	"""Creates a file named LICENSE in the current directory with license content."""
	license_file = FILEPATH
	with open(license_file, 'w') as f:
		f.write(license_content)

@click.group()
def main():
	"""It generates a license for your project."""
	pass

@main.command()
def list():
	"""Lists all available licenses."""
	call_url = BASE_LIST_URL
	response = requests.get(call_url, headers=HEADERS)
	if response.status_code == requests.codes.ok:
		license_list = [x['key'] for x in response.json()]
		click.echo(license_list)
	else:
		click.echo("Service not working at the moment.")<commit_msg>unicode to string conversion of license names<commit_after>#!/usr/bin/env python

import os
import re
import sys
from datetime import datetime

import click
import requests
from requests.compat import urljoin

BASE_LIST_URL = 'https://api.github.com/licenses'
BASE_SEARCH_URL = 'https://api.github.com/licenses/'
HEADERS = {
	"Accept" : "application/vnd.github.drax-preview+json",
}

DIR_PATH = os.path.abspath(os.path.dirname(__file__))
PARENT_DIR = os.path.abspath(os.path.join(DIR_PATH, os.pardir))
FILEPATH = os.path.abspath(os.path.join(PARENT_DIR, 'LICENSE'))

def build_license_content(content, name):
	"""Creates the license by replacing year and name in the original text."""
	year = datetime.now().year
	content = re.sub('\[year\]', str(year), content)
	content = re.sub('\[fullname\]', name, content)
	return content

def create_license_file(license_content):
	"""Creates a file named LICENSE in the current directory with license content."""
	license_file = FILEPATH
	with open(license_file, 'w') as f:
		f.write(license_content)

@click.group()
def main():
	"""It generates a license for your project."""
	pass

@main.command()
def list():
	"""Lists all available licenses."""
	call_url = BASE_LIST_URL
	response = requests.get(call_url, headers=HEADERS)
	if response.status_code == requests.codes.ok:
		license_list = [str(x['key']) for x in response.json()]
		click.echo("List of all license key names:")
		click.echo(license_list)
	else:
		click.echo("Service not working at the moment.")
{'fraction_non_alphanumeric': 0.1374829001367989, 'fraction_numerical': 0.0, 'mean_word_length': 5.223404255319149, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3892339', 'n_tokens_mistral': 973, 'n_tokens_neox': 949, 'n_words': 259}