[ports2data] Make port label parsing more robust
This commit is contained in:
parent
4eb1d8d486
commit
3bedab2301
1 changed files with 9 additions and 5 deletions
|
|
@ -160,13 +160,17 @@ def data_to_ports_flat(
|
|||
|
||||
local_ports = {}
|
||||
for label in labels:
|
||||
name, property_string = label.string.split(':')
|
||||
properties = property_string.split(' ')
|
||||
ptype = properties[0]
|
||||
angle_deg = float(properties[1]) if len(ptype) else 0
|
||||
if ':' not in label.string:
|
||||
logger.warning(f'Invalid port label "{label.string}" in pattern "{pstr}" (missing ":")')
|
||||
continue
|
||||
|
||||
name, property_string = label.string.split(':', 1)
|
||||
properties = property_string.split()
|
||||
ptype = properties[0] if len(properties) > 0 else 'unk'
|
||||
angle_deg = float(properties[1]) if len(properties) > 1 else numpy.inf
|
||||
|
||||
xy = label.offset
|
||||
angle = numpy.deg2rad(angle_deg)
|
||||
angle = numpy.deg2rad(angle_deg) if numpy.isfinite(angle_deg) else None
|
||||
|
||||
if name in local_ports:
|
||||
logger.warning(f'Duplicate port "{name}" in pattern "{pstr}"')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue