<commit_before>#!/usr/bin/env python
# -*- coding: utf -8 -*-
from __future__ import unicode_literals
import pytest

from dll import DoublyLL


class Deque(object):
    """Deque data structure class"""
    def __init__(self, iterable=None):
        """Initiate an instance of Deque using composition."""
        self._doublyLL = DoublyLL(iterable)

    def __len__(self):
        """For the built-in len()"""
        return len(self._doublyLL)

    def append(self, val):
        """Add val to the end of the deque."""
        return self._doublyLL.append(val)

    def appendleft(self, val):
        """Add a value to the front of the deque."""
        return self._doublyLL.push(val)

    def pop(self):
        """Remove a value to the end of the deque."""
        if len(self) == 0:
            raise IndexError("can't pop off an empty deque.")
        return self._doublyLL.shift()

    def popleft(self):
        """Remove a value to the front of the deque."""
        if len(self) == 0:
            raise IndexError("can't popleft off an empty deque.")
        return self._doublyLL.pop()

    def peek(self):
        """Peek at a value at the end of the deque."""
        if len(self) == 0:
            return None
        return self._doublyLL.tail_node.value

    def peekleft(self):
        """Peek at a value at the front of the deque."""
        if len(self) == 0:
            return None
        return self._doublyLL.head_node.value

    def size(self):
        """Return size of the deque"""
        return len(self)<commit_msg>use try, except instead of checking for len<commit_after>#!/usr/bin/env python
# -*- coding: utf -8 -*-
from __future__ import unicode_literals
import pytest

from dll import DoublyLL


class Deque(object):
    """Deque data structure class"""
    def __init__(self, iterable=None):
        """Initiate an instance of Deque using composition."""
        self._doublyLL = DoublyLL(iterable)

    def __len__(self):
        """For the built-in len()"""
        return len(self._doublyLL)

    def append(self, val):
        """Add val to the end of the deque."""
        return self._doublyLL.append(val)

    def appendleft(self, val):
        """Add a value to the front of the deque."""
        return self._doublyLL.push(val)

    def pop(self):
        """Remove a value to the end of the deque."""
        if len(self) == 0:
            raise IndexError("can't pop off an empty deque.")
        return self._doublyLL.shift()

    def popleft(self):
        """Remove a value to the front of the deque."""
        if len(self) == 0:
            raise IndexError("can't popleft off an empty deque.")
        return self._doublyLL.pop()

    def peek(self):
        """Peek at a value at the end of the deque."""
        try:
            return self._doublyLL.tail_node.value
        except AttributeError:
            return None

    def peekleft(self):
        """Peek at a value at the front of the deque."""
        try:
            return self._doublyLL.head_node.value
        except AttributeError:
            return None

    def size(self):
        """Return size of the deque"""
        return len(self)
{'fraction_non_alphanumeric': 0.11487341772151899, 'fraction_numerical': 0.002531645569620253, 'mean_word_length': 2.21239837398374, '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': '6383850', 'n_tokens_mistral': 993, 'n_tokens_neox': 915, 'n_words': 328}