Skip to content

Commit 6d4db96

Browse files
stack doc string
1 parent 8fc62bc commit 6d4db96

File tree

4 files changed

+29
-150
lines changed

4 files changed

+29
-150
lines changed

contentstack/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from .entry import Entry
1010
from .asset import Asset
11-
from .asset_library import AssetLibrary
1211
from .config import Config
1312
from .content_type import ContentType
1413
from .errors import Error, ConfigError

contentstack/asset_library.py

Lines changed: 0 additions & 120 deletions
This file was deleted.

contentstack/config.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,25 @@
3232
class Config:
3333

3434
def __init__(self):
35-
self.defaultConfig = dict(protocol="https://", host="cdn.contentstack.io", port=443, version="v3", path={
36-
"stacks": "stacks",
37-
"sync": "stacks/sync",
38-
"content_types": "content_types",
39-
"entries": "content_types",
40-
"assets": "assets",
41-
"environments": "environments"
42-
})
35+
self.defaultConfig = dict(protocol="https:/",
36+
host="cdn.contentstack.io",
37+
port=443,
38+
version="v3",
39+
path={
40+
"stacks": "stacks",
41+
"sync": "stacks/sync",
42+
"content_types": "content_types",
43+
"entries": "content_types",
44+
"assets": "assets",
45+
"environments": "environments"
46+
})
4347

4448
def host(self, host_url=None):
45-
if host_url is not None:
46-
self.defaultConfig["host"] = host_url
47-
return self.defaultConfig["host"]
49+
if host_url is not None and isinstance(host_url, str):
50+
self.defaultConfig['host'] = host_url
51+
return self.defaultConfig['host']
4852

49-
def version(self, version: str = None):
53+
def version(self, version=None):
5054
if version is not None and isinstance(version, str):
5155
self.defaultConfig['version'] = version
5256
return self.defaultConfig['version']
@@ -59,20 +63,25 @@ def path(self, path):
5963
return url_section[path]
6064
else:
6165
logging.error("{0} is invalid endpoint path".format(path))
62-
raise ValueError('Invalid endpoint!!, {0} is invalid endpoint path, '
63-
'Path can be found among {1}'
64-
.format(path, url_section.keys()))
66+
raise Exception('Invalid endpoint!!, {0} is invalid endpoint path, Path can be found among {1}'
67+
.format(path, url_section.keys()))
68+
69+
@property
70+
def default_endpoint(self):
71+
endpoint_url = "{0}/{1}/{2}".format(self.defaultConfig["protocol"], self.host(), self.version())
72+
return endpoint_url
6573

6674
def endpoint(self, path):
6775
url = self.path(path)
6876
if url is not None and isinstance(url, str):
69-
url = "{0}{1}/{2}/{3}".format(self.defaultConfig["protocol"], self.host(), self.version(), url)
77+
url = "{0}/{1}/{2}/{3}".format(self.defaultConfig["protocol"], self.host(), self.version(), url)
7078
logging.info('endpoint is :: {0} '.format(url))
79+
7180
return url
7281

7382

74-
config = Config()
75-
config.host("cdn.contentstack.io")
76-
result_url = config.endpoint('entries')
77-
print(result_url)
83+
# config = Config()
84+
# config.host("stag-cdn.contentstack.io")
85+
# result_url = config.endpoint('assets')
86+
# print(result_url)
7887

contentstack/http_connection.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,28 @@ def get_result(self, url: str, query: dict, headers: dict):
3939
# If result contains stack, return json response
4040
if 'stack' in result:
4141
return result['stack']
42-
4342
# If result contains entry, return Entry
4443
if 'entry' in result:
4544
dict_entry = result['entry']
4645
return self.__parse_entries(dict_entry)
47-
4846
# If result contains entries, return list[Entry]
4947
if 'entries' in result:
5048
entry_list = result['entries']
5149
return self.__parse_entries(entry_list)
52-
5350
# If result contains asset, return Asset
5451
if 'asset' in result:
5552
dict_asset = result['asset']
5653
return self.__parse_assets(dict_asset)
57-
5854
# If result contains assets, return list[Asset]
5955
if 'assets' in result:
6056
asset_list = result['assets']
6157
return self.__parse_assets(asset_list)
62-
6358
# If result contains content_type,return content_type json
6459
if 'content_type' in result:
6560
return result['content_type']
66-
6761
# If result contains content_types,return content_types json
6862
if 'content_types' in result:
6963
return result['content_types']
70-
7164
# If result contains items, return SyncResult json
7265
if 'items' in result:
7366
sync_result = SyncResult().configure(result)
@@ -96,7 +89,6 @@ def __parse_entries(result):
9689
for entry_obj in result:
9790
each_entry = Entry().configure(entry_obj)
9891
entries.append(each_entry)
99-
10092
return entries
10193

10294
@staticmethod
@@ -117,7 +109,6 @@ def __parse_assets(result):
117109

118110
@staticmethod
119111
def __user_agents() -> dict:
120-
121112
import contentstack
122113
import platform
123114

0 commit comments

Comments
 (0)