Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cake-bot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleksandr Barabash
cake-bot
Commits
11ffcc52
Commit
11ffcc52
authored
Dec 06, 2022
by
Oleksandr Barabash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_first_or_none updated
parent
a12d0910
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
cosmos_client.py
utils/cosmos_client.py
+2
-1
functions.py
utils/functions.py
+2
-2
No files found.
utils/cosmos_client.py
View file @
11ffcc52
...
@@ -19,6 +19,7 @@ from entities.json.camel_case_mixin import timestamp_factory
...
@@ -19,6 +19,7 @@ from entities.json.camel_case_mixin import timestamp_factory
from
entities.json.conversation_reference
import
ConversationReference
from
entities.json.conversation_reference
import
ConversationReference
from
entities.json.initiation
import
Initiation
from
entities.json.initiation
import
Initiation
from
entities.json.notification
import
NotificationCosmos
from
entities.json.notification
import
NotificationCosmos
from
utils.functions
import
get_first_or_none
from
utils.log
import
Log
from
utils.log
import
Log
...
@@ -123,7 +124,7 @@ class CosmosClient:
...
@@ -123,7 +124,7 @@ class CosmosClient:
next_page
=
pager
.
next
()
next_page
=
pager
.
next
()
Log
.
d
(
TAG
,
f
"get_next_page_bl::next_page:{next_page},"
Log
.
d
(
TAG
,
f
"get_next_page_bl::next_page:{next_page},"
f
"list({list(next_page)})"
)
f
"list({list(next_page)})"
)
return
list
(
next_page
)[
0
]
return
get_first_or_none
(
list
(
next_page
),
list
())
except
StopIteration
:
except
StopIteration
:
Log
.
e
(
TAG
,
"get_next_page_bl:: no items found, returning '[]'"
,
Log
.
e
(
TAG
,
"get_next_page_bl:: no items found, returning '[]'"
,
exc_info
=
sys
.
exc_info
())
exc_info
=
sys
.
exc_info
())
...
...
utils/functions.py
View file @
11ffcc52
...
@@ -40,11 +40,11 @@ def get_i18n(turn_context: TurnContext,
...
@@ -40,11 +40,11 @@ def get_i18n(turn_context: TurnContext,
return
i18n
return
i18n
def
get_first_or_none
(
items
:
List
)
->
Optional
[
Dict
[
str
,
any
]]:
def
get_first_or_none
(
items
:
List
,
default
=
None
)
->
Optional
[
Dict
[
str
,
any
]]:
""" Get first object from list or return None len < 1 """
""" Get first object from list or return None len < 1 """
if
len
(
items
)
>
0
:
if
len
(
items
)
>
0
:
return
items
[
0
]
return
items
[
0
]
return
None
return
default
def
parse_auth_header
(
header
:
Optional
[
str
])
->
Tuple
[
Optional
[
str
],
def
parse_auth_header
(
header
:
Optional
[
str
])
->
Tuple
[
Optional
[
str
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment