Exemplo n.º 1
0
 def find_by_url(cls, url):
     for i in range(0, len(url) + 1):
         try:
             store = cls.get_by_url_prefix(url[:i])
             return store
         except:
             raise StoreErrors.StoreNotFoundException(
                 "The URL prefix used to find the store didn't give us any results"
             )
    def get_by_url(cls, url):
        try:
            for i in range(0, len(url) + 1):
                store_data = cls.get_by_url_prefix(url[:i + 13])
                i += 1
                store = store_data
                return store

        except:
            raise StoreErrors.StoreNotFoundException(
                "The store you are trying to reach could'nt find :(")
Exemplo n.º 3
0
 def find_by_url(cls, url):
     """
     Return a store from a url like "http://www.johnlewis.com/item/sdfj4h5g4g21k.html"
     :param url: The item's URL
     :return: a Store, or raises a StoreNotFoundException if no store matches the URL
     """
     for i in range(0, len(url)+1):
         try:
             store = cls.get_by_url_prefix(url[:i])
             return store
         except:
             raise StoreErrors.StoreNotFoundException("The URL Prefix used to find the store didn't give us any results!")
Exemplo n.º 4
0
 def find_by_url(cls, url):
     """
     Return a store from url
     :param url: The item's url
     :return: a Store, or raises a StoreNotFoundException if none found
     """
     for i in range(0, len(url) + 1):
         try:
             store = cls.get_by_url_prefix(url[:i])
             return store
         except:
             raise StoreErrors.StoreNotFoundException(
                 "The URL Prefix used doesn't return any results")
Exemplo n.º 5
0
 def find_by_url(cls, url: str) -> "Store":
     """
     Return a store from a url like "http://www.johnlewis.com/item/sdfj4h5g4g21k.html"
     :param url: The item's URL
     :return: a Store, or raises a StoreNotFoundException if no store matches the URL
     """
     for i in range(len(url)+1, 0, -1):
         try:
             print(f"Trying to find store starting with {url[:i]}")
             store = cls.get_by_url_prefix(url[:i])
             return store
         except:
             continue
     else:
         raise StoreErrors.StoreNotFoundException("The URL Prefix used to find the store didn't give us any results!")