Changeset 1172:6cb71d6b4572 for src
- Timestamp:
- 10/20/24 12:57:19 (5 weeks ago)
- Branch:
- python3
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gates.py
r1158 r1172 10 10 class Gate(object): 11 11 """Information about a gate.""" 12 @staticmethod 13 def fromJSON(data): 14 """Create the gate from the given JSON data.""" 15 return Gate(data["number"], data["terminal"], 16 data["type"], 17 maxSpan = data["maxSpan"], 18 maxLength = data["maxLength"]) 19 12 20 def __init__(self, number, terminal, type, 13 21 availableFn = None, taxiThrough = False, … … 44 52 return False 45 53 54 def toJSON(self): 55 """Create a JSON representation of the gate.""" 56 data = {} 57 for attributeName in ["number", "terminal", "type", 58 "maxSpan", "maxLength"]: 59 data[attributeName] = getattr(self, attributeName) 60 return data 61 46 62 #-------------------------------------------------------------------------------------- 47 63 … … 56 72 # Display info type: a new column 57 73 DISPLAY_NEW_COLUMN=3 74 75 @staticmethod 76 def fromJSON(data): 77 """Create a gates object from the given JSON data.""" 78 gates = Gates() 79 for gateData in data: 80 gates.add(Gate.fromJSON(gateData)) 81 return gates 58 82 59 83 def __init__(self): … … 137 161 print("Gate %s has no maximal dimensions from the database" % 138 162 (gate.number,)) 163 164 def toJSON(self): 165 """Convert the list of gates into a JSON data.""" 166 return [gate.toJSON() for gate in self._gates] 139 167 140 168 def _addRow(self):
Note:
See TracChangeset
for help on using the changeset viewer.