Skip to content

Commit

Permalink
Go back to named regex group for detector name
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Oct 4, 2024
1 parent 997ae1d commit 56e4f29
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions extra_data/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,12 @@ def _combine_bitfield(ints):
@classmethod
def _find_detector_names(cls, data):
# Find sources matching the pattern (raw or proc) for this detector type
raw_re = re.compile(f'({cls._det_name_pat}){cls._source_raw_pat}')
corr_re = re.compile(f'({cls._det_name_pat}){cls._source_corr_pat}')
raw_re = re.compile(f'(?P<detname>{cls._det_name_pat}){cls._source_raw_pat}')
corr_re = re.compile(f'(?P<detname>{cls._det_name_pat}){cls._source_corr_pat}')
detector_names = set()
for source in data.instrument_sources:
m = raw_re.match(source) or corr_re.match(source)
if m:
detector_names.add(m.group(1))
if m := raw_re.match(source) or corr_re.match(source):
detector_names.add(m['detname'])
return detector_names

@classmethod
Expand Down

0 comments on commit 56e4f29

Please sign in to comment.