Skip to content

Commit fa1c79d

Browse files
mshaileshr@gmail.commshaileshr@gmail.com
authored andcommitted
v1.1.0 pylint applied.
score: 9.96/10
1 parent 20e21c9 commit fa1c79d

File tree

10 files changed

+87
-44
lines changed

10 files changed

+87
-44
lines changed

CHANGELOGS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
CHANGELOG
22
=============
33

4+
5+
6+
*Date: 7-Aug-2020 - initial release*
7+
8+
**v1.1.0**
9+
============
10+
- **EntryQueryable**
11+
- updated include_reference function.
12+
13+
-----------------------------
14+
415
*Date: 17-Jun-2020 - initial release*
516

617
**v1.0.0**

changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CHANGELOG
66

77
**v1.1.0**
88
============
9-
- **EntryQueyable**
9+
- **EntryQueryable**
1010
- updated include_reference function.
1111

1212
-----------------------------

contentstack/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
"""
2+
The __init__.py files are required to make Python treat the directories as containing
3+
packages; this is done to prevent directories with a common name, such as string,
4+
from unintentionally hiding valid modules that occur later on the module search path
5+
6+
file __init__.py contains package information like
7+
__author__, __status__, __version__, __endpoint__ and __email__
8+
9+
"""
110
from .entry import Entry
211
from .asset import Asset
312
from .contenttype import ContentType
@@ -10,4 +19,4 @@
1019
__status__ = 'debug'
1120
__version__ = '1.1.0'
1221
__endpoint__ = 'cdn.contentstack.io'
13-
__email__ = 'mshaileshr@gmail.com'
22+
__email__ = 'shailesh.mishra@contentstack.com'

contentstack/contenttype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# Your code has been rated at 10.00/10 by pylint
1010

1111
from urllib import parse
12+
1213
from contentstack.entry import Entry
1314
from contentstack.query import Query
1415

@@ -44,7 +45,7 @@ def entry(self, entry_uid: str):
4445
"""
4546
if self.__content_type_uid is None:
4647
raise PermissionError('Please provide valid content_type_uid')
47-
elif entry_uid is None:
48+
if entry_uid is None:
4849
raise PermissionError('Please provide valid entry uid')
4950
entry = Entry(self.http_instance, self.__content_type_uid, entry_uid=entry_uid)
5051
return entry

contentstack/entryqueryable.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
EntryQueryable class contains common functions
3+
that is used as parents class for the query and entry classes
4+
"""
15

26

37
class EntryQueryable:
@@ -80,10 +84,17 @@ def include_reference(self, field_uid):
8084
8185
Arguments:
8286
Array of the only reference keys to be included in response
83-
field_uid {str or list of str} -- [str/list of str] of field_uid on which include operation to perform
87+
field_uid {str or list of str} -- [str/list of str] of field_uid on
88+
which include operation to perform
8489
8590
Returns:
8691
self -- So you can chain this call.
92+
93+
>>> import contentstack
94+
>>> stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
95+
>>> entry = stack.content_type('content_type')
96+
>>> entry("entry_uid").include_reference(["categories", "brand"])
97+
>>> result = entry.fetch()
8798
"""
8899
if field_uid is not None and isinstance(field_uid, (str, list)):
89100
self.entry_queryable_param["include[]"] = field_uid

contentstack/https_connection.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
"""
2-
# -*- coding: utf-8 -*-
3-
requests.api
4-
~~~~~~~~~~~~
5-
62
This module implements the Requests API.
73
"""
84

95
# ************* Module https_connection.py **************
106
# Your code has been rated at 10.00/10 by pylint
117

12-
from json import JSONDecodeError
13-
import json
14-
import urllib.parse as urlparse
158
import platform
9+
from json import JSONDecodeError
10+
1611
import requests
1712
from requests.exceptions import Timeout, HTTPError
13+
1814
import contentstack
1915

2016

@@ -77,9 +73,14 @@ def update_connection_timeout(self, timeout: int):
7773
"""Facilitate to update timeout for the https request"""
7874
self.default_timeout = timeout
7975

80-
def get_complete_url(self, base_url: str, params: dict):
81-
if 'query' in params:
82-
params["query"] = json.dumps(params["query"])
83-
query = urlparse.urlencode(params)
84-
url = '{}&{}'.format(base_url, query)
85-
return url
76+
# def get_complete_url(self, base_url: str, params: dict):
77+
# """
78+
# creates complete url with the help of base_url and query parameters
79+
# :param base_url: base url
80+
# :param params: query parameters
81+
# :return: url
82+
# """
83+
# if 'query' in params:
84+
# params["query"] = json.dumps(params["query"])
85+
# query = urlparse.urlencode(params)
86+
# return '{}&{}'.format(base_url, query)

contentstack/image_transform.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
different transform_params in second parameter in array form
77
"""
88

9+
910
# ************* Module image_transform **************
1011
# Your code has been rated at 10.00/10 by pylint
1112

1213

13-
class ImageTransform:
14+
class ImageTransform: # pylint: disable=too-few-public-methods
1415
"""
1516
The Image Delivery API is used to retrieve, manipulate and/or convert image
1617
files
1718
"""
1819

1920
def __init__(self, http_instance, image_url, **kwargs):
2021
"""
22+
creates instance of the ImageTransform class
2123
:param httpInstance: instance of HttpsConnection
2224
:param image_url: url on which manipulation required, Image transformation url
2325
:param kwargs: parameter in which we want to place different
@@ -50,5 +52,3 @@ def get_url(self):
5052
if args:
5153
self.image_url += '?{0}'.format('&'.join(args))
5254
return self.image_url
53-
54-

contentstack/utility.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
"""
22
Utils
33
contentstack
4-
Created by Shailesh Mishra on 22/06/19.
4+
Last modified by Shailesh Mishra on 06/08/20.
55
Copyright 2019 Contentstack. All rights reserved.
66
"""
77

8-
# ************* Module utility **************
9-
# Your code has been rated at 10.00/10
8+
# ************* Module utility checked using pylint **************
9+
# Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
1010

1111

12-
import logging
1312
import json
14-
import urllib.parse as urlparse
13+
import logging
14+
from urllib import parse
1515

1616

1717
def config_logging(logging_type: logging.WARNING):
18-
import logging
18+
"""
19+
This is to create logging config
20+
:param logging_type: Level of the logging
21+
:return: basicConfig instance
22+
"""
1923
logging.basicConfig(
2024
filename='application.log',
2125
level=logging_type,
@@ -50,13 +54,22 @@ def log(message):
5054

5155
@staticmethod
5256
def do_url_encode(params):
53-
from urllib import parse
57+
"""
58+
To encode url with query parameters
59+
:param params:
60+
:return: encoded url
61+
"""
5462
return parse.urlencode(params)
5563

5664
@staticmethod
5765
def get_complete_url(base_url: str, params: dict):
66+
"""
67+
creates complete url using base_url and their respective parameters
68+
:param base_url:
69+
:param params:
70+
:return:
71+
"""
5872
if 'query' in params:
5973
params["query"] = json.dumps(params["query"])
60-
query = urlparse.urlencode(params)
61-
url = '{}&{}'.format(base_url, query)
62-
return url
74+
query = parse.urlencode(params)
75+
return '{}&{}'.format(base_url, query)

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"name": "contentstack.python",
3-
"version": "1.0.0",
4-
"dependencies": {
5-
}
3+
"version": "1.1.0"
64
}

setup.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,26 @@
1717
name="contentstack",
1818
keywords='contentstack-python',
1919
version="1.1.0",
20-
author="contentstack",
21-
author_email="mshaileshr@gmail.com",
20+
author="Contentstack",
21+
author_email="shailesh.mishra@contentstack.com",
2222
description="Contentstack is a headless CMS with an API-first approach.",
2323
long_description="Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use "
2424
"to build powerful cross-platform applications in their favorite languages. Build your "
2525
"application frontend, and Contentstack will take care of the rest",
2626
long_description_content_type="text/markdown",
2727
url="https://github.com/contentstack/contentstack-python",
28-
# packages=setuptools.find_packages(),
2928
packages=['contentstack'],
3029
license='MIT',
3130
test_suite='tests.all_tests',
3231
install_requires=['requests>=1.1.0'],
3332
classifiers=[
34-
"License :: OSI Approved :: MIT License",
35-
"Operating System :: OS Independent",
36-
'Intended Audience :: Developers',
37-
'Natural Language :: English',
38-
'Programming Language :: Python :: 3.6',
39-
'Programming Language :: Python :: 3.7',
40-
],
33+
"License :: OSI Approved :: MIT License",
34+
"Operating System :: OS Independent",
35+
'Intended Audience :: Developers',
36+
'Natural Language :: English',
37+
'Programming Language :: Python :: 3.6',
38+
'Programming Language :: Python :: 3.7',
39+
],
4140
python_requires='>=3.6',
4241
zip_safe=False,
43-
)
42+
)

0 commit comments

Comments
 (0)