mirror of https://github.com/nymea/nymea.git
more precise param namings and translation context strings
parent
cdf5c63b59
commit
62976cd860
|
|
@ -68,23 +68,23 @@ def extractPlugin(pluginMap):
|
||||||
|
|
||||||
# Extract plugin params (configurations)
|
# Extract plugin params (configurations)
|
||||||
if 'paramTypes' in pluginMap:
|
if 'paramTypes' in pluginMap:
|
||||||
extractParamTypes(pluginMap['paramTypes'], pluginMap['name'][0].lower() + pluginMap['name'][1:])
|
extractParamTypes(pluginMap['paramTypes'], pluginMap['name'][0].lower() + pluginMap['name'][1:], 'plugin', '')
|
||||||
|
|
||||||
if 'vendors' in pluginMap:
|
if 'vendors' in pluginMap:
|
||||||
extractVendors(pluginMap['vendors'])
|
extractVendors(pluginMap['vendors'])
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------
|
||||||
def extractParamTypes(paramTypes, contextName):
|
def extractParamTypes(paramTypes, deviceClassName, typeClass, typeName):
|
||||||
for paramType in paramTypes:
|
for paramType in paramTypes:
|
||||||
try:
|
try:
|
||||||
variableName = '%sParamTypeId' % (contextName + paramType['name'][0].capitalize() + paramType['name'][1:])
|
variableName = '%sParamTypeId' % (deviceClassName + typeName[0].capitalize() + typeName[1:] + paramType['name'][0].capitalize() + paramType['name'][1:] + typeClass)
|
||||||
if not variableName in variableNames:
|
if not variableName in variableNames:
|
||||||
variableNames.append(variableName)
|
variableNames.append(variableName)
|
||||||
printInfo('Define ParamTypeId %s = %s' % (variableName, paramType['id']))
|
printInfo('Define ParamTypeId %s = %s' % (variableName, paramType['id']))
|
||||||
if args.filetype is 'i':
|
if args.filetype is 'i':
|
||||||
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, paramType['id']))
|
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, paramType['id']))
|
||||||
addTranslationString(paramType['displayName'], 'The name of the paramType (%s) of %s' % (paramType['id'], contextName))
|
addTranslationString(paramType['displayName'], 'The name of the ParamType (DeviceClass: %s, %sType: %s, ID: %s)' % (deviceClassName, typeClass, typeName, paramType['id']))
|
||||||
createExternDefinition('ParamTypeId', variableName)
|
createExternDefinition('ParamTypeId', variableName)
|
||||||
else:
|
else:
|
||||||
printWarning('Duplicated variable name \"%s\" for ParamTypeId %s -> skipping' % (variableName, paramType['id']))
|
printWarning('Duplicated variable name \"%s\" for ParamTypeId %s -> skipping' % (variableName, paramType['id']))
|
||||||
|
|
@ -136,13 +136,13 @@ def extractDeviceClasses(deviceClasses):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if 'paramTypes' in deviceClass:
|
if 'paramTypes' in deviceClass:
|
||||||
extractParamTypes(deviceClass['paramTypes'], deviceClass['name'])
|
extractParamTypes(deviceClass['paramTypes'], deviceClass['name'], "", 'deviceClass')
|
||||||
|
|
||||||
if 'discoveryParamTypes' in deviceClass:
|
if 'discoveryParamTypes' in deviceClass:
|
||||||
extractParamTypes(deviceClass['discoveryParamTypes'], deviceClass['name'])
|
extractParamTypes(deviceClass['discoveryParamTypes'], deviceClass['name'], "", 'discovery')
|
||||||
|
|
||||||
if 'stateTypes' in deviceClass:
|
if 'stateTypes' in deviceClass:
|
||||||
extractStateTypes(deviceClass['stateTypes'], deviceClass['name'])
|
extractStateTypes(deviceClass['stateTypes'], deviceClass['name'],)
|
||||||
|
|
||||||
if 'actionTypes' in deviceClass:
|
if 'actionTypes' in deviceClass:
|
||||||
extractActionTypes(deviceClass['actionTypes'], deviceClass['name'])
|
extractActionTypes(deviceClass['actionTypes'], deviceClass['name'])
|
||||||
|
|
@ -170,7 +170,7 @@ def extractStateTypes(stateTypes, deviceClassName):
|
||||||
# Create EventTypeId for this state
|
# Create EventTypeId for this state
|
||||||
variableName = '%s%sEventTypeId' % (deviceClassName, stateType['name'][0].capitalize() + stateType['name'][1:])
|
variableName = '%s%sEventTypeId' % (deviceClassName, stateType['name'][0].capitalize() + stateType['name'][1:])
|
||||||
if not variableName in variableNames:
|
if not variableName in variableNames:
|
||||||
addTranslationString(stateType['displayNameEvent'], 'The name of the autocreated EventType (%s)' % stateType['id'])
|
addTranslationString(stateType['displayNameEvent'], 'The name of the autocreated EventType (DeviceClass: %s, StateType: %s, ID: %s)' % (deviceClassName, stateType['name'], stateType['id']))
|
||||||
variableNames.append(variableName)
|
variableNames.append(variableName)
|
||||||
printInfo('Define EventTypeId %s = %s' % (variableName, stateType['id']))
|
printInfo('Define EventTypeId %s = %s' % (variableName, stateType['id']))
|
||||||
if args.filetype is 'i':
|
if args.filetype is 'i':
|
||||||
|
|
@ -184,7 +184,7 @@ def extractStateTypes(stateTypes, deviceClassName):
|
||||||
if not variableName in variableNames:
|
if not variableName in variableNames:
|
||||||
variableNames.append(variableName)
|
variableNames.append(variableName)
|
||||||
printInfo('Define ParamTypeId %s for StateType %s = %s' % (variableName, variableName, stateType['id']))
|
printInfo('Define ParamTypeId %s for StateType %s = %s' % (variableName, variableName, stateType['id']))
|
||||||
addTranslationString(stateType['displayName'], 'The name of the ParamType of the autocreated EventType (%s) of DeviceClass %s' % (stateType['id'], deviceClassName))
|
addTranslationString(stateType['displayName'], 'The name of the ParamType for the autocreated EventType (DeviceClass: %s, StateType: %s, ID: %s' % (deviceClassName, stateType['name'], stateType['id']))
|
||||||
if args.filetype is 'i':
|
if args.filetype is 'i':
|
||||||
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, stateType['id']))
|
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, stateType['id']))
|
||||||
createExternDefinition('ParamTypeId', variableName)
|
createExternDefinition('ParamTypeId', variableName)
|
||||||
|
|
@ -198,7 +198,7 @@ def extractStateTypes(stateTypes, deviceClassName):
|
||||||
if not variableName in variableNames:
|
if not variableName in variableNames:
|
||||||
variableNames.append(variableName)
|
variableNames.append(variableName)
|
||||||
printInfo('Define ActionTypeId for writable StateType %s = %s' % (variableName, stateType['id']))
|
printInfo('Define ActionTypeId for writable StateType %s = %s' % (variableName, stateType['id']))
|
||||||
addTranslationString(stateType['displayNameAction'], 'The name of the autocreated ActionType (%s)' % stateType['id'])
|
addTranslationString(stateType['displayNameAction'], 'The name of the autocreated ActionType (DeviceClass: %s, StateType: %s, ID: %s)' % (deviceClassName, stateType['name'], stateType['id']))
|
||||||
if args.filetype is 'i':
|
if args.filetype is 'i':
|
||||||
writeToFile('ActionTypeId %s = ActionTypeId(\"%s\");' % (variableName, stateType['id']))
|
writeToFile('ActionTypeId %s = ActionTypeId(\"%s\");' % (variableName, stateType['id']))
|
||||||
createExternDefinition('ActionTypeId', variableName)
|
createExternDefinition('ActionTypeId', variableName)
|
||||||
|
|
@ -210,7 +210,7 @@ def extractStateTypes(stateTypes, deviceClassName):
|
||||||
if not variableName in variableNames:
|
if not variableName in variableNames:
|
||||||
variableNames.append(variableName)
|
variableNames.append(variableName)
|
||||||
printInfo('Define ParamTypeId %s for autocreated ActionType %s = %s' % (variableName, variableName, stateType['id']))
|
printInfo('Define ParamTypeId %s for autocreated ActionType %s = %s' % (variableName, variableName, stateType['id']))
|
||||||
addTranslationString(stateType['displayName'], 'The name of the autocreated ParamType of the writable StateType (%s) of DeviceClass %s' % (stateType['id'], deviceClassName))
|
addTranslationString(stateType['displayName'], 'The name of the ParamType for the autocreated ActionType (DeviceClass: %s, StateType: %s, ID: %s)' % (deviceClassName, stateType['name'], stateType['id']))
|
||||||
if args.filetype is 'i':
|
if args.filetype is 'i':
|
||||||
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, stateType['id']))
|
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, stateType['id']))
|
||||||
createExternDefinition('ParamTypeId', variableName)
|
createExternDefinition('ParamTypeId', variableName)
|
||||||
|
|
@ -241,7 +241,7 @@ def extractActionTypes(actionTypes, deviceClassName):
|
||||||
|
|
||||||
# Define paramTypes of this ActionType
|
# Define paramTypes of this ActionType
|
||||||
if 'paramTypes' in actionType:
|
if 'paramTypes' in actionType:
|
||||||
extractParamTypes(actionType['paramTypes'], deviceClassName)
|
extractParamTypes(actionType['paramTypes'], deviceClassName, 'Action', actionType['name'])
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
@ -263,7 +263,7 @@ def extractEventTypes(eventTypes, deviceClassName):
|
||||||
|
|
||||||
# Define paramTypes of this EventType
|
# Define paramTypes of this EventType
|
||||||
if 'paramTypes' in eventType:
|
if 'paramTypes' in eventType:
|
||||||
extractParamTypes(eventType['paramTypes'], deviceClassName)
|
extractParamTypes(eventType['paramTypes'], deviceClassName, 'Event', eventType['name'])
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue