<commit_before>"""
gist.py
=======

Module which contains all the gist related material.

"""

from json import dumps
from .models import GitHubCore, BaseComment
from .user import User


class GistFile(object):
    """The :class:`GistFile <GistFile>` object. This is used to represent a
    file object returned by GitHub while interacting with gists.
    """

    def __init__(self, attributes):
        super(GistFile, self).__init__()

        self._raw = attributes.get('raw_url')
        self._name = attributes.get('filename')
        self._language = attributes.get('language')
        self._size = attributes.get('size')
        self._content = attributes.get('content')

    def __repr__(self):
        return '<Gist File [%s]>' % self._name

    @property
    def content(self):
        """The content of the file."""
        return self._content

    @property
    def name(self):
        """The name of the file."""
        return self._name

    @property
    def lang(self):
        """The language associated with the file."""
        return self._language

    @property
    def raw_url(self):
        """The raw URL for the file at GitHub."""
        return self._raw

    @property
    def size(self):
        """The size of the file."""
        return self._size


class GistComment(BaseComment):
    """The :class:`GistComment <GistComment>` object. This represents a comment
    on a gist.
    """

    def __init__(self, comment, session):
        super(GistComment, self).__init__(comment, session)

    def __repr__(self):
        return '<Gist Comment [%s]>' % self._user.login


class Gist(GitHubCore):
    """The :class:`Gist <Gist>` object. This object holds all the information
    returned by Github about a gist. With it you can comment on or fork the
    gist (assuming you are authenticated), edit or delete the gist (assuming
    you own it).  You can also "star" or "unstar" the gist (again assuming you
    have authenticated).
    """

    def __init__(self, data, session):
        super(Gist, self).__init__(session)

        self._update_(data)

    def __repr__(self):
        return '<Gist [%s]>' % self._id

    def _update_(self, data):
        # The gist identifier
        self._id = data.get('id')
        self._desc = data.get('description')

        # e.g. https://api.github.com/gists/1
        self._api = data.get('url')
        # e.g. https://gist.github.com/1
        self._url = data.get('html_url')
        self._public = data.get('public')
        # a list of all the forks of that gist
        self._forks = data.get('forks', [])
        # e.g. git://gist.github.com/1.git
        self._pull = data.get('git_pull_url')
        # e.g. git@gist.github.com/1.git
        self._push = data.get('git_push_url')
        # date the gist was created
        self._created = self._strptime(data.get('created_at'))
        self._updated = self._strptime(data.get('updated_at'))
        self._user = User(data.get('user'), self._session)

        # Create a list of files in the gist
        self._files = []
        for file in data['files']:
            self._files.append(GistFile(data['files'][file]))

    def create_comment(self, body):
        """Create a comment on this gist.

        :param body: (required), body of the comment
        :type body: str
        :returns: :class:`GistComment <GistComment>`
        """
        url = self._api + '/comments'<commit_msg>Fix Gist() class.<commit_after>"""
gist.py
=======

Module which contains all the gist related material.

"""

from json import dumps
from .models import GitHubCore, BaseComment
from .user import User


class GistFile(object):
    """The :class:`GistFile <GistFile>` object. This is used to represent a
    file object returned by GitHub while interacting with gists.
    """

    def __init__(self, attributes):
        super(GistFile, self).__init__()

        self._raw = attributes.get('raw_url')
        self._name = attributes.get('filename')
        self._language = attributes.get('language')
        self._size = attributes.get('size')
        self._content = attributes.get('content')

    def __repr__(self):
        return '<Gist File [%s]>' % self._name

    @property
    def content(self):
        """The content of the file."""
        return self._content

    @property
    def name(self):
        """The name of the file."""
        return self._name

    @property
    def lang(self):
        """The language associated with the file."""
        return self._language

    @property
    def raw_url(self):
        """The raw URL for the file at GitHub."""
        return self._raw

    @property
    def size(self):
        """The size of the file."""
        return self._size


class GistComment(BaseComment):
    """The :class:`GistComment <GistComment>` object. This represents a comment
    on a gist.
    """

    def __init__(self, comment, session):
        super(GistComment, self).__init__(comment, session)

    def __repr__(self):
        return '<Gist Comment [%s]>' % self._user.login


class Gist(GitHubCore):
    """The :class:`Gist <Gist>` object. This object holds all the information
    returned by Github about a gist. With it you can comment on or fork the
    gist (assuming you are authenticated), edit or delete the gist (assuming
    you own it).  You can also "star" or "unstar" the gist (again assuming you
    have authenticated).
    """

    def __init__(self, data, session):
        super(Gist, self).__init__(session)

        self._update_(data)

    def __repr__(self):
        return '<Gist [%s]>' % self._id

    def _update_(self, data):
        # The gist identifier
        self._id = data.get('id')
        self._desc = data.get('description')

        # e.g. https://api.github.com/gists/1
        self._api = data.get('url')
        # e.g. https://gist.github.com/1
        self._url = data.get('html_url')
        self._public = data.get('public')
        # a list of all the forks of that gist
        self._forks = data.get('forks', [])
        # e.g. git://gist.github.com/1.git
        self._pull = data.get('git_pull_url')
        # e.g. git@gist.github.com/1.git
        self._push = data.get('git_push_url')
        # date the gist was created
        self._created = self._strptime(data.get('created_at'))
        self._updated = self._strptime(data.get('updated_at'))
        if data.get('user'):
            self._user = User(data.get('user'), self._session)
        else:
            self._user = None

        # Create a list of files in the gist
        self._files = []
        for file in data['files']:
            self._files.append(GistFile(data['files'][file]))

    def create_comment(self, body):
        """Create a comment on this gist.

        :param body: (required), body of the comment
        :type body: str
        :returns: :class:`GistComment <GistComment>`
        """
        url = self._api + '/comments'
{'fraction_non_alphanumeric': 0.12902294703420408, 'fraction_numerical': 0.0011545677586953383, 'mean_word_length': 2.413793103448276, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7080845', 'n_tokens_mistral': 2117, 'n_tokens_neox': 2046, 'n_words': 614}