File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from newsapi import const
66from newsapi .newsapi_auth import NewsApiAuth
77from newsapi .newsapi_exception import NewsAPIException
8- from newsapi .utils import is_valid_string , stringify_date_param
8+ from newsapi .utils import (
9+ is_valid_string , is_valid_string_or_list , stringify_date_param
10+ )
911
1012
1113class NewsApiClient (object ):
@@ -88,10 +90,10 @@ def get_top_headlines( # noqa: C901
8890
8991 # Keyword/Phrase
9092 if q is not None :
91- if is_valid_string (q ):
93+ if is_valid_string_or_list (q ):
9294 payload ["q" ] = q
9395 else :
94- raise TypeError ("keyword/phrase q param should be of type str" )
96+ raise TypeError ("keyword/phrase q param should be of type str or list of type str " )
9597
9698 # Keyword/Phrase in Title
9799 if qintitle is not None :
@@ -246,10 +248,10 @@ def get_everything( # noqa: C901
246248
247249 # Keyword/Phrase
248250 if q is not None :
249- if is_valid_string (q ):
251+ if is_valid_string_or_list (q ):
250252 payload ["q" ] = q
251253 else :
252- raise TypeError ("keyword/phrase q param should be of type str" )
254+ raise TypeError ("keyword/phrase q param should be of type str or list of type str " )
253255
254256 # Keyword/Phrase in Title
255257 if qintitle is not None :
Original file line number Diff line number Diff line change @@ -54,6 +54,13 @@ def validate_datetime_str(datetimestr):
5454
5555if PY3 :
5656
57+ def is_valid_string_or_list (var ):
58+ if isinstance (var , list ):
59+ return all ((is_valid_string (item ) for item in var ))
60+
61+ else :
62+ return is_valid_string (var )
63+
5764 def is_valid_string (var ):
5865 return isinstance (var , str )
5966
@@ -63,6 +70,13 @@ def is_valid_num(var):
6370
6471elif PY2 :
6572
73+ def is_valid_string_or_list (var ):
74+ if isinstance (var , list ):
75+ return all ((is_valid_string (item ) for item in var ))
76+
77+ else :
78+ return is_valid_string (var )
79+
6680 def is_valid_string (var ):
6781 return isinstance (var , basestring ) # noqa
6882
Original file line number Diff line number Diff line change 1212
1313from setuptools import setup
1414
15- VERSION = "0.2.6 "
15+ VERSION = "0.2.7 "
1616INSTALL_REQUIRES = ["requests<3.0.0" ]
1717TESTS_REQUIRE = ["pytest" ]
1818
You can’t perform that action at this time.
0 commit comments