hcs-core 0.1.302__py3-none-any.whl → 0.1.304__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.
hcs_core/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.302"
1
+ __version__ = "0.1.304"
@@ -40,7 +40,11 @@ def with_query(url: str, **kwargs: Any) -> str:
40
40
  class PageRequest:
41
41
  def __init__(self, fn_get_page: Callable, fn_filter: Callable = None, **kwargs):
42
42
  limit = kwargs.get("limit")
43
- self.limit = int(limit) if limit else 10
43
+ if limit is None or limit == "":
44
+ limit = 10
45
+ else:
46
+ limit = int(limit)
47
+ self.limit = limit
44
48
  self.fn_get_page = fn_get_page
45
49
  self.fn_filter = fn_filter
46
50
  self.query = _remove_none(dict(kwargs))
@@ -57,12 +61,14 @@ class PageRequest:
57
61
  params["size"] = size
58
62
 
59
63
  query_string = urlencode(params)
60
- page = self.fn_get_page(query_string)
61
- if not page or not page.content:
64
+ page_data = self.fn_get_page(query_string)
65
+ if not page_data or not page_data.content:
62
66
  return [], False
67
+ content = page_data.content
63
68
  if self.fn_filter:
64
- return list(filter(self.fn_filter, page.content)), True
65
- return page.content, True
69
+ content = list(filter(self.fn_filter, content))
70
+ has_next = page_data.get("totalPages", 0) > page + 1
71
+ return content, has_next
66
72
 
67
73
  def get(self) -> list:
68
74
  ret = []
@@ -83,12 +89,15 @@ class PageRequest:
83
89
  else:
84
90
  content = page.content
85
91
  ret += content
86
- if len(ret) > self.limit:
92
+ if self.limit > 0 and len(ret) > self.limit:
87
93
  ret = ret[: self.limit]
88
94
  break
89
- if len(page.content) < self.query["size"]:
90
- break # no more items
95
+ # if len(page.content) < self.query["size"]:
96
+ # break # no more items
97
+ total_pages = page.get("totalPages", 0)
91
98
  page_index += 1
99
+ if page_index >= total_pages:
100
+ break
92
101
 
93
102
  return ret
94
103
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hcs-core
3
- Version: 0.1.302
3
+ Version: 0.1.304
4
4
  Summary: Horizon Cloud Service CLI module.
5
5
  Project-URL: Homepage, https://github.com/euc-eng/hcs-cli
6
6
  Project-URL: Bug Tracker, https://github.com/euc-eng/hcs-cli/issues
@@ -1,4 +1,4 @@
1
- hcs_core/__init__.py,sha256=aJpq_qgUJaJ0o4-fhRld22s0zAiQAgHVWiAbrJatEHs,24
1
+ hcs_core/__init__.py,sha256=UHqRaGYGGABhXkQBMY58fzqaHad2XcEmjrKQKN-kUQ8,24
2
2
  hcs_core/ctxp/__init__.py,sha256=bHVHhJP10Luz1a3Kk3zFx14dAO4SY6Q20Lrv8rNWWGc,1075
3
3
  hcs_core/ctxp/_init.py,sha256=fMcRMPfJx-N0c-u0Zj2sFVKQL1-lWQd28gooAZETGUA,2933
4
4
  hcs_core/ctxp/cli_options.py,sha256=cwlUgYXzIie9eRcu8fkBo_iFvC8LhflKGblWYtM2Hto,2739
@@ -60,10 +60,10 @@ hcs_core/util/exit.py,sha256=UStMZKlfCFN7GBouc1y3pPFGPFQ66qfcRZ_fYQXFD0E,838
60
60
  hcs_core/util/hcs_constants.py,sha256=Ic1Tx_UNJiQchfsdnRDzgiOaCjKHnsWXx997nElppm4,1755
61
61
  hcs_core/util/job_view.py,sha256=LpyihmDJLXm4DtTST7Z-WydyWNYCJETT_SxCWunvGOg,8424
62
62
  hcs_core/util/pki_util.py,sha256=Lt3-IzIoGcaQKNE7KUszxR7JSZkpXduVZJ262TszsIs,6685
63
- hcs_core/util/query_util.py,sha256=5bh3bUVIQuY9qerndfuyfyzkTExYJ8zD0_e3PSN7y-4,3142
63
+ hcs_core/util/query_util.py,sha256=uYfcEF_00eUs_S5OK64zpH0cnb6dwy91_J1OY5ZrFVs,3471
64
64
  hcs_core/util/scheduler.py,sha256=bPpCmGUL1UctJMfLPAg-h4Hl2YZr96FiI78-G_Usn08,2958
65
65
  hcs_core/util/ssl_util.py,sha256=MvU102fGwWWh9hhSmLnn1qQIWuD6TjZnN0iH0MXUtW0,1239
66
66
  hcs_core/util/versions.py,sha256=6nyyZzi3P69WQfioPc2_YWZQcUc13mC1eKoK58b3WUQ,1709
67
- hcs_core-0.1.302.dist-info/METADATA,sha256=df0XFaK0uAZAHRvEOEOk4bk8FoS8C7yLST84z6OdGNk,1951
68
- hcs_core-0.1.302.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
69
- hcs_core-0.1.302.dist-info/RECORD,,
67
+ hcs_core-0.1.304.dist-info/METADATA,sha256=YmjzFD1Ns9b36igsOBJFQWUH-CjPwPukiJGjFpJm1lg,1951
68
+ hcs_core-0.1.304.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
69
+ hcs_core-0.1.304.dist-info/RECORD,,