fix(bridge/python): inconsistent indentation TabError

This commit is contained in:
Divlo
2023-05-20 19:49:07 +02:00
parent de17719537
commit ebaa3c4f9b
3 changed files with 39 additions and 33 deletions
-1
View File
@@ -12,5 +12,4 @@ end_of_line = lf
insert_final_newline = true
[*.py]
indent_style = tab
indent_size = 4
+25 -22
View File
@@ -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]
@@ -25,10 +27,10 @@ class Leon:
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
@@ -56,21 +58,21 @@ class Leon:
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': {
@@ -85,8 +87,8 @@ class Leon:
output['output']['widget'] = answer_input['widget']
answer_object = {
**INTENT_OBJECT,
**output
**INTENT_OBJECT,
**output
}
# Temporize for the data buffer output on the core
@@ -97,4 +99,5 @@ class Leon:
except Exception as e:
print('Error while creating answer:', e)
leon = Leon()
+14 -10
View File
@@ -2,21 +2,25 @@ from typing import Dict, Any, Optional, List
# 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]
class AnswerData:
pass
class AnswerInput:
key: Optional[str]
widget: Any
data: Optional[AnswerData]
core: Dict[str, Any]
class AnswerConfig:
text: str
speech: str
text: str
speech: str