git://git.onelab.eu
/
tests.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
one layer of polish
[tests.git]
/
system
/
TestMapper.py
diff --git
a/system/TestMapper.py
b/system/TestMapper.py
index
7d0547f
..
9a8ea67
100644
(file)
--- a/
system/TestMapper.py
+++ b/
system/TestMapper.py
@@
-13,73
+13,75
@@
import utils
class TestMapper:
class TestMapper:
- def __init__
(self,plcs,options):
- self.plcs
=
plcs
- self.options
=
options
+ def __init__(self,plcs,options):
+ self.plcs
=
plcs
+ self.options
=
options
@staticmethod
@staticmethod
- def plc_name
(plc):
+ def plc_name(plc):
return plc['name']
@staticmethod
return plc['name']
@staticmethod
- def node_name
(node):
+ def node_name(node):
return node['name']
return node['name']
- def node_names
(self):
- result
=
[]
+ def node_names(self):
+ result
=
[]
for plc in self.plcs:
for site in plc['sites']:
for node in site['nodes']:
result.append(node['name'])
return result
for plc in self.plcs:
for site in plc['sites']:
for node in site['nodes']:
result.append(node['name'])
return result
- def apply_first_map
(self, type, name, obj, maplist):
+ def apply_first_map(self, type, name, obj, maplist):
for (map_pattern,rename_dict) in maplist:
if utils.match (name,map_pattern):
if self.options.verbose:
for (map_pattern,rename_dict) in maplist:
if utils.match (name,map_pattern):
if self.options.verbose:
- utils.header("TestMapper/%s : applying rules '%s' on %s"%(type,map_pattern,name))
+ utils.header("TestMapper/{} : applying rules '{}' on {}"\
+ .format(type, map_pattern, name))
for (k,v) in rename_dict.iteritems():
# apply : separator
for (k,v) in rename_dict.iteritems():
# apply : separator
- path
=
k.split(':')
+ path
=
k.split(':')
# step down but last step in path
# step down but last step in path
- o
=
obj
+ o
=
obj
for step in path[:-1]:
if not o.has_key(step):
for step in path[:-1]:
if not o.has_key(step):
- o[step]
=
{}
+ o[step]
=
{}
if self.options.verbose:
if self.options.verbose:
- utils.header ("WARNING : created step
%s in path %s on %s %s"%(
- step,path,type,name))
- o
=
o[step]
+ utils.header ("WARNING : created step
{} in path {} on {} {}"\
+
.format(
step,path,type,name))
+ o
=
o[step]
# last step is the one for side-effect
# last step is the one for side-effect
- step
=
path[-1]
+ step
=
path[-1]
if self.options.verbose:
if not o.has_key(step):
if self.options.verbose:
if not o.has_key(step):
- utils.header ("WARNING : inserting key
%s for path %s on %s %s"%(
-
step,path,type,
name))
+ utils.header ("WARNING : inserting key
{} for path {} on {} {}"\
+
.format(step, path, type,
name))
# apply formatting if '%s' found in the value
if v is None:
if self.options.verbose: print "TestMapper WARNING - None value - ignored, key=",k
continue
# apply formatting if '%s' found in the value
if v is None:
if self.options.verbose: print "TestMapper WARNING - None value - ignored, key=",k
continue
- if v.find('%s')
>=
0:
- v
=v%
obj[k]
+ if v.find('%s')
>=
0:
+ v
= v %
obj[k]
if self.options.verbose:
if self.options.verbose:
- print("TestMapper, rewriting %s: %s into %s"%(name,k,v))
- o[step]=v
+ print("TestMapper, rewriting {}: {} into {}"\
+ .format(name, k, v))
+ o[step] = v
# only apply first rule
return
# only apply first rule
return
- def map
(self,
mapper):
+ def map
(self,
mapper):
plc_maps = mapper.get('plc',[])
node_maps = mapper.get('node',[])
for plc in self.plcs:
plc_maps = mapper.get('plc',[])
node_maps = mapper.get('node',[])
for plc in self.plcs:
- name
=
TestMapper.plc_name(plc)
- self.apply_first_map
('plc',name,plc,
plc_maps)
+ name
=
TestMapper.plc_name(plc)
+ self.apply_first_map
('plc', name, plc,
plc_maps)
for site in plc['sites']:
for node in site['nodes']:
nodename = TestMapper.node_name(node)
for site in plc['sites']:
for node in site['nodes']:
nodename = TestMapper.node_name(node)
- self.apply_first_map('node',
nodename,node,
node_maps)
+ self.apply_first_map('node',
nodename, node,
node_maps)
return self.plcs
return self.plcs