Skip to content
Snippets Groups Projects
Commit 2019d066 authored by Egor Sobolev's avatar Egor Sobolev
Browse files

Apply suggestions: style and legacy control data protection


Co-authored-by: default avatarPhilipp Schmidt <philipp.schmidt@xfel.eu>
parent 6075f802
No related branches found
No related tags found
1 merge request!25Support legacy sources
......@@ -119,7 +119,8 @@ class SourceDataWriter:
after_base = perf_counter()
self.write_control(
f, [sd for sd in sources if sd.is_control])
f, [sd for sd in sources
if sd.is_control and not sd.is_legacy])
after_control = perf_counter()
self.write_instrument(
......@@ -180,8 +181,8 @@ class SourceDataWriter:
instrument_src = f.create_instrument_source(source)
instrument_src.create_index(**index_group_counts)
for source in legacy_sources:
f.create_legacy_source(source.source, source.canonical_name)
for sd in legacy_sources:
f.create_legacy_source(sd.source, sd.canonical_name)
def write_control(self, f, sources):
"""Write CONTROL and RUN data.
......@@ -480,15 +481,18 @@ def build_sources_index(sources):
def get_legacy_sources(sources):
legacy_sources = []
channels = []
for source in sources:
if not source.is_legacy:
for sd in sources:
if not sd.is_legacy:
continue
legacy_sources.append(source)
if source.source.endswith(":xtdf"):
channels.append(source.source + "/image")
if sd.is_control:
raise ValueError(
"Legacy source name is not supported for CONTROL data")
legacy_sources.append(sd)
if sd.source.endswith(":xtdf"):
channels.append(sd.source + "/image")
else:
channels.extend(
(f"{source.source}/{grp}" in source.index_groups))
(f"{sd.source}/{grp}" for grp in sd.index_groups))
return legacy_sources, channels
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment