platzky 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
platzky/db/db.py CHANGED
@@ -90,14 +90,6 @@ class DB(ABC):
90
90
  def get_font(self) -> str:
91
91
  pass
92
92
 
93
- @abstractmethod
94
- def get_all_providers(self): # TODO providers are not part of the DB
95
- pass
96
-
97
- @abstractmethod
98
- def get_all_questions(self): # TODO questions are not part of the DB
99
- pass
100
-
101
93
  @abstractmethod
102
94
  def get_site_content(self) -> str:
103
95
  pass
platzky/db/graph_ql_db.py CHANGED
@@ -1,6 +1,5 @@
1
1
  # TODO rename file, extract it to another library, remove qgl and aiohttp from dependencies
2
2
 
3
- import json
4
3
 
5
4
  from gql import Client, gql
6
5
  from gql.transport.aiohttp import AIOHTTPTransport
@@ -27,14 +26,24 @@ def db_from_config(config: GraphQlDbConfig):
27
26
  return GraphQL(config.endpoint, config.token)
28
27
 
29
28
 
30
- def _standarize_post(post):
29
+ def _standarize_comment(
30
+ comment,
31
+ ): # TODO add tests for checking stadarization of comments
32
+ return {
33
+ "author": comment["author"],
34
+ "comment": comment["comment"],
35
+ "date": comment["createdAt"],
36
+ }
37
+
38
+
39
+ def _standarize_post(post): # TODO add tests for checking stadarization of posts
31
40
  return {
32
41
  "author": post["author"]["name"],
33
42
  "slug": post["slug"],
34
43
  "title": post["title"],
35
44
  "excerpt": post["excerpt"],
36
45
  "contentInMarkdown": post["contentInRichText"]["html"],
37
- "comments": post["comments"],
46
+ "comments": [_standarize_comment(comment) for comment in post["comments"]],
38
47
  "tags": post["tags"],
39
48
  "language": post["language"],
40
49
  "coverImage": {
@@ -186,39 +195,6 @@ class GraphQL(DB):
186
195
  "posts"
187
196
  ]
188
197
 
189
- def get_all_providers(self):
190
- all_providers = gql(
191
- """
192
- query MyQuery {
193
- providers(stage: PUBLISHED) {
194
- link
195
- name
196
- offer
197
- currency
198
- }
199
- }
200
- """
201
- )
202
- providers = self.client.execute(all_providers)["providers"]
203
- for provider in providers:
204
- provider["offer"] = json.loads(provider["offer"])
205
- return providers
206
-
207
- def get_all_questions(self):
208
- all_questions = gql(
209
- """
210
- query MyQuery {
211
- questions(stage: PUBLISHED) {
212
- question
213
- field
214
- inputType
215
- }
216
- }
217
- """
218
- )
219
- query = self.client.execute(all_questions)
220
- return query["questions"]
221
-
222
198
  def add_comment(self, author_name, comment, post_slug):
223
199
  add_comment = gql(
224
200
  """
platzky/db/json_db.py CHANGED
@@ -68,12 +68,6 @@ class Json(DB):
68
68
  post for post in self.get_site_content()["posts"] if tag in post["tags"]
69
69
  )
70
70
 
71
- def get_all_providers(self):
72
- return self.data["providers"]
73
-
74
- def get_all_questions(self):
75
- return self.data["questions"]
76
-
77
71
  def get_site_content(self):
78
72
  content = self.data.get("site_content")
79
73
  if content is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: platzky
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Not only blog engine
5
5
  License: MIT
6
6
  Requires-Python: >=3.10,<4.0
@@ -18,6 +18,7 @@ Requires-Dist: aiohttp (>=3.9.5,<4.0.0)
18
18
  Requires-Dist: google-cloud-storage (>=2.5.0,<3.0.0)
19
19
  Requires-Dist: gql (>=3.4.0,<4.0.0)
20
20
  Requires-Dist: humanize (>=4.9.0,<5.0.0)
21
+ Requires-Dist: pydantic (>=2.7.1,<3.0.0)
21
22
  Description-Content-Type: text/markdown
22
23
 
23
24
  ![Github Actions](https://github.com/platzky/platzky/actions/workflows/tests.yml/badge.svg?event=push&branch=main)
@@ -4,11 +4,11 @@ platzky/blog/blog.py,sha256=R1Otio2Ix5d02CT9mtYZ_kKMbKJArsuJdJLjCfc4Qxg,3031
4
4
  platzky/blog/comment_form.py,sha256=4lkNJ_S_2DZmJBbz-NPDqahvy2Zz5AGNH2spFeGIop4,513
5
5
  platzky/config.py,sha256=XL4oASEZQtc6iNfiLkAJaHp9fUX3A53DEpCXznYyOrQ,2203
6
6
  platzky/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- platzky/db/db.py,sha256=1Ey7B-mc8QQyP4n3YbnA96PzWNTbrnXtTpMDNCg34nc,2876
7
+ platzky/db/db.py,sha256=0smTAiP4MDKOF_t60-KVKs1h-oTGydrWvAgPavFjDDo,2660
8
8
  platzky/db/db_loader.py,sha256=CuEiXxhIa4bFMm0vi7ugzm7j3WycilGRKCU6smgIImE,905
9
9
  platzky/db/google_json_db.py,sha256=65NKwbalGA1FfQz724dAK_3PS9e-MeLUb7WZkVU6nBo,1513
10
- platzky/db/graph_ql_db.py,sha256=1MmesGRqMZzsvGPkwA2DwwE4QLc-q0lsxfg3oBwin4A,6974
11
- platzky/db/json_db.py,sha256=UIZSWxqB2aCiL1WjSFLEOLVNQx-qCJ_66wHYlaSqD0A,3328
10
+ platzky/db/graph_ql_db.py,sha256=jAfz9WK7tYjTFFwurR0piuW_M79vK7IbV9AbQpNLnOo,6444
11
+ platzky/db/json_db.py,sha256=lbDZiEDWZebd9sssF8td1HKod4o7CdIvHu2fcPFgs7U,3184
12
12
  platzky/db/json_file_db.py,sha256=UQ8TadELmqOzj_tgNfmzhtCkDkMAgcB9vaUy0GQXUY4,1010
13
13
  platzky/models.py,sha256=8ATKVrGRtQ1JV_z7IdYbx1cxBU7ISoXjTmNxTlxok-k,1450
14
14
  platzky/platzky.py,sha256=3KljmS4lTB1yscOSDoavZ2yFwHcdQ_K8Om8qlJBA73U,4649
@@ -29,6 +29,6 @@ platzky/templates/post.html,sha256=GSgjIZsOQKtNx3cEbquSjZ5L4whPnG6MzRyoq9k4B8Q,1
29
29
  platzky/templates/robots.txt,sha256=2_j2tiYtYJnzZUrANiX9pvBxyw5Dp27fR_co18BPEJ0,116
30
30
  platzky/templates/sitemap.xml,sha256=iIJZ91_B5ZuNLCHsRtsGKZlBAXojOTP8kffqKLacgvs,578
31
31
  platzky/www_handler.py,sha256=pF6Rmvem1sdVqHD7z3RLrDuG-CwAqfGCti50_NPsB2w,725
32
- platzky-0.2.0.dist-info/METADATA,sha256=I3Rb4nKIsnCShVi_acU6oXFrl9TAP7OWo_pe7bU26p4,1550
33
- platzky-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
34
- platzky-0.2.0.dist-info/RECORD,,
32
+ platzky-0.2.2.dist-info/METADATA,sha256=KLe5kPbROivj3-ijlD80rlcoojVRZUY-t01hGIf4i_M,1591
33
+ platzky-0.2.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
34
+ platzky-0.2.2.dist-info/RECORD,,