<commit_before>import json
from urllib.parse import urljoin
import sys


def get_payload():
    return json.load(sys.stdin)


def get_index_url(payload):
    source = payload['source']
    uri = source['uri']
    index = source['index']
    if not uri.endswith('/'):
        uri += '/'
    if not index.endswith('/'):
        index += '/'
    return urljoin(uri, index)


def get_package_url(payload):
    package = payload['source']['package']
    return get_index_url(payload) + package


def get_auth(payload):
    source = payload['source']
    return source['username'], source['password']


def get_version(payload):
    if 'version' in payload:
        version = payload['version']['version']
    else:
        version = None
    return version<commit_msg>Handle missing version in payload.<commit_after>import json
from urllib.parse import urljoin
import sys


def get_payload():
    return json.load(sys.stdin)


def get_index_url(payload):
    source = payload['source']
    uri = source['uri']
    index = source['index']
    if not uri.endswith('/'):
        uri += '/'
    if not index.endswith('/'):
        index += '/'
    return urljoin(uri, index)


def get_package_url(payload):
    package = payload['source']['package']
    return get_index_url(payload) + package


def get_auth(payload):
    source = payload['source']
    return source['username'], source['password']


def get_version(payload):
    try:
        version = payload['version']['version']
    except TypeError:
        version = None
    return version
{'fraction_non_alphanumeric': 0.13580246913580246, 'fraction_numerical': 0.0, 'mean_word_length': 3.3258426966292136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '7183749', 'n_tokens_mistral': 460, 'n_tokens_neox': 445, 'n_words': 117}