Changeset 1189 for trunk/bindings/python
- Timestamp:
- 03/02/09 22:00:34 (3 years ago)
- File:
-
- 1 edited
-
trunk/bindings/python/nxs/napi.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/python/nxs/napi.py
r1188 r1189 315 315 self.isopen = True 316 316 317 def _getpath(self): 318 return '/'+'/'.join(self._path) 317 def _getpath(self): 318 mypath = [level[0] for level in self._path] 319 return '/'+'/'.join(mypath) 319 320 path = property(_getpath,doc="Unix-style path to node") 320 321 … … 421 422 def openpath(self, path): 422 423 """ 423 Open a particular group '/path/to/group'. Paths can 424 be absolute or relative to the currently open group. 425 If openpath fails, then currently open path may not 426 be different from the starting path. 424 Open a particular group '/path/to/group'. Paths can be 425 absolute or relative to the currently open group. If openpath 426 fails, then currently open path may not be different from the 427 starting path. For better performation the types can be 428 specified as well using '/path:type1/to:type2/group:type3' 429 which will prevent searching the file for the types associated 430 with the supplied names. 427 431 428 432 Raises ValueError. … … 437 441 if path == '/': 438 442 target = [] 439 elif path.startswith('/'):440 target = path[1:].split('/')441 443 else: 442 target = self._path + path.split('/') 444 if path.endswith("/"): 445 path = path[:-1] 446 if path.startswith('/'): 447 target = path[1:].split('/') 448 else: 449 target = self._path + path.split('/') 443 450 444 451 # Remove relative path indicators from target … … 455 462 L.append(t) 456 463 target = L 464 465 # split out nxclass from each level if available 466 L = [] 467 for t in target: 468 try: 469 item = t.split(":") 470 if len(item) == 1: 471 L.append((item[0], None)) 472 else: 473 L.append(tuple(item)) 474 except AttributeError: 475 L.append(t) 476 target = L 477 457 478 #print "current path",self._path 458 479 #print "%s"%path,target … … 476 497 up = self._path[len(target):] 477 498 down = [] 478 up.reverse() 499 500 # add more information to the down path 501 for i in xrange(len(down)): 502 try: 503 (name, nxclass) = down[i] 504 except ValueError: 505 down[i] = (down[i], None) 479 506 #print "close,open",up,down 480 507 … … 488 515 # Open groups on the way down 489 516 for target in down: 490 # Find target name in current group. We need to do this because 491 # we can't open the group without knowing the class. We also 492 # need the class so that we can handle SDS specially. 493 n,_,_ = self.getgroupinfo() 494 self.initgroupdir() 495 for i in range(n): 496 name,nxclass = self.getnextentry() 497 if name != target: continue 498 if nxclass != 'SDS': 499 self.opengroup(name,nxclass) 500 elif opendata: 501 self.opendata(name) 502 break 517 (name, nxclass) = target 518 if nxclass is None: 519 entries = self.getentries() 520 if not entries.has_key(name): 521 raise KeyError("Failed to find entry with name \"%s\"" \ 522 % name) 523 nxclass = entries[name] 524 if nxclass != "SDS": 525 self.opengroup(name, nxclass) 526 elif opendata: 527 self.opendata(name) 503 528 else: 504 529 raise ValueError("node %s not in %s"%(name,self.path)) … … 540 565 raise ValueError,\ 541 566 "Could not open %s:%s in %s"%(nxclass,name,self._loc()) 542 self._path.append( name)567 self._path.append((name,nxclass)) 543 568 544 569 nxlib.nxiclosegroup_.restype = c_int … … 738 763 if status == ERROR: 739 764 raise ValueError, "Could not open data %s: %s"%(name, self._loc()) 740 self._path.append( name)765 self._path.append((name,"SDS")) 741 766 self._indata = True 742 767
Note: See TracChangeset
for help on using the changeset viewer.
