Skip to content

Commit def2b97

Browse files
code clean-up
1 parent 6d29721 commit def2b97

File tree

8 files changed

+40
-29
lines changed

8 files changed

+40
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ config.py/
1515
/reports
1616
/tests/reports
1717
# Distribution / packaging
18+
.dccache
1819
.Python
1920
build/
2021
develop-eggs/

CHANGELOG.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
============
66

7-
**Date: 1-Aug-2021**
7+
### Date: 1-Aug-2021
88

99
Issue #17 resolved.
1010
Stack.sync_init uses wrong parameter names
@@ -13,22 +13,20 @@ Stack.sync_init uses wrong parameter names
1313

1414
============
1515

16-
**Date: 22-Jul-2021**
16+
### Date: 22-Jul-2021
1717

1818
contentstack-utils updated to v1.1.0
1919

2020
## _v1.4.0_
2121

2222
============
2323

24-
**Date: 05-Apr-2021**
24+
### Date: 05-Apr-2021
2525

26-
Entry
27-
- include_embedded_objects support added
28-
Query
29-
- include_embedded_objects support added
26+
Entry - include_embedded_objects support added
27+
Query - include_embedded_objects support added
3028

31-
-----------------------------
29+
---
3230

3331
## _v1.3.0_
3432

@@ -39,7 +37,7 @@ Date: 26-Feb-2021
3937
- Retry policy and timeout support included
4038
- Set default timeout 30 sec
4139

42-
-----------------------------
40+
---
4341

4442
## _v1.2.0_
4543

@@ -59,7 +57,7 @@ Date: 08-Dec-2020
5957
- Query
6058
- added support for include_fallback.
6159

62-
-----------------------------
60+
---
6361

6462
## _v1.1.0_
6563

@@ -69,7 +67,7 @@ EntryQueryable
6967

7068
- updated include_reference function.
7169

72-
-----------------------------
70+
---
7371

7472
## _v1.0.0_
7573

@@ -93,12 +91,12 @@ Query
9391

9492
- Changes incorporated in the Query class.
9593

96-
-----------------------------
94+
---
9795

9896
## _v0.1.0_
9997

10098
November-18, 2019 -beta release
10199

102100
Initial release for the contentstack-python-sdk for Content Delivery API
103101

104-
-----------------------------
102+
---

contentstack/assetquery.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def __init__(self, http_instance):
2727
self.base_url = "{}/assets".format(self.http_instance.endpoint)
2828
if "environment" in self.http_instance.headers:
2929
env = self.http_instance.headers["environment"]
30-
self.base_url = "{}?{}".format(self.base_url, "environment={}".format(env))
30+
self.base_url = "{}?{}".format(
31+
self.base_url, "environment={}".format(env))
3132

3233
def environment(self, environment):
3334
r"""Provide the name of the environment if you wish to retrieve the assets published

contentstack/basequery.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class QueryOperation(enum.Enum):
3535

3636

3737
def _get_operation_value(fields):
38-
value = fields[0] if isinstance(fields, list) and len(fields) == 1 else fields
38+
value = fields[0] if isinstance(
39+
fields, list) and len(fields) == 1 else fields
3940
return value
4041

4142

contentstack/contenttype.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
log = logging.getLogger(__name__)
1818

19+
1920
class ContentType:
2021
"""
2122
Content type defines the structure or schema of a page or a
@@ -49,7 +50,8 @@ def entry(self, entry_uid: str):
4950
raise PermissionError('Please provide valid content_type_uid')
5051
if entry_uid is None:
5152
raise PermissionError('Please provide valid entry uid')
52-
entry = Entry(self.http_instance, self.__content_type_uid, entry_uid=entry_uid)
53+
entry = Entry(self.http_instance,
54+
self.__content_type_uid, entry_uid=entry_uid)
5355
return entry
5456

5557
def query(self):
@@ -84,9 +86,11 @@ def fetch(self):
8486
------------------------------
8587
"""
8688
if self.__content_type_uid is None:
87-
raise KeyError('content_type_uid can not be None to fetch contenttype')
89+
raise KeyError(
90+
'content_type_uid can not be None to fetch contenttype')
8891
self.local_param['environment'] = self.http_instance.headers['environment']
89-
uri = '{}/content_types/{}'.format(self.http_instance.endpoint, self.__content_type_uid)
92+
uri = '{}/content_types/{}'.format(
93+
self.http_instance.endpoint, self.__content_type_uid)
9094
encoded_params = parse.urlencode(self.local_param)
9195
url = '{}?{}'.format(uri, encoded_params)
9296
result = self.http_instance.get(url)
@@ -111,6 +115,7 @@ def find(self, params=None):
111115
if params is not None:
112116
self.local_param.update(params)
113117
encoded_params = parse.urlencode(self.local_param)
114-
url = '{}?{}'.format('{}/content_types'.format(self.http_instance.endpoint), encoded_params)
118+
url = '{}?{}'.format(
119+
'{}/content_types'.format(self.http_instance.endpoint), encoded_params)
115120
result = self.http_instance.get(url)
116121
return result

contentstack/https_connection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ def get(self, url):
6363
adapter = HTTPAdapter(max_retries=self.retry_strategy)
6464
session.mount('https://', adapter)
6565
# log.info('url: %s', url)
66-
response = session.get(url, verify=True, headers=self.headers, timeout=self.timeout)
66+
response = session.get(
67+
url, verify=True, headers=self.headers, timeout=self.timeout)
68+
session.close()
6769
if response.encoding is None:
6870
response.encoding = 'utf-8'
6971
if response is not None:
7072
return response.json()
7173
else:
7274
return {"error": "error details not found", "error_code": 422, "error_message": "unknown error"}
75+
7376
except Timeout:
7477
raise TimeoutError('The request timed out')
7578
except ConnectionError:

contentstack/image_transform.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
log = logging.getLogger(__name__)
1515

16+
1617
class ImageTransform: # pylint: disable=too-few-public-methods
1718
"""
1819
The Image Delivery API is used to retrieve, manipulate and/or convert image
@@ -51,7 +52,8 @@ def get_url(self):
5152
------------------------------
5253
"""
5354
# args = ['{0}={1}'.format(k, v) for k, v in self.image_params.items()]
54-
args = ['{0}={1}'.format(k, v) for k, v in list(self.image_params.items())]
55+
args = ['{0}={1}'.format(k, v)
56+
for k, v in list(self.image_params.items())]
5557
if args:
5658
self.image_url += '?{0}'.format('&'.join(args))
5759
return self.image_url

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "contentstack.python",
3-
"version": "1.5.1",
4-
"developer": "shaileshmishra",
5-
"license": "MIT",
6-
"author": {"name": "shaileshmishra", "email": "[email protected]"},
7-
"homepage": "www.contentstack.com",
8-
"readme": "./readme"
9-
}
2+
"name": "contentstack.python",
3+
"version": "1.5.1",
4+
"developer": "ishaileshmishra",
5+
"license": "MIT",
6+
"author": { "name": "shaileshmishra", "email": "[email protected]" },
7+
"homepage": "www.contentstack.com",
8+
"readme": "./readme"
9+
}

0 commit comments

Comments
 (0)