<commit_before># -*- coding: utf-8 -*-

import json


def _normalize(url):
    """
    Ensure that its argument ends with a trailing / if it's nonempty.
    """

    if url and not url.endswith("/"):
        return url + "/"
    else:
        return url


class Configuration:
    """
    Configuration settings derived from the environment and current git branch.
    """

    def __init__(self, env):
        self.content_store_url = _normalize(env.get("CONTENT_STORE_URL"))
        self.content_store_apikey = env.get("CONTENT_STORE_APIKEY")
        self.content_id_base = _normalize(env.get("CONTENT_ID_BASE"))
        self.is_primary = env.get("TRAVIS_PULL_REQUEST") == "false"
        self.tls_verify = env.get("CONTENT_STORE_TLS_VERIFY") != "false"

    def apply_file(self, f):
        """
        Parse the contents of an open filehandle as JSON and apply recognized
        settings found there to this configuration.

        Environment variables take precedence over any values found here.
        """

        doc = json.load(f)

        for setting, value in doc.items():
            if setting == "contentIDBase":
                if not self.content_id_base:
                    self.content_id_base = _normalize(value)
                elif self.content_id_base != _normalize(value):
                    print("Using environment variable CONTENT_ID_BASE=[{}] "
                          "instead of _deconst.json setting [{}]."
                          .format(self.content_id_base, value))
            elif setting == "githubUrl":
                self.github_url = value
                self.github_issues_url = '/'.join(segment.strip('/') for segment in [value, 'issues'])
            elif setting == "meta":
                self.meta = value
            else:
                print("Ignoring an unrecognized configuration setting: [{}]"
                      .format(setting))

        # Add the Github issues URL to the repository-wide metadata
        self.meta.update({'github_issues_url': self.github_issues_url})

    def skip_submit_reasons(self):<commit_msg>handle content repos that haven't set githubUrl or meta<commit_after># -*- coding: utf-8 -*-

import json


def _normalize(url):
    """
    Ensure that its argument ends with a trailing / if it's nonempty.
    """

    if url and not url.endswith("/"):
        return url + "/"
    else:
        return url


class Configuration:
    """
    Configuration settings derived from the environment and current git branch.
    """

    def __init__(self, env):
        self.content_store_url = _normalize(env.get("CONTENT_STORE_URL"))
        self.content_store_apikey = env.get("CONTENT_STORE_APIKEY")
        self.content_id_base = _normalize(env.get("CONTENT_ID_BASE"))
        self.is_primary = env.get("TRAVIS_PULL_REQUEST") == "false"
        self.tls_verify = env.get("CONTENT_STORE_TLS_VERIFY") != "false"
        self.meta = {}

    def apply_file(self, f):
        """
        Parse the contents of an open filehandle as JSON and apply recognized
        settings found there to this configuration.

        Environment variables take precedence over any values found here.
        """

        doc = json.load(f)

        for setting, value in doc.items():
            if setting == "contentIDBase":
                if not self.content_id_base:
                    self.content_id_base = _normalize(value)
                elif self.content_id_base != _normalize(value):
                    print("Using environment variable CONTENT_ID_BASE=[{}] "
                          "instead of _deconst.json setting [{}]."
                          .format(self.content_id_base, value))
            elif setting == "githubUrl":
                self.github_url = value
                self.github_issues_url = '/'.join(segment.strip('/') for segment in [value, 'issues'])
            elif setting == "meta":
                self.meta = value
            else:
                print("Ignoring an unrecognized configuration setting: [{}]"
                      .format(setting))

        # Add the Github issues URL to the repository-wide metadata
        if hasattr(self, 'github_issues_url'):
            self.meta.update({'github_issues_url': self.github_issues_url})


    def skip_submit_reasons(self):
{'fraction_non_alphanumeric': 0.1033356659668766, 'fraction_numerical': 0.00046652670865407047, 'mean_word_length': 2.12764405543399, 'pattern_counts': {'":': 6, '<': 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': '1416590', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1146, 'n_words': 311}