<commit_before>#! /usr/bin/env python
# encoding: utf-8

import os


class UploadVideoMixin(object):
    """Handle uploading a new video to the Vimeo API."""

    UPLOAD_ENDPOINT = '/me/videos'
    REPLACE_ENDPOINT = '{video_uri}/files'

    def upload(self, filename):
        """Upload the named file to Vimeo."""
        ticket = self.post(self.UPLOAD_ENDPOINT, data={'type': 'streaming'})

        self._perform_upload(filename, ticket)

    def replace(self, video_uri, filename, upgrade_to_1080=False):
        """Replace the video at the given uri with the named source file."""
        uri = self.REPLACE_ENDPOINT.format(video_uri=video_uri)

        ticket = self.put(uri,
                          data={'type': 'streaming',
                                'upgrade_to_1080': 'true' if upgrade_to_1080 else 'false'})

        self._perform_upload(filename, ticket)

    def _perform_upload(self, filename, ticket):
        """Take an upload ticket and perform the actual upload."""

        assert ticket.status_code == 201, "Failed to create an upload ticket"

        ticket = ticket.json()<commit_msg>added upgrade to 1080p to upload<commit_after>#! /usr/bin/env python
# encoding: utf-8

import os


class UploadVideoMixin(object):
    """Handle uploading a new video to the Vimeo API."""

    UPLOAD_ENDPOINT = '/me/videos'
    REPLACE_ENDPOINT = '{video_uri}/files'

    def upload(self, filename, upgrade_to_1080=False):
        """Upload the named file to Vimeo."""
        ticket = self.post(self.UPLOAD_ENDPOINT,
                          data={'type': 'streaming',
                                'upgrade_to_1080': 'true' if upgrade_to_1080 else 'false'})

        self._perform_upload(filename, ticket)

    def replace(self, video_uri, filename, upgrade_to_1080=False):
        """Replace the video at the given uri with the named source file."""
        uri = self.REPLACE_ENDPOINT.format(video_uri=video_uri)

        ticket = self.put(uri,
                          data={'type': 'streaming',
                                'upgrade_to_1080': 'true' if upgrade_to_1080 else 'false'})

        self._perform_upload(filename, ticket)

    def _perform_upload(self, filename, ticket):
        """Take an upload ticket and perform the actual upload."""

        assert ticket.status_code == 201, "Failed to create an upload ticket"

        ticket = ticket.json()
{'fraction_non_alphanumeric': 0.11143695014662756, 'fraction_numerical': 0.020108923334729786, 'mean_word_length': 2.634703196347032, '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': '7438323', 'n_tokens_mistral': 734, 'n_tokens_neox': 678, 'n_words': 195}