Skip to content

Commit

Permalink
fix(bridge/python): inconsistent indentation TabError
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig committed May 20, 2023
1 parent de17719 commit ebaa3c4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ end_of_line = lf
insert_final_newline = true

[*.py]
indent_style = tab
indent_size = 4
47 changes: 25 additions & 22 deletions bridges/python/src/sdk/leon.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import random
import sys
import json
from time import sleep

from types import
from .types import AnswerInput
from ..constants import SKILL_SRC_CONFIG, SKILL_CONFIG, INTENT_OBJECT


class Leon:
instance: 'Leon' = None
instance: 'Leon' = None

def __init__(self) -> None:
if not Leon.instance:
Leon.instance = self
def __init__(self) -> None:
if not Leon.instance:
Leon.instance = self

def get_src_config(self, key: str = None):
"""
Get source configuration
"""
def get_src_config(self, key: str = None):
"""
Get source configuration
"""
try:
if key:
return SKILL_SRC_CONFIG[key]
Expand All @@ -25,10 +27,10 @@ def get_src_config(self, key: str = None):
print('Error while getting source configuration:', e)
return {}

def set_answer_data(self, answer_key: str, data = None):
"""
Apply data to the answer
"""
def set_answer_data(self, answer_key: str, data=None):
"""
Apply data to the answer
"""
if answer_key:
try:
# In case the answer key is a raw answer
Expand Down Expand Up @@ -56,21 +58,21 @@ def set_answer_data(self, answer_key: str, data = None):
if not isinstance(answer, str) and answer.get('text'):
answer['text'] = answer['text'].replace('%{}%'.format(key), str(value))
answer['speech'] = answer['speech'].replace('%{}%'.format(key), str(value))
else:
else:
answer = answer.replace('%{}%'.format(key), str(value))

return answer
except Exception as e:
print('Error while setting answer data:', e)
except Exception as e:
print('Error while setting answer data:', e)

return None
return None

return None

def answer(self, answer_input: AnswerInput) -> None:
"""
Send an answer to the core
"""
"""
Send an answer to the core
"""
try:
output = {
'output': {
Expand All @@ -85,8 +87,8 @@ def answer(self, answer_input: AnswerInput) -> None:
output['output']['widget'] = answer_input['widget']

answer_object = {
**INTENT_OBJECT,
**output
**INTENT_OBJECT,
**output
}

# Temporize for the data buffer output on the core
Expand All @@ -97,4 +99,5 @@ def answer(self, answer_input: AnswerInput) -> None:
except Exception as e:
print('Error while creating answer:', e)


leon = Leon()
22 changes: 13 additions & 9 deletions bridges/python/src/sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

# TODO


class AnswerData:
pass


class Answer:
key: Optional[str]
key: Optional[str]
widget: Optional[Any]
data: Optional[AnswerData]
core: Optional[Dict[str, Any]]


class AnswerInput:
key: Optional[str]
widget: Any
data: Optional[AnswerData]
core: Dict[str, Any]
key: Optional[str]
widget: Any
data: Optional[AnswerData]
core: Dict[str, Any]

class AnswerData:
pass

class AnswerConfig:
text: str
speech: str
text: str
speech: str

0 comments on commit ebaa3c4

Please sign in to comment.