from collections import OrderedDict
from itertools import islice
from typing import List

from app.master.build import Build
from app.util.exceptions import ItemNotFoundError


<<<<<<< HEAD
class BuildStore:
=======
class BuildStore(object):
>>>>>>> Migrate builds from master to BuildStore
    """
    Build storage service that stores and handles all builds.
    """
    _all_builds_by_id = OrderedDict()

    @classmethod
    def get(cls, build_id: int) -> Build:
        """
        Returns a build by id
        :param build_id: The id for the build whose status we are getting
        """
        build = cls._all_builds_by_id.get(build_id)
        if build is None:
            raise ItemNotFoundError('Invalid build id: {}.'.format(build_id))

        return build

    @classmethod
<<<<<<< HEAD
    def get_range(cls, start: int, end: int) -> List[Build]:
        """
        Returns a list of all builds.
        :param start: The starting index of the requested build
        :param end: 1 + the index of the last requested element, although if this is greater than the total number
                    of builds available the length of the returned list may be smaller than (end - start)
=======
    def get_range(cls, start: int, end: int) -> List['Build']:
        """
        Returns a list of all builds.
        :param offset: The starting index of the requested build
        :param limit: The number of builds requested
>>>>>>> Migrate builds from master to BuildStore
        """
        requested_builds = islice(cls._all_builds_by_id, start, end)
        return [cls._all_builds_by_id[key] for key in requested_builds]

    @classmethod
    def add(cls, build: Build):
        """
        Add new build to collection
        :param build: The build to add to the store
        """
        cls._all_builds_by_id[build.build_id()] = build

    @classmethod
    def size(cls) -> int:
        """
        Return the amount of builds within the store
        """
        return len(cls._all_builds_by_id)

@@ -170,29 +170,16 @@
 Error%0A%0A%0A
-%3C%3C%3C%3C%3C%3C%3C HEAD%0A
 class Bu
@@ -192,91 +192,8 @@
 re:%0A
-=======%0Aclass BuildStore(object):%0A%3E%3E%3E%3E%3E%3E%3E Migrate builds from master to BuildStore%0A
     
@@ -692,21 +692,8 @@
 hod%0A
-%3C%3C%3C%3C%3C%3C%3C HEAD%0A
     
@@ -978,16 +978,16 @@
  number%0A
+
         
@@ -1088,296 +1088,8 @@
 rt)%0A
-=======%0A    def get_range(cls, start: int, end: int) -%3E List%5B'Build'%5D:%0A        %22%22%22%0A        Returns a list of all builds.%0A        :param offset: The starting index of the requested build%0A        :param limit: The number of builds requested%0A%3E%3E%3E%3E%3E%3E%3E Migrate builds from master to BuildStore%0A
     

Fix docstring