| | 262 | def getSimpleProperties(simplePropertyNodeList, propertyFile): |
| | 263 | props = [] |
| | 264 | for node in simplePropertyNodeList: |
| | 265 | p = getSimpleProperty(node) |
| | 266 | if p == None: |
| | 267 | print "There was an error parsing simple properties in the PRF file " + propertyFile |
| | 268 | continue |
| | 269 | props.append(p) |
| | 270 | |
| | 271 | return props |
| | 272 | |
| | 273 | def getSimpleSequenceProperties(simpleSequencePropertyNodeList, propertyFile): |
| | 274 | props = [] |
| | 275 | for node in simpleSequencePropertyNodeList: |
| | 276 | p = getSimpleSequenceProperty(node, propertyFile) |
| | 277 | if p == None: |
| | 278 | print "There was an error parsing simple sequence properties in the PRF file " + propertyFile |
| | 279 | continue |
| | 280 | props.append(p) |
| | 281 | |
| | 282 | return props |
| | 283 | |
| | 284 | def getSimpleProperty(n): |
| | 285 | tmpName = n.getAttribute("name") |
| | 286 | tmpID = n.getAttribute("id") |
| | 287 | tmpType = n.getAttribute("type") |
| | 288 | tmpMode = n.getAttribute("mode") |
| | 289 | tmpDes = n.getAttribute("description") |
| | 290 | |
| | 291 | if tmpName == "" or tmpID == "" or tmpType == "" or tmpMode == "": |
| | 292 | return None |
| | 293 | if tmpMode not in availableModes: |
| | 294 | return None |
| | 295 | if tmpType not in availableTypes: |
| | 296 | return None |
| | 297 | |
| | 298 | newProp = CC.SimpleProperty(tmpName,tmpMode,tmpType,description=tmpDes) |
| | 299 | |
| | 300 | # Set ID |
| | 301 | #UUID in the sad file will need to match the UUID in the prf (tmpID is from prf) |
| | 302 | newProp.id = tmpID |
| | 303 | |
| | 304 | # Get/set property value |
| | 305 | valueNodeList = n.getElementsByTagName("value") |
| | 306 | value = valueNodeList[0].childNodes[0].data |
| | 307 | newProp.value = newProp.defaultValue = str(value) |
| | 308 | del valueNodeList, value |
| | 309 | |
| | 310 | # Get/set property units |
| | 311 | unitsNodeList = n.getElementsByTagName("units") |
| | 312 | if len(unitsNodeList) > 0: |
| | 313 | units = unitsNodeList[0].childNodes[0].data |
| | 314 | newProp.units = str(s.units) |
| | 315 | #del unitsNodeList, units |
| | 316 | |
| | 317 | # TODO: Get/set min/max values |
| | 318 | # TODO: Get/set enum |
| | 319 | |
| | 320 | # Get/set kind |
| | 321 | kindNodeList = n.getElementsByTagName("kind") |
| | 322 | kindtype = kindNodeList[0].getAttribute("kindtype") |
| | 323 | if kindtype == "": |
| | 324 | return None |
| | 325 | newProp.kind = str(kindtype) |
| | 326 | del kindNodeList, kindtype |
| | 327 | |
| | 328 | # Get/set action |
| | 329 | actionNodeList = n.getElementsByTagName("action") |
| | 330 | if len(actionNodeList) > 0: |
| | 331 | actiontype = actionNodeList[0].getAttribute("type") |
| | 332 | newProp.action = str(actiontype) |
| | 333 | #del actionNodeList, actiontype |
| | 334 | |
| | 335 | return newProp |
| | 336 | |
| | 337 | def getSimpleSequenceProperty(n, prfPath): |
| | 338 | tmpName = n.getAttribute("name") |
| | 339 | tmpID = n.getAttribute("id") |
| | 340 | tmpType = n.getAttribute("type") |
| | 341 | tmpMode = n.getAttribute("mode") |
| | 342 | tmpDes = n.getAttribute("description") |
| | 343 | |
| | 344 | if tmpName == "" or tmpID == "" or tmpType == "" or tmpMode == "": |
| | 345 | return None |
| | 346 | if tmpMode not in availableModes: |
| | 347 | return None |
| | 348 | if tmpType not in availableTypes: |
| | 349 | return None |
| | 350 | |
| | 351 | newProp = CC.SimpleSequenceProperty(tmpName,tmpMode,tmpType,description=tmpDes) |
| | 352 | |
| | 353 | # Set ID |
| | 354 | #UUID in the sad file will need to match the UUID in the prf (tmpID is from prf) |
| | 355 | newProp.id = tmpID |
| | 356 | |
| | 357 | |
| | 358 | # Get/set property values |
| | 359 | newProp.values = [] |
| | 360 | newProp.defaultValues = [] |
| | 361 | valuesNodeList = n.getElementsByTagName("values") |
| | 362 | |
| | 363 | try: |
| | 364 | valueNodeList = valuesNodeList[0].getElementsByTagName("value") |
| | 365 | except: |
| | 366 | valueNodeList = n.getElementsByTagName("value") #cbd |
| | 367 | #print "\nERROR in " + prfPath |
| | 368 | #print "ERROR parsing prf file. You may be missing a values tag in a simple sequence property.\n" |
| | 369 | #sys.exit() |
| | 370 | print "\nWarning in " + prfPath |
| | 371 | print "Warning parsing prf file. You may be missing a values tag in a simple sequence property.\n" |
| | 372 | |
| | 373 | for valueNode in valueNodeList: |
| | 374 | tmpVal = valueNode.childNodes[0].data |
| | 375 | newProp.values.append(str(tmpVal)) |
| | 376 | newProp.defaultValues.append(str(tmpVal)) |
| | 377 | del valueNodeList |
| | 378 | |
| | 379 | # Get/set property units |
| | 380 | unitsNodeList = n.getElementsByTagName("units") |
| | 381 | if len(unitsNodeList) > 0: |
| | 382 | units = unitsNodeList[0].childNodes[0].data |
| | 383 | newProp.units = str(s.units) |
| | 384 | #del unitsNodeList, units |
| | 385 | |
| | 386 | # TODO: Get/set min/max values |
| | 387 | # TODO: Get/set enum |
| | 388 | |
| | 389 | # Get/set kind |
| | 390 | kindNodeList = n.getElementsByTagName("kind") |
| | 391 | kindtype = kindNodeList[0].getAttribute("kindtype") |
| | 392 | if kindtype == "": |
| | 393 | return None |
| | 394 | newProp.kind = str(kindtype) |
| | 395 | del kindNodeList, kindtype |
| | 396 | |
| | 397 | # Get/set action |
| | 398 | actionNodeList = n.getElementsByTagName("action") |
| | 399 | if len(actionNodeList) > 0: |
| | 400 | actiontype = actionNodeList[0].getAttribute("type") |
| | 401 | newProp.action = str(actiontype) |
| | 402 | #del actionNodeList, actiontype |
| | 403 | |
| | 404 | return newProp |
| | 405 | |
| | 406 | |