33
44from typing import List , Union
55
6- from ..errors import AsinNotFound , InvalidArgument
6+ from ..errors import InvalidArgument
77from ..tools import get_asin
88
99
@@ -20,27 +20,24 @@ def get_items_ids(items: Union[str, List[str]]) -> List[str]:
2020 else :
2121 items_ids = [get_asin (x .strip ()) for x in items ]
2222
23- if items_ids :
24- return items_ids
25-
26- raise AsinNotFound ("No ASIN codes have been found." )
23+ return items_ids
2724
2825
2926def check_search_args (** kwargs ):
30- _check_search_mandatory_args (** kwargs )
31- _check_search_pagination_args (** kwargs )
27+ check_search_mandatory_args (** kwargs )
28+ check_search_pagination_args (** kwargs )
3229
3330
34- def _check_search_mandatory_args (** kwargs ):
31+ def check_search_mandatory_args (** kwargs ):
3532 mandatory_args = [
36- kwargs [ "keywords" ] ,
37- kwargs [ "actor" ] ,
38- kwargs [ "artist" ] ,
39- kwargs [ "author" ] ,
40- kwargs [ "brand" ] ,
41- kwargs [ "title" ] ,
42- kwargs [ "browse_node_id" ] ,
43- kwargs [ "search_index" ] ,
33+ kwargs . get ( "keywords" ) ,
34+ kwargs . get ( "actor" ) ,
35+ kwargs . get ( "artist" ) ,
36+ kwargs . get ( "author" ) ,
37+ kwargs . get ( "brand" ) ,
38+ kwargs . get ( "title" ) ,
39+ kwargs . get ( "browse_node_id" ) ,
40+ kwargs . get ( "search_index" ) ,
4441 ]
4542 if all (arg is None for arg in mandatory_args ):
4643 error_message = (
@@ -50,9 +47,9 @@ def _check_search_mandatory_args(**kwargs):
5047 raise InvalidArgument (error_message )
5148
5249
53- def _check_search_pagination_args (** kwargs ):
50+ def check_search_pagination_args (** kwargs ):
5451 error_message = "Args item_count and item_page should be integers between 1 and 10."
55- pagination_args = [kwargs [ "item_count" ] , kwargs [ "item_page" ] ]
52+ pagination_args = [kwargs . get ( "item_count" ) , kwargs . get ( "item_page" ) ]
5653 pagination_args = [arg for arg in pagination_args if arg ]
5754
5855 if not all (isinstance (arg , int ) for arg in pagination_args ):
@@ -66,7 +63,7 @@ def check_variations_args(**kwargs):
6663 error_message = (
6764 "Args variation_count and variation_page should be integers between 1 and 10."
6865 )
69- variation_args = [kwargs [ "variation_count" ] , kwargs [ "variation_page" ] ]
66+ variation_args = [kwargs . get ( "variation_count" ) , kwargs . get ( "variation_page" ) ]
7067 variation_args = [arg for arg in variation_args if arg ]
7168
7269 if not all (isinstance (arg , int ) for arg in variation_args ):
@@ -77,6 +74,6 @@ def check_variations_args(**kwargs):
7774
7875
7976def check_browse_nodes_args (** kwargs ):
80- if not isinstance (kwargs [ "browse_node_ids" ] , List ):
77+ if not isinstance (kwargs . get ( "browse_node_ids" ) , List ):
8178 error_message = "Argument browse_node_ids should be a List of strings."
8279 raise InvalidArgument (error_message )
0 commit comments