From 51e6832d9df70e7f8bbe180ac587cfcdbb12e8fa Mon Sep 17 00:00:00 2001 From: Shwetabh Kumar Date: Wed, 3 Feb 2021 12:16:48 +0530 Subject: [PATCH] Fix: Handling None case for Iterators --- netsuitesdk/api/base.py | 16 +++++++++------- setup.py | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/netsuitesdk/api/base.py b/netsuitesdk/api/base.py index abb0609..eecb93b 100644 --- a/netsuitesdk/api/base.py +++ b/netsuitesdk/api/base.py @@ -5,15 +5,17 @@ from typing import List logger = logging.getLogger(__name__) - - # TODO: introduce arg and return types + + +# TODO: introduce arg and return types class ApiBase: def __init__(self, ns_client, type_name): self.ns_client = ns_client self.type_name = type_name def get_all(self): - return list(self.get_all_generator()) + all_records = self.get_all_generator() + return list(all_records) if all_records else [] def get_all_generator(self, page_size=20): """ @@ -25,7 +27,8 @@ def get(self, internalId=None, externalId=None) -> OrderedDict: return self._get(internalId=internalId, externalId=externalId) def get_ref(self, internalId=None, externalId=None) -> OrderedDict: - return self._serialize(self.ns_client.RecordRef(type=self.type_name.lower(), internalId=internalId, externalId=externalId)) + return self._serialize(self.ns_client.RecordRef(type=self.type_name.lower(), + internalId=internalId, externalId=externalId)) def post(self, data) -> OrderedDict: raise NotImplementedError('post method not implemented') @@ -44,7 +47,8 @@ def _serialize_array(self, records) -> List[OrderedDict]: """ return zeep.helpers.serialize_object(records) - def _paginated_search_to_generator(self, paginated_search): + @staticmethod + def _paginated_search_to_generator(paginated_search): if paginated_search.num_records == 0: return @@ -53,8 +57,6 @@ def _paginated_search_to_generator(self, paginated_search): logger.debug(f'current page index {paginated_search.page_index}') logger.debug('going to page %d', 0) - num_records = paginated_search.num_records - records = [] for p in range(1, num_pages + 1): diff --git a/setup.py b/setup.py index bbcdf30..43f21ec 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='netsuitesdk', - version='1.13.0', + version='1.13.1', author='Siva Narayanan', author_email='siva@fyle.in', description='Python SDK for accessing the NetSuite SOAP webservice',