Skip to content
Snippets Groups Projects
Commit 2e03c956 authored by jkerdreu's avatar jkerdreu
Browse files

Golang uses tab instead of space for indenting

Fix the template for avoid gofmt large changes



git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@3231 b32b6428-25c9-4566-ad07-03861ab6144f
parent e642bcf1
Branches
No related tags found
No related merge requests found
//=====================================================================
// =====================================================================
func New${Name}(addr uuid.UUID) *xaal.Device {
dev := xaal.NewDevice("${devtype}")
dev.Address = addr
% if (len(attributes) !=0):
dev := xaal.NewDevice("${devtype}")
dev.Address = addr
% if (len(attributes) !=0):
// -------- Attributes --------
% for attr in attributes:
// -------- Attributes --------
% for attr in attributes:
<%
dm = datamodel[attributes[attr]]
desc = dm.get('description','no-desc ?')
type_ = dm.get('type')
unit = dm.get('unit')
comment = desc
if type_:
comment = comment +' | type: ' + type_
if unit:
comment = comment +' | unit: ' + unit
%> // ${comment}
dm = datamodel[attributes[attr]]
desc = dm.get('description','no-desc ?')
type_ = dm.get('type')
unit = dm.get('unit')
comment = desc
if type_:
comment = comment +' | type: ' + type_
if unit:
comment = comment +' | unit: ' + unit
%> // ${comment}
<%
type_ = dm.get('type')
value = 'nil'
if type_ == 'data = bool':
value = 'false'
elif type_ in ['data = uint','data = number']:
value = 0
elif unit in ['K']:
value = 0
elif unit in ['%','%EL','%RH','°']:
value = 0.0
%> dev.AddAttribute("${attr}",${value})
% endfor
% endif
% if (len(methods) !=0):
type_ = dm.get('type')
value = 'nil'
if type_ == 'data = bool':
value = 'false'
elif type_ in ['data = uint','data = number']:
value = 0
elif unit in ['K']:
value = 0
elif unit in ['%','%EL','%RH','°']:
value = 0.0
%> dev.AddAttribute("${attr}", ${value})
% endfor
% endif
% if (len(methods) !=0):
// -------- Methods --------
% for meth in methods:
// -------- Methods --------
% for meth in methods:
<%
keys = list(methods[meth].get('in',{}).keys())
print_keys = ', '.join(keys)
camel_meth = "default"+ f"{meth}".replace('_','.').title().replace('.','')
keys = list(methods[meth].get('in',{}).keys())
print_keys = ', '.join(keys)
camel_meth = "default"+ f"{meth}".replace('_','.').title().replace('.','')
%> // ${methods[meth]['description']}
% if len(keys) != 0 :
${camel_meth} := func(args xaal.MessageBody) *xaal.MessageBody {
// Arguments: ${print_keys}
fmt.Printf("default ${meth}: %v\n", args)
% else:
${camel_meth} := func(xaal.MessageBody) *xaal.MessageBody {
fmt.Printf("default ${meth}\n")
% endif
return nil
}
% endfor
% for meth in methods:
%> // ${methods[meth]['description']}
% if len(keys) != 0 :
${camel_meth} := func(args xaal.MessageBody) *xaal.MessageBody {
// Arguments: ${print_keys}
fmt.Printf("default ${meth}: %v\n", args)
% else:
${camel_meth} := func(xaal.MessageBody) *xaal.MessageBody {
fmt.Printf("default ${meth}\n")
% endif
return nil
}
% endfor
% for meth in methods:
<%
camel_meth = "default"+f"{meth}".replace('_','.').title().replace('.','')
%> dev.AddMethod("${meth}", ${camel_meth})
% endfor
% endif
camel_meth = "default"+f"{meth}".replace('_','.').title().replace('.','')
%> dev.AddMethod("${meth}", ${camel_meth})
% endfor
% endif
return dev
return dev
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment