<commit_before>try:
    import ujson as json
except ImportError:
    import json
from six.moves.urllib.parse import parse_qsl

import requests.sessions

from . import session


# Catalog class
#_________________________________________________________________________________________
class Catalog(object):
    """:todo: Document Catalog Class."""

    ROW_TYPES = dict(
        green=0,
        blue=1,
        red=2,
        brown=9,
        purple=-1,
    )

    # init()
    #_____________________________________________________________________________________
    def __init__(self, identifier=None, task_ids=None, params={}, verbose=True,
                 config=None):
        verbose = '1' if verbose else '0'
        params = {} if not params else params

        self.session = session.ArchiveSession(config)
        self.http_session = requests.sessions.Session()

        # Set cookies from config.
        self.http_session.cookies = self.session.cookies
        self.http_session.cookies['verbose'] = verbose

        # Params required to retrieve JSONP from the IA catalog.
        self.params = dict(
            json=2,
            output='json',
            callback='foo',
        )
        self.params.update(params)
        # Return user's current tasks as default.
        if not identifier and not task_ids:
            self.params['justme'] = 1

        if task_ids:
            self.params.update(dict(
                where='task_id in({tasks})'.format(tasks=','.join(task_ids)),
                history=99999999999999999999999, # TODO: is there a better way?
            ))

        if identifier:
            self.url = 'http://archive.org/history/{id}'.format(id=identifier)
        elif task_ids:
            self.url = 'http://cat-tracey.archive.org/catalog.php'<commit_msg>convert `task_ids` to a list if it's not already a set/list.<commit_after>try:
    import ujson as json
except ImportError:
    import json
from six.moves.urllib.parse import parse_qsl

import requests.sessions

from . import session


# Catalog class
#_________________________________________________________________________________________
class Catalog(object):
    """:todo: Document Catalog Class."""

    ROW_TYPES = dict(
        green=0,
        blue=1,
        red=2,
        brown=9,
        purple=-1,
    )

    # init()
    #_____________________________________________________________________________________
    def __init__(self, identifier=None, task_ids=None, params={}, verbose=True,
                 config=None):
        verbose = '1' if verbose else '0'
        params = {} if not params else params

        self.session = session.ArchiveSession(config)
        self.http_session = requests.sessions.Session()

        # Set cookies from config.
        self.http_session.cookies = self.session.cookies
        self.http_session.cookies['verbose'] = verbose

        # Params required to retrieve JSONP from the IA catalog.
        self.params = dict(
            json=2,
            output='json',
            callback='foo',
        )
        self.params.update(params)
        # Return user's current tasks as default.
        if not identifier and not task_ids:
            self.params['justme'] = 1

        if task_ids:
            if not isinstance(task_ids, (set, list)):
                task_ids = [task_ids]
            self.params.update(dict(
                where='task_id in({tasks})'.format(tasks=','.join(task_ids)),
                history=99999999999999999999999, # TODO: is there a better way?
            ))

        if identifier:
            self.url = 'http://archive.org/history/{id}'.format(id=identifier)
        elif task_ids:
            self.url = 'http://cat-tracey.archive.org/catalog.php'
{'fraction_non_alphanumeric': 0.09997334044254866, 'fraction_numerical': 0.017062116768861636, 'mean_word_length': 2.341050756901158, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '7119023', 'n_tokens_mistral': 1050, 'n_tokens_neox': 969, 'n_words': 244}