**Update Lingua Franca to v0.4.1**
The update from Lingua Franca v0.2.x to v0.4.x includes few
breaking changes.
- Some API methods have been updated.
- Mycroft-core tests have been updated to reflect improvements in
Lingua Franca's formatting and parsing.
- add LF default lang setting method to config.locale
including warning that this method will change in the future
- Add TODO's for 21.08 - moving more methods to LF
- simplify loading and setting default of languages in Skills service
- Remove unneeded wrappers for Lingua Franca functions
- Fix documentation of format and parse utils
- Fix test warnings
The api methods are now much easier to use, almost transparent. The
current caveat is that only "standarad" python types are acceptable
(int, float, str, list, bool, None) due to the json serialization.
- api methods are now created with the skill_api_method decorator
- both arguments and keyword arguments are sent to the api method
instead of the message object
- api methods now uses a normal return statement instead of having to
handle creating response messages on the bus.
For example if the datetime skill wants to make the datetime string
fetchable simply add the skill_api_method decorator to the
get_display_date method.
@skill_api_method
def get_display_date(self, day=None, location=None):
"""Returns the date and time as a string."""
[...]
The methods return value will be sent back to the caller and can be used
from a skill through
datetime = SkillApi.get('mycroft-date-time.mycroftai')
self.log.info(datetime.get_display_date())
The skill api allows skills to define a public api which can easily be
accessed by other skills over the message bus just as easy as working
with a normal object.
The skill api object is generated from the skill's public_api property. It's a dict where each key is turned into a method on the api object. The method is defined as
"api_method": {
"type": message type string
"func": handler method
"help": help string for cli
}
Example skill:
class Test2(MycroftSkill):
def __init__(self):
MycroftSkill.__init__(self)
self.public_api = {
'speak': {
'type': 't2.speak',
'func': self.handle_speak,
'help': 'speak the test sentence\nand another line\n\nlast'
},
'speak2': {
'type': 't2.speak2',
'func': self.handle_speak2,
'help': 'speak the other sentence'
}
}
def handle_speak(self, message):
self.speak('This is a test')
self.bus.emit(message.response(data=None))
def handle_speak2(self, message):
self.speak('This is another test')
self.bus.emit(message.response(data=None))
When mycroft_skill.find_resource fails to load a resource for self.lang
fall back to lang 'en-us'
as most skills/resources are available in english by default.
==== Fixed Issues ====