Skip to content

Commit

Permalink
Avoid unnecessary string parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
herm authored and hgrecco committed Aug 22, 2016
1 parent 7d6f750 commit 478d114
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pyvisa-py/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def after_parsing(self):

self.interface = cls(port=self.parsed.board, timeout=2000, writeTimeout=2000)

for name in 'ASRL_END_IN,ASRL_END_OUT,SEND_END_EN,TERMCHAR,' \
'TERMCHAR_EN,SUPPRESS_END_EN'.split(','):
for name in ('ASRL_END_IN', 'ASRL_END_OUT', 'SEND_END_EN', 'TERMCHAR',
'TERMCHAR_EN', 'SUPPRESS_END_EN'):
attribute = getattr(constants, 'VI_ATTR_' + name)
self.attrs[attribute] = attributes.AttributesByID[attribute].default

Expand Down
4 changes: 2 additions & 2 deletions pyvisa-py/tcpip.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def after_parsing(self):
self.link = link
self.max_recv_size = min(max_recv_size, 2 ** 30) # 1GB

for name in 'SEND_END_EN,TERMCHAR,TERMCHAR_EN'.split(','):
for name in ('SEND_END_EN', 'TERMCHAR', 'TERMCHAR_EN'):
attribute = getattr(constants, 'VI_ATTR_' + name)
self.attrs[attribute] = attributes.AttributesByID[attribute].default

Expand Down Expand Up @@ -345,7 +345,7 @@ def after_parsing(self):
self.attrs[constants.VI_ATTR_TCPIP_PORT] = self.parsed.port
self.attrs[constants.VI_ATTR_INTF_NUM] = self.parsed.board

for name in 'TERMCHAR,TERMCHAR_EN'.split(','):
for name in ('TERMCHAR', 'TERMCHAR_EN'):
attribute = getattr(constants, 'VI_ATTR_' + name)
self.attrs[attribute] = attributes.AttributesByID[attribute].default

Expand Down
4 changes: 2 additions & 2 deletions pyvisa-py/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def after_parsing(self):
int(self.parsed.model_code, 0),
self.parsed.serial_number)

for name in 'SEND_END_EN,TERMCHAR,TERMCHAR_EN'.split(','):
for name in ('SEND_END_EN', 'TERMCHAR', 'TERMCHAR_EN'):
attribute = getattr(constants, 'VI_ATTR_' + name)
self.attrs[attribute] = attributes.AttributesByID[attribute].default

Expand Down Expand Up @@ -228,6 +228,6 @@ def after_parsing(self):
int(self.parsed.model_code, 0),
self.parsed.serial_number)

for name in 'SEND_END_EN,TERMCHAR,TERMCHAR_EN'.split(','):
for name in ('SEND_END_EN', 'TERMCHAR', 'TERMCHAR_EN'):
attribute = getattr(constants, 'VI_ATTR_' + name)
self.attrs[attribute] = attributes.AttributesByID[attribute].default

0 comments on commit 478d114

Please sign in to comment.