python3: remove not necessary temp list

parent fb4e4583
......@@ -65,7 +65,7 @@ def main(host=None, user=None, passwd=None):
else:
properties[name] = [values, value]
for node in list(server2nodes.values()):
for node in server2nodes.values():
node.save()
......
......@@ -516,7 +516,7 @@ class MDClient(ExporterClient):
def createStringFromDict(self, motor_position_dict):
ret = ""
for motor in list(motor_position_dict.keys()):
for motor in motor_position_dict.keys():
ret += motor + "=" + str(motor_position_dict[motor]) + ","
return ret
......@@ -541,7 +541,7 @@ class MDClient(ExporterClient):
def getMotorPositions(self):
array = self.readPropertyAsStringArray(self.PROPERTY_MOTOR_POSITIONS)
dict = self.createDictFromStringList(array)
for key in list(dict.keys()):
for key in dict.keys():
dict[key] = float(dict[key])
return dict
......
......@@ -561,7 +561,7 @@ class ModbusTcp:
modbus._connected = False
modbus._fd = None
# inform all pending requests that the socket closed
for trans in list(modbus._transaction.values()):
for trans in modbus._transaction.values():
trans.put(socket.error(errno.EPIPE, "Broken pipe"))
except ReferenceError:
pass
......@@ -158,7 +158,7 @@ class _ServerObject(object):
def __dir__(self):
result = ["zerorpc_call__"]
for name, info in list(self._metadata["members"].items()):
for name, info in self._metadata["members"].items():
if "method" in info["type"]:
result.append(name)
return result
......@@ -332,7 +332,7 @@ def Client(address, **kwargs):
stream = metadata.get("stream", False)
members = dict(_client=client)
for name, info in list(metadata["members"].items()):
for name, info in metadata["members"].items():
if name.startswith("__") and name[2:-2] in SPECIAL_METHODS:
continue
name, mtype, doc = info["name"], info["type"], info["doc"]
......
......@@ -46,17 +46,17 @@ from .exceptions import CommunicationError, CommunicationTimeout
def decode_IDN(s):
manuf, model, serial, version = list(map(str.strip, s.split(",")))
manuf, model, serial, version = map(str.strip, s.split(","))
return dict(manufacturer=manuf, model=model, serial=serial, version=version)
def __decode_Err(s):
code, desc = list(map(str.strip, s.split(",", 1)))
code, desc = map(str.strip, s.split(",", 1))
return dict(code=int(code), desc=desc[1:-1])
def __decode_ErrArray(s):
msgs = list(map(str.strip, s.split(",")))
msgs = map(str.strip, s.split(","))
result = []
for i in range(0, len(msgs), 2):
code, desc = int(msgs[i]), msgs[i + 1][1:-1]
......@@ -284,7 +284,7 @@ class Commands(object):
try:
return self._command_cache[cmd_name_u]
except KeyError:
for cmd_expr, cmd_info in list(self.command_expressions.items()):
for cmd_expr, cmd_info in self.command_expressions.items():
reg_expr = cmd_info["re"]
if reg_expr.match(cmd_name):
self._command_cache[cmd_name.upper()] = cmd_expr
......@@ -302,7 +302,7 @@ class Commands(object):
self.command_expressions.update(commands.command_expressions)
self._command_cache.update(commands._command_cache)
elif isinstance(commands, dict):
for cmd_expr, cmd in list(commands.items()):
for cmd_expr, cmd in commands.items():
self[cmd_expr] = cmd
else:
for cmd_expr, cmd in commands:
......@@ -779,7 +779,7 @@ def main(argv=None):
)
add(
"--parity",
choices=list(serial.PARITY_NAMES.keys()),
choices=serial.PARITY_NAMES.keys(),
default=serial.PARITY_NONE,
help="parity type",
)
......
......@@ -405,7 +405,7 @@ class RFC2217(_BaseSerial):
self._socket.send(telnet_sub_cmd.data)
telnet_sub_cmd.data = b""
items = list(self.rfc2217_port_settings.values())
items = self.rfc2217_port_settings.values()
while 1:
self._parse_nego(telnet_cmd)
if sum(o.active for o in items) == len(items):
......@@ -500,7 +500,7 @@ class RFC2217(_BaseSerial):
elif suboption == FLOWCONTROL_RESUME:
self._remote_suspend_flow = False
else:
for item in list(self.rfc2217_options.values()):
for item in self.rfc2217_options.values():
if item.ack_option == suboption:
item.check_answer(value)
break
......@@ -625,7 +625,7 @@ class TangoSerial(_BaseSerial):
get_object_proxy(device).set_timeout_millis(int(timeout * 1000))
args = []
kwargs["eol"] = cnt._eol
for arg, (key, encode) in list(self.PAR_MAP.items()):
for arg, (key, encode) in self.PAR_MAP.items():
args.append(arg)
args.append(encode(self, kwargs[key]))
device.DevSerSetParameter(args)
......
......@@ -123,7 +123,7 @@ class BaseSpecCommand:
# convert args list to string args list
# it is much more convenient using .call('psvo', 12) than .call('psvo', '12')
# a possible problem will be seen in Spec
args = list(map(repr, args))
args = map(repr, args)
if func:
# macro function
......
......@@ -109,7 +109,7 @@ def dictionarytoraw(dict):
"""Transform a Python dictionary object to the string format
expected by Spec"""
data = ""
for key, val in list(dict.items()):
for key, val in dict.items():
if isinstance(val, dict):
for kkey, vval in val.items():
if kkey is None:
......
......@@ -68,7 +68,7 @@ def get_interface(*args, **kwargs):
from .udp import Udp
interfaces = dict(serial=Serial, gpib=Gpib, tcp=Tcp, udp=Udp)
for iname, iclass in list(interfaces.items()):
for iname, iclass in interfaces.items():
if iname in kwargs:
ikwargs = kwargs.pop(iname)
if isinstance(ikwargs, dict):
......@@ -221,7 +221,7 @@ class HexMsg:
self.msg = msg
def __str__(self):
return " ".join(map(hex, list(map(ord, self.msg))))
return " ".join(map(hex, map(ord, self.msg)))
def __repr__(self):
return "[{0}]".format(self)
......@@ -139,7 +139,7 @@ class GroupMove(object):
)
monitor_move[motion] = task
try:
gevent.joinall(list(monitor_move.values()), raise_error=True)
gevent.joinall(monitor_move.values(), raise_error=True)
finally:
# update the last motor state
for motion, task in monitor_move.items():
......@@ -1553,7 +1553,7 @@ class Axis(object):
def limit2config(l):
return self.user2dial(l) if l is not None else l
ll, hl = list(map(limit2config, self.limits))
ll, hl = map(limit2config, self.limits)
self.__config.set("low_limit", ll)
self.__config.set("high_limit", hl)
if any((velocity, acceleration, limits)):
......@@ -1802,7 +1802,7 @@ class AxisState(object):
if self._state_desc.get(state)
else "",
)
for state in map(str, list(self._current_states))
for state in map(str, self._current_states)
]
if len(states) == 0:
......
......@@ -33,7 +33,7 @@ def get_all():
"""
return [
x
for x in list(setup_globals.__dict__.values())
for x in setup_globals.__dict__.values()
if isinstance(x, MeasurementGroup) and x != ACTIVE_MG
]
......@@ -44,7 +44,7 @@ def get_all_names():
"""
return [
x.name
for x in list(setup_globals.__dict__.values())
for x in setup_globals.__dict__.values()
if isinstance(x, MeasurementGroup) and x != ACTIVE_MG
]
......
......@@ -26,7 +26,7 @@ def Group(*axes_list):
def check_axes(*axes_to_check):
from bliss.controllers.motor import CalcController
grp_axes = list(axes.values())
grp_axes = axes.values()
for axis in axes_to_check:
if isinstance(axis.controller, CalcController):
names = [
......@@ -42,7 +42,7 @@ def Group(*axes_list):
# also check reals, that can be calc axes themselves too
check_axes(*axis.controller.reals)
check_axes(*list(axes.values()))
check_axes(*axes.values())
# always use the same group name for groups of same axes,
# this is to make sure master name will stay the same
......
......@@ -365,7 +365,7 @@ class BasePlot(object):
else:
data_dict = OrderedDict((field, data[field]) for field in fields)
# Send data
for field, value in list(data_dict.items()):
for field, value in data_dict.items():
self.add_single_data(field, value)
# Return data dict
return data_dict
......
......@@ -49,7 +49,7 @@ class _StringImporter(object):
return None
def load_module(self, fullname):
if not fullname in list(self._modules.keys()):
if not fullname in self._modules.keys():
raise ImportError(fullname)
filename = self._modules.get(fullname)
......@@ -75,7 +75,7 @@ class _StringImporter(object):
return new_module
def get_source(self, fullname):
if not fullname in list(self._modules.keys()):
if not fullname in self._modules.keys():
raise ImportError(fullname)
filename = self._modules.get(fullname)
......@@ -298,9 +298,7 @@ class Session(object):
tree.create_node(tag=self.name, identifier=self)
tree = self._build_children_tree(tree, self, children)
multiple_ref_child = [
(name, parents)
for name, (ref, parents) in list(children.items())
if ref > 1
(name, parents) for name, (ref, parents) in children.items() if ref > 1
]
if multiple_ref_child:
msg = "Session %s as cyclic references to sessions:\n" % self.name
......
......@@ -171,7 +171,7 @@ class Shutter(object):
if value not in self.MODE2STR:
raise ValueError(
"Mode can only be: %s"
% ",".join((x[0] for x in list(self.MODE2STR.values())))
% ",".join((x[0] for x in self.MODE2STR.values()))
)
self.init()
self._set_mode(value)
......
......@@ -296,7 +296,7 @@ def __umove(*args, **kwargs):
group, motor_pos = __move(*args, **kwargs)
with error_cleanup(group.stop):
motor_names = [axis.name for axis in motor_pos]
col_len = max(max(list(map(len, motor_names))), 8)
col_len = max(max(map(len, motor_names)), 8)
hfmt = "^{width}".format(width=col_len)
rfmt = ">{width}.03f".format(width=col_len)
print("")
......@@ -321,7 +321,7 @@ def __move(*args, **kwargs):
motor_pos = OrderedDict()
for m, p in zip(get_objects_iter(*args[::2]), args[1::2]):
motor_pos[m] = p
group = Group(*list(motor_pos.keys()))
group = Group(*motor_pos.keys())
group.move(motor_pos, wait=wait, relative=relative)
return group, motor_pos
......@@ -465,7 +465,7 @@ def edit_roi_counters(detector, acq_time=None):
plot = scan.get_plot(detector.image, wait=True)
selections = []
for roi_name, roi in list(roi_counters.items()):
for roi_name, roi in roi_counters.items():
selection = dict(
kind="Rectangle",
origin=(roi.x, roi.y),
......@@ -482,8 +482,8 @@ def edit_roi_counters(detector, acq_time=None):
if not label:
ignored += 1
continue
x, y = list(map(int, list(map(round, selection["origin"]))))
w, h = list(map(int, list(map(round, selection["size"]))))
x, y = map(int, map(round, selection["origin"]))
w, h = map(int, map(round, selection["size"]))
rois.append((x, y, w, h))
roi_labels.append(label)
if ignored:
......
......@@ -456,7 +456,7 @@ def common_prefix(paths, sep=os.path.sep):
def allnamesequal(name):
return all(n == name[0] for n in name[1:])
bydirectorylevels = list(zip(*[p.split(sep) for p in paths]))
bydirectorylevels = zip(*[p.split(sep) for p in paths])
return sep.join(x[0] for x in itertools.takewhile(allnamesequal, bydirectorylevels))
......@@ -490,7 +490,7 @@ class Statistics(object):
def __init__(self, profile):
self._profile = {
key: numpy.array(values, dtype=numpy.float)
for key, values in list(profile.items())
for key, values in profile.items()
}
@property
......@@ -499,8 +499,7 @@ class Statistics(object):
elapsed time function
"""
return {
key: values[:, 1] - values[:, 0]
for key, values in list(self._profile.items())
key: values[:, 1] - values[:, 0] for key, values in self._profile.items()
}
@property
......@@ -510,7 +509,7 @@ class Statistics(object):
"""
return {
key: (values.min(), values.mean(), values.max(), values.std())
for key, values in list(self.elapsed_time.items())
for key, values in self.elapsed_time.items()
}
def __repr__(self):
......
......@@ -139,7 +139,7 @@ class WebConfig(object):
def __build_tree_sessions(self):
cfg = self.get_config()
sessions = {}
for name, item in list(self.items.items()):
for name, item in self.items.items():
config = cfg.get_config(name)
if config.plugin != "session":
continue
......@@ -152,7 +152,7 @@ class WebConfig(object):
def __build_tree_items(self):
items = self.items
result = {}
for name, item in list(items.items()):
for name, item in items.items():
current_level = result
db_file = item["path"]
parts = db_file.split(os.path.sep)
......@@ -172,7 +172,7 @@ class WebConfig(object):
def __build_tree_plugins(self):
cfg = self.get_config()
result = {}
for name, item in list(self.items.items()):
for name, item in self.items.items():
config = cfg.get_config(name)
plugin_name = config.plugin or "__no_plugin__"
plugin_data = result.get(plugin_name)
......@@ -189,7 +189,7 @@ class WebConfig(object):
def __build_tree_tags(self):
cfg = self.get_config()
result = {}
for name, item in list(self.items.items()):
for name, item in self.items.items():
config = cfg.get_config(name)
for tag in item["tags"] or ["__no_tag__"]:
tag_data = result.get(tag)
......@@ -244,7 +244,7 @@ class WebConfig(object):
return dst
def __build_tree_files__(self, src, dst, path=""):
for name, data in list(src.items()):
for name, data in src.items():
if name.startswith(".") or name.endswith("~") or name.endswith(".rdb"):
continue
item_path = os.path.join(path, name)
......@@ -371,7 +371,7 @@ def main():
@web_app.route("/db_files")
def db_files():
cfg = __config.get_config()
db_files, _ = list(zip(*client.get_config_db_files()))
db_files, _ = zip(*client.get_config_db_files())
return flask.json.dumps(db_files)
......@@ -414,7 +414,7 @@ def get_db_file_editor(filename):
def items():
cfg = __config.get_config()
db_files, _ = list(map(list, list(zip(*client.get_config_db_files()))))
db_files, _ = map(list, zip(*client.get_config_db_files()))
for name in cfg.names_list:
config = cfg.get_config(name)
......
......@@ -427,7 +427,7 @@ def get_channel_html(cfg):
def get_card_html(cfg):
cfg = dict(list(cfg.items()))
cfg = dict(cfg.items())
card_type = cfg.get("class")
card_class = card.get_ct2_card_class(card_type)
cts = cfg.setdefault("counters", [])
......@@ -527,11 +527,11 @@ def card_edit(cfg, request):
cfg, counters, channels = {}, {}, {}
# handle generic card parameters
for p_name, p_info in list(GENERAL_PARAMS.items()):
for p_name, p_info in GENERAL_PARAMS.items():
cfg[p_name] = value_to_config(form, p_name, p_info)
# handle counter parameters
for p_name, p_info in list(COUNTER_PARAMS.items()):
for p_name, p_info in COUNTER_PARAMS.items():
if p_name == "address":
continue
for counter in card_class.COUNTERS:
......@@ -540,7 +540,7 @@ def card_edit(cfg, request):
ct[p_name] = value_to_config(form, ct_p_name, p_info)
# handle input channels parameters
for p_name, p_info in list(IN_CHANNEL_PARAMS.items()):
for p_name, p_info in IN_CHANNEL_PARAMS.items():
if p_name == "address":
continue
for channel in card_class.INPUT_CHANNELS:
......@@ -549,7 +549,7 @@ def card_edit(cfg, request):
ch[p_name] = value_to_config(form, ch_p_name, p_info)
# handle output channels parameters
for p_name, p_info in list(OUT_CHANNEL_PARAMS.items()):
for p_name, p_info in OUT_CHANNEL_PARAMS.items():
if p_name == "address":
continue
for channel in card_class.OUTPUT_CHANNELS:
......@@ -560,7 +560,7 @@ def card_edit(cfg, request):
cfg["counters"] = [counters[ct] for ct in sorted(counters)]
cfg["channels"] = [channels[ch] for ch in sorted(channels)]
card_cfg.update([(k, v) for k, v in list(cfg.items())])
card_cfg.update([(k, v) for k, v in cfg.items()])
card_cfg.save()
result["message"] = "'%s' configuration applied!" % card_name
......
......@@ -58,7 +58,7 @@ def __get_empty_main(cfg):
def edit(cfg, request):
if request.method == "POST":
for k, v in list(request.form.items()):
for k, v in request.form.items():
cfg.root[k] = v
cfg.root.save()
......
......@@ -97,12 +97,12 @@ def get_axis_html(cfg):
name = cfg["name"]
ctrl_class = cfg.parent.get("class")
ctrl_name = cfg.parent.get("name")
vars = dict(list(cfg.items()))
vars = dict(cfg.items())
filename = "emotion_" + ctrl_class + "_axis.html"
html_template = get_jinja2().select_template([filename, "emotion_axis.html"])
extra_params = {}
for key, value in list(vars.items()):
for key, value in vars.items():
if key not in __KNOWN_AXIS_PARAMS:
extra_params[key] = dict(name=key, label=key.capitalize(), value=value)
......@@ -126,13 +126,13 @@ def get_axis_html(cfg):
def get_ctrl_html(cfg):
ctrl_class = cfg.get("class")
vars = dict(list(cfg.items()))
vars = dict(cfg.items())
filename = "emotion_" + ctrl_class + ".html"
html_template = get_jinja2().select_template([filename, "emotion_controller.html"])
extra_params = []
for key, value in list(vars.items()):
for key, value in vars.items():
if key not in __KNOWN_CONTROLLER_PARAMS:
extra_params.append(dict(name=key, label=key.capitalize(), value=value))
......@@ -189,7 +189,7 @@ def controller_edit(cfg, request):
import flask.json
if request.method == "POST":
form = dict([(k, v) for k, v in list(request.form.items()) if v])
form = dict([(k, v) for k, v in request.form.items() if v])
update_server = form.pop("__update_server__") == "true"
orig_name = form.pop("__original_name__")
name = form.get("name", orig_name)
......@@ -203,7 +203,7 @@ def controller_edit(cfg, request):
axes_data = {}
objs = set()
for param_name, param_value in list(form.items()):
for param_name, param_value in form.items():
if " " in param_name: # axis param
param_name, axis_name = param_name.split()
obj = cfg.get_config(axis_name)
......@@ -249,7 +249,7 @@ def axis_edit(cfg, request):
import flask.json
if request.method == "POST":
form = dict([(k, v) for k, v in list(request.form.items()) if v])
form = dict([(k, v) for k, v in request.form.items() if v])
update_server = form.pop("__update_server__") == "true"
orig_name = form.pop("__original_name__")
name = form["name"]
......@@ -386,7 +386,7 @@ def create_objects_from_config_node(config, node):
controller._init()
all_names = axes_names + encoders_names + switches_names + shutters_names
cache_dict = dict(list(zip(all_names, [controller] * len(all_names))))
cache_dict = dict(zip(all_names, [controller] * len(all_names)))
ctrl = cache_dict.pop(obj_name, None)
if ctrl is not None:
obj = create_object_from_cache(None, obj_name, controller)
......
......@@ -39,14 +39,14 @@ def create_objects_from_config_node(config, item_cfg_node):
for category in ("inputs", "outputs", "ctrl_loops"):
try:
cache_dict.update(
dict(list(zip(names[category], [controller] * len(names[category]))))
dict(zip(names[category], [controller] * len(names[category])))
)
except KeyError:
pass
# controller.initialize()
o = controller.get_object(item_name)
if item_name in list(dict(loops).keys()):
if item_name in dict(loops).keys():
referenced_object = o.config["input"][1:]
if referenced_object in controller._objects:
# referencing an object in same controller
......
......@@ -442,7 +442,7 @@ class QueueSetting(object):
def __setitem__(self, ran, value, cnx=None):
if isinstance(ran, slice):
for i, v in zip(list(range(ran.start, ran.stop)), value):
for i, v in zip(range(ran.start, ran.stop), value):
self.set_item(v, pos=i, cnx=cnx)
elif isinstance(ran, int):
self.set_item(value, pos=ran, cnx=cnx)
......@@ -776,10 +776,10 @@ class Struct(object):
self._proxy = HashSetting(name, **keys)
def __dir__(self):
return list(self._proxy.keys())
return self._proxy.keys()
def __repr__(self):
return "<Struct with attributes: %s>" % list(self._proxy.keys())
return "<Struct with attributes: %s>" % self._proxy.keys()
def __getattribute__(self, name):
if name.startswith("_"):
......@@ -854,7 +854,7 @@ class Parameters(object, metaclass=ParametersType):
self.add(key)
def __dir__(self):
keys = [x for x in list(self._proxy.keys()) if not x.startswith("_")]
keys = [x for x in self._proxy.keys() if not x.startswith("_")]
return keys + ["add", "remove", "switch", "configs", "to_dict", "from_dict"]
def to_dict(self):
......@@ -902,7 +902,7 @@ class Parameters(object, metaclass=ParametersType):
basename = ":".join(self._proxy._name.split(":")[:-1])
self._proxy._name = "%s:%s" % (basename, name)
for key in list(self._proxy.keys()):