<commit_before>import time, cjson, math
from request import *

class Catalog:
    def __init__(self, url, user=None, password=None):
        self.url = url
        self.user = user
        self.password = password

    def listRepositories(self):
        """Returns the names of repositories in the catalog."""
        repos = jsonRequest(self, "GET", "/repositories")
        return [repo["id"] for repo in repos]

    def createRepository(self, name):
        """Ask the server to create a new repository."""
        nullRequest(self, "PUT", "/repositories/" + urllib.quote(name))
        return self.getRepository(name)

    def deleteRepository(self, name):
        """Delete a repository in this catalog."""
        nullRequest(self, "DELETE", "/repositories/" + urllib.quote(name))

    # def federateTripleStores(self, name, storeNames):
    #     """Create a federated store."""
    #     nullRequest(self, "PUT", "/repositories/" + urllib.quote(name) +
    #                 "?" + urlenc(federate=storeNames))

    def getRepository(self, name):
        """Create an access object for a triple store."""
        return Repository(self.url + "/repositories/" + urllib.quote(name), self.user, self.password)


class Client(Catalog):
    def listCatalogs(self):
        return jsonRequest(self, "GET", "/catalogs")

    def openCatalog(self, url):
        return Catalog(url, self.user, self.password)

    def openCatalogByName(self, name=None):
        url = self.url
        if name:
            url += "/catalogs/" + urllib.quote(name)
        return self.openCatalog(url)


class Repository:
    def __init__(self, url, user=None, password=None):
        # TODO verify existence of repository at this point?
        self.url = url
        self.user = user
        self.password = password

    def getSize(self, context=None):
        """Returns the amount of triples in the repository."""
        return jsonRequest(self, "GET", "/size", urlenc(context=context))

    def listContexts(self):
        """Lists the contexts (named graphs) that are present in this repository."""
        return [t["contextID"] for t in jsonRequest(self, "GET", "/contexts")]
<commit_msg>follow change in return format of /catalogs<commit_after>import time, cjson, math
from request import *

class Catalog:
    def __init__(self, url, user=None, password=None):
        self.url = url
        self.user = user
        self.password = password

    def listRepositories(self):
        """Returns the names of repositories in the catalog."""
        repos = jsonRequest(self, "GET", "/repositories")
        return [repo["id"] for repo in repos]

    def createRepository(self, name):
        """Ask the server to create a new repository."""
        nullRequest(self, "PUT", "/repositories/" + urllib.quote(name))
        return self.getRepository(name)

    def deleteRepository(self, name):
        """Delete a repository in this catalog."""
        nullRequest(self, "DELETE", "/repositories/" + urllib.quote(name))

    # def federateTripleStores(self, name, storeNames):
    #     """Create a federated store."""
    #     nullRequest(self, "PUT", "/repositories/" + urllib.quote(name) +
    #                 "?" + urlenc(federate=storeNames))

    def getRepository(self, name):
        """Create an access object for a triple store."""
        return Repository(self.url + "/repositories/" + urllib.quote(name), self.user, self.password)


class Client(Catalog):
    def listCatalogs(self):
        return [cat["id"] for cat in jsonRequest(self, "GET", "/catalogs")]

    def openCatalog(self, uriOrName):
        if (uriOrName.startswith("http://")):
            return Catalog(uriOrName, self.user, self.password)
        else:
            return self.openCatalogByName(uriOrName);

    def openCatalogByName(self, name=None):
        url = self.url
        if name and name != "~":
            url += "/catalogs/" + urllib.quote(name)
        return self.openCatalog(url)


class Repository:
    def __init__(self, url, user=None, password=<PASSWORD>):
        # TODO verify existence of repository at this point?
        self.url = url
        self.user = user
        self.password = password

    def getSize(self, context=None):
        """Returns the amount of triples in the repository."""
        return jsonRequest(self, "GET", "/size", urlenc(context=context))

    def listContexts(self):
        """Lists the contexts (named graphs) that are present in this repository."""
        return [t["contextID"] for t in jsonRequest(self, "GET", "/contexts")]

{'fraction_non_alphanumeric': 0.12924424972617743, 'fraction_numerical': 0.0, 'mean_word_length': 2.8337531486146097, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 4, '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': '1538611', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1268, 'n_words': 387}