Skip to content

Commit 03f4b36

Browse files
mshaileshr@gmail.commshaileshr@gmail.com
authored andcommitted
docstring
1 parent 8efa824 commit 03f4b36

File tree

2 files changed

+4
-66
lines changed

2 files changed

+4
-66
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ venv.bak/
105105
# mypy
106106
.mypy_cache/
107107
.idea/
108-
.vscode
108+
.vscode/

contentstack/http_connection.py

Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,15 @@ def get_result(self, url: str, query: dict, headers: dict):
4141
# Case: If UIR Parameter contains entries
4242
if 'entries' in self.__base_url:
4343
self.__payload = self.__execute_entry()
44-
# self.__payload = parse.urlencode(query=params, encoding='UTF-8')
4544
else:
4645
url_param = ''
4746
for (key, value) in self.__query_params.items():
4847
url_param = '{}&{}={}'.format(url_param, key, value)
4948
self.__payload = url_param
50-
5149
try:
5250
if self.__payload.startswith("&"):
5351
self.__payload = self.__payload[1:]
52+
5453
_url = '{}?{}'.format(self.__base_url, self.__payload)
5554
logging.info('{}?{}'.format(self.__base_url, self.__payload))
5655
response = requests.get(_url, verify=True, timeout=(10, 8), headers=self.__headers)
@@ -76,70 +75,9 @@ def get_result(self, url: str, query: dict, headers: dict):
7675
except HTTPError:
7776
raise HTTPError('Http Error Occurred')
7877

79-
# def __check_for_valid_query(self):
80-
#
81-
# if 'include[]' in self.__query_params:
82-
# url_params = ''
83-
# params = self.__query_params['include[]']
84-
# for param in params:
85-
# url_params = '{}&include[]={}'.format(url_params, param)
86-
# del self.__query_params['include[]']
87-
# return self.__return_query(url_params)
88-
#
89-
# elif 'only[BASE][]' in self.__query_params:
90-
# url_params = ''
91-
# params = self.__query_params['only[BASE][]']
92-
# for param in params:
93-
# url_params = '{}&only[BASE][]={}'.format(url_params, param)
94-
# del self.__query_params['only[BASE][]']
95-
# return self.__return_query(url_params)
96-
#
97-
# elif 'except[BASE][]' in self.__query_params:
98-
# url_params = ''
99-
# params = self.__query_params['except[BASE][]']
100-
# for param in params:
101-
# url_params = '{}&except[BASE][]={}'.format(url_params, param)
102-
# del self.__query_params['except[BASE][]']
103-
# return self.__return_query(url_params)
104-
#
105-
# elif 'only' in self.__query_params:
106-
# url_params = ''
107-
# params = self.__query_params['only']
108-
# for param in params:
109-
# url_params = '{}&only={}'.format(url_params, param)
110-
# del self.__query_params['only']
111-
# return self.__return_query(url_params)
112-
#
113-
# elif 'except' in self.__query_params:
114-
# url_params = ''
115-
# params = self.__query_params['except']
116-
# for param in params:
117-
# url_params = '{}&except={}'.format(url_params, param)
118-
# del self.__query_params['except']
119-
# return self.__return_query(url_params)
120-
#
121-
# elif 'query' in self.__query_params:
122-
# url_params = ''
123-
# params = self.__query_params['query']
124-
# for param in params:
125-
# url_params = '{}&query={}'.format(url_params, param)
126-
# del self.__query_params['query']
127-
# return self.__return_query(url_params)
128-
# else:
129-
# pass
130-
#
131-
# def __return_query(self, url_params):
132-
# other_queries = ''
133-
# for key, value in self.__query_params.items():
134-
# other_queries = '{}&{}={}'.format(other_queries, key, value)
135-
# url_params = '{}{}'.format(other_queries, url_params)
136-
# self.__query_params.clear()
137-
# return url_params
138-
13978
def __parse_dict(self, response):
14079
from contentstack.stack import SyncResult
14180
result = response.json()
142-
14381
if 'stack' in result:
14482
return result['stack']
14583
if 'entry' in result:
@@ -242,8 +180,8 @@ def __execute_entry(self):
242180
if isinstance(inner_list, list):
243181
url_param = '{}&{}'.format(url_param, urlencode({inner_key: inner_list}, doseq=True))
244182
elif key == 'query':
245-
query = urlencode({key: value})
246-
url_param = '{}&{}'.format(url_param, query, doseq=True)
183+
url_param = '{}&{}={}'.format(url_param, key, value.__str__().replace("\'", "\""))
184+
print(url_param)
247185
else:
248186
url_param = '{}&{}={}'.format(url_param, key, value)
249187

0 commit comments

Comments
 (0)