Skip to content

Commit 5274f26

Browse files
author
Benjamin Moody
committed
Reformat header patterns using re.VERBOSE for readability.
1 parent 8053ccc commit 5274f26

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

wfdb/io/_header.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,34 @@
100100

101101
# Regexp objects for reading headers
102102
# Record line
103-
_rx_record = re.compile(''.join(
104-
["[ \t]*",
105-
"(?P<record_name>[-\w]+)/?(?P<n_seg>\d*)[ \t]+",
106-
"(?P<n_sig>\d+)[ \t]*(?P<fs>\d*\.?\d*)/*(?P<counter_freq>-?\d*\.?\d*)",
107-
"\(?(?P<base_counter>-?\d*\.?\d*)\)?[ \t]*(?P<sig_len>\d*)[ \t]*",
108-
"(?P<base_time>\d{,2}:?\d{,2}:?\d{,2}\.?\d{,6})[ \t]*",
109-
"(?P<base_date>\d{,2}/?\d{,2}/?\d{,4})"])
110-
)
103+
_rx_record = re.compile(
104+
r'''
105+
[ \t]*
106+
(?P<record_name>[-\w]+)/?(?P<n_seg>\d*)[ \t]+
107+
(?P<n_sig>\d+)[ \t]*(?P<fs>\d*\.?\d*)/*(?P<counter_freq>-?\d*\.?\d*)
108+
\(?(?P<base_counter>-?\d*\.?\d*)\)?[ \t]*(?P<sig_len>\d*)[ \t]*
109+
(?P<base_time>\d{,2}:?\d{,2}:?\d{,2}\.?\d{,6})[ \t]*
110+
(?P<base_date>\d{,2}/?\d{,2}/?\d{,4})
111+
''', re.VERBOSE)
111112

112113
# Signal line
113-
_rx_signal = re.compile(''.join(
114-
["[ \t]*",
115-
"(?P<file_name>~?[-\w]*\.?[\w]*)[ \t]+(?P<fmt>\d+)x?"
116-
"(?P<samps_per_frame>\d*):?(?P<skew>\d*)\+?(?P<byte_offset>\d*)[ \t]*",
117-
"(?P<adc_gain>-?\d*\.?\d*e?[\+-]?\d*)\(?(?P<baseline>-?\d*)\)?",
118-
"/?(?P<units>[\w\^\-\?%\/]*)[ \t]*(?P<adc_res>\d*)[ \t]*",
119-
"(?P<adc_zero>-?\d*)[ \t]*(?P<init_value>-?\d*)[ \t]*(?P<checksum>-?\d*)",
120-
"[ \t]*(?P<block_size>\d*)[ \t]*(?P<sig_name>[\S]?[^\t\n\r\f\v]*)"])
121-
)
114+
_rx_signal = re.compile(
115+
r'''
116+
[ \t]*
117+
(?P<file_name>~?[-\w]*\.?[\w]*)[ \t]+(?P<fmt>\d+)x?
118+
(?P<samps_per_frame>\d*):?(?P<skew>\d*)\+?(?P<byte_offset>\d*)[ \t]*
119+
(?P<adc_gain>-?\d*\.?\d*e?[\+-]?\d*)\(?(?P<baseline>-?\d*)\)?
120+
/?(?P<units>[\w\^\-\?%\/]*)[ \t]*(?P<adc_res>\d*)[ \t]*
121+
(?P<adc_zero>-?\d*)[ \t]*(?P<init_value>-?\d*)[ \t]*(?P<checksum>-?\d*)
122+
[ \t]*(?P<block_size>\d*)[ \t]*(?P<sig_name>[\S]?[^\t\n\r\f\v]*)
123+
''', re.VERBOSE)
122124

123125
# Segment line
124-
_rx_segment = re.compile('[ \t]*(?P<seg_name>[-\w]*~?)[ \t]+(?P<seg_len>\d+)')
125-
126+
_rx_segment = re.compile(
127+
r'''
128+
[ \t]*
129+
(?P<seg_name>[-\w]*~?)[ \t]+(?P<seg_len>\d+)
130+
''', re.VERBOSE)
126131

127132
class BaseHeaderMixin(object):
128133
"""

0 commit comments

Comments
 (0)