NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

Changeset 371

Show
Ignore:
Timestamp:
09/09/10 13:21:20
Author:
cbc
Message:

Retype sensors and points collections as dictionaries.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spongenet/trunk/spongenet/parse.py

    r370 r371  
    199199    >>> _xmldoc = xmldoc(_xmldoc_path) 
    200200    >>> _data = Data(_xmldoc) 
    201     >>> point = _data.devices[0].sensors[0].points[0
     201    >>> point = _data.devices[0].sensors["SN100-0"].points["Battery Voltage"
    202202    >>> len(point.keys()) == 8 
    203203    True 
     
    243243    >>> _xmldoc = xmldoc(_xmldoc_path) 
    244244    >>> _data = Data(_xmldoc) 
    245     >>> sensor = _data.devices[0].sensors[0
    246     >>> len(sensor.points
     245    >>> sensor = _data.devices[0].sensors["SN100-0"
     246    >>> len(sensor.points.items()
    247247    3 
    248248    >>> len(sensor.keys()) == 9 
     
    278278                self.points = [Point(point) for point 
    279279                                in elem.findall(xmlns + "Point")] 
     280                self.points = dict([(point["descr"], point) 
     281                                   for point in self.points]) 
    280282            else: 
    281283                self[tag] = elem.text 
     
    296298    >>> _data = Data(_xmldoc) 
    297299    >>> device = _data.devices[0] 
    298     >>> len(device.sensors
     300    >>> len(device.sensors.items()
    299301    15 
    300302    >>> len(device.keys()) 
     
    355357                self.sensors = [Sensor(sensor, xmlns) for sensor 
    356358                                in elem.findall(xmlns + "SensorData")] 
     359                self.sensors = dict([(sensor["id"], sensor) 
     360                                    for sensor in self.sensors]) 
    357361            else: 
    358362                self[tag] = elem.text