Changeset 1123 for trunk/bindings/python
- Timestamp:
- 14/11/08 21:07:48 (4 years ago)
- File:
-
- 1 edited
-
trunk/bindings/python/nxs/napi.py (modified) (61 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/python/nxs/napi.py
r1121 r1123 90 90 'uint8' 'uint16' 'uint32' 'uint64' 91 91 92 Use 'char' for string data. 92 Use 'char' for string data. 93 93 94 94 You can use the numpy A.dtype attribute for the type of array A. … … 248 248 raise OSError, "Set NEXUSLIB or move NeXus to one of: %s"%(", ".join(files)) 249 249 250 def _init(): 251 lib = _libnexus() 252 lib.NXMDisableErrorReporting() 253 return lib 254 255 # Define the interface to the dll 256 nxlib = _init() 250 257 251 258 … … 258 265 class NeXus(object): 259 266 260 # Define the interface to the dll261 lib = _libnexus()262 263 267 # ==== File ==== 264 #lib.nxiopen_.restype = c_int265 #lib.nxiopen_.argtypes = [c_char_p, c_int, c_void_pp]268 nxlib.nxiopen_.restype = c_int 269 nxlib.nxiopen_.argtypes = [c_char_p, c_int, c_void_pp] 266 270 def __init__(self, filename, mode='r'): 267 271 """ … … 276 280 nxs.ACC_CREATEXML 'wx' 277 281 282 Raises ValueError if the open mode is invalid. 283 278 284 Raises RuntimeError if the file could not be opened, with the 279 285 filename as part of the error message. … … 291 297 self.handle = c_void_p(None) 292 298 self.path = [] 293 status = self.lib.nxiopen_(filename,mode,_ref(self.handle))299 status = nxlib.nxiopen_(filename,mode,_ref(self.handle)) 294 300 if status == ERROR: 295 301 if mode in [ACC_READ, ACC_RDWR]: … … 317 323 """ 318 324 Opens the NeXus file handle if it is not already open. 325 326 Raises RuntimeError if the file could not be opened. 327 328 Corresponds to NXopen(filename,mode,&handle) 319 329 """ 320 330 if self.isopen: return … … 323 333 else: 324 334 mode = ACC_RDWR 325 status = self.lib.nxiopen_(self.filename,mode,_ref(self.handle))335 status = nxlib.nxiopen_(self.filename,mode,_ref(self.handle)) 326 336 if status == ERROR: 327 337 raise RuntimeError, "Could not open %s"%(self.filename) 328 338 self.path = [] 329 339 330 #lib.nxiclose_.restype = c_int331 #lib.nxiclose_.argtypes = [c_void_pp]340 nxlib.nxiclose_.restype = c_int 341 nxlib.nxiclose_.argtypes = [c_void_pp] 332 342 def close(self): 333 343 """ 334 344 Close the NeXus file associated with handle. 335 345 336 Raises RuntimeError if file could not be opened.346 Raises RuntimeError if file could not be closed. 337 347 338 348 Corresponds to NXclose(&handle) … … 340 350 if self.isopen: 341 351 self.isopen = False 342 status = self.lib.nxiclose_(_ref(self.handle))352 status = nxlib.nxiclose_(_ref(self.handle)) 343 353 if status == ERROR: 344 354 raise RuntimeError, "Could not close NeXus file %s"%(self.filename) 345 355 self.path = [] 346 356 347 lib.nxiflush_.restype = c_int348 lib.nxiflush_.argtypes = [c_void_pp]357 nxlib.nxiflush_.restype = c_int 358 nxlib.nxiflush_.argtypes = [c_void_pp] 349 359 def flush(self): 350 360 """ … … 355 365 Corresponds to NXflush(&handle) 356 366 """ 357 status = self.lib.nxiflush_(_ref(self.handle))367 status = nxlib.nxiflush_(_ref(self.handle)) 358 368 if status == ERROR: 359 369 raise RuntimeError, "Could not flush NeXus file %s"%(self.filename) 360 370 361 lib.nxisetnumberformat_.restype = c_int362 lib.nxisetnumberformat_.argtypes = [c_void_p, c_int, c_char_p]371 nxlib.nxisetnumberformat_.restype = c_int 372 nxlib.nxisetnumberformat_.argtypes = [c_void_p, c_int, c_char_p] 363 373 def setnumberformat(self,type,format): 364 374 """ … … 366 376 applies to XML). 367 377 368 Raises ValueError if th is fails.378 Raises ValueError if the number format is incorrect. 369 379 370 380 Corresponds to NXsetnumberformat(&handle,type,format) 371 381 """ 372 382 type = _nxtype_code[type] 373 status = self.lib.nxisetnumberformat_(self.handle,type,format)374 if status == ERROR: 375 raise RuntimeError,\383 status = nxlib.nxisetnumberformat_(self.handle,type,format) 384 if status == ERROR: 385 raise ValueError,\ 376 386 "Could not set %s to %s in %s"%(type,format,self.filename) 377 387 378 388 # ==== Group ==== 379 lib.nximakegroup_.restype = c_int380 lib.nximakegroup_.argtypes = [c_void_p, c_char_p, c_char_p]389 nxlib.nximakegroup_.restype = c_int 390 nxlib.nximakegroup_.argtypes = [c_void_p, c_char_p, c_char_p] 381 391 def makegroup(self, name, nxclass): 382 392 """ … … 387 397 Corresponds to NXmakegroup(handle, name, nxclass) 388 398 """ 389 status = self.lib.nximakegroup_(self.handle, name, nxclass)399 status = nxlib.nximakegroup_(self.handle, name, nxclass) 390 400 if status == ERROR: 391 401 raise RuntimeError,\ 392 402 "Could not create %s:%s in %s"%(nxclass,name,self._loc()) 393 403 394 lib.nxiopenpath_.restype = c_int395 lib.nxiopenpath_.argtypes = [c_void_p, c_char_p]404 nxlib.nxiopenpath_.restype = c_int 405 nxlib.nxiopenpath_.argtypes = [c_void_p, c_char_p] 396 406 def openpath(self, path): 397 407 """ … … 403 413 Corresponds to NXopenpath(handle, path) 404 414 """ 405 status = self.lib.nxiopenpath_(self.handle, path)415 status = nxlib.nxiopenpath_(self.handle, path) 406 416 if status == ERROR: 407 417 raise ValueError, "Could not open %s in %s"%(path,self._loc()) … … 413 423 414 424 415 lib.nxiopengrouppath_.restype = c_int416 lib.nxiopengrouppath_.argtypes = [c_void_p, c_char_p]425 nxlib.nxiopengrouppath_.restype = c_int 426 nxlib.nxiopengrouppath_.argtypes = [c_void_p, c_char_p] 417 427 def opengrouppath(self, path): 418 428 """ … … 425 435 Corresponds to NXopengrouppath(handle, path) 426 436 """ 427 status = self.lib.nxiopengrouppath_(self.handle, path)437 status = nxlib.nxiopengrouppath_(self.handle, path) 428 438 if status == ERROR: 429 439 raise ValueError, "Could not open %s in %s"%(path,self.filename) … … 435 445 436 446 437 lib.nxiopengroup_.restype = c_int438 lib.nxiopengroup_.argtypes = [c_void_p, c_char_p, c_char_p]447 nxlib.nxiopengroup_.restype = c_int 448 nxlib.nxiopengroup_.argtypes = [c_void_p, c_char_p, c_char_p] 439 449 def opengroup(self, name, nxclass): 440 450 """ … … 446 456 """ 447 457 #print "open group",nxclass,name 448 status = self.lib.nxiopengroup_(self.handle, name, nxclass)458 status = nxlib.nxiopengroup_(self.handle, name, nxclass) 449 459 if status == ERROR: 450 460 raise ValueError,\ … … 452 462 self.path.append(name) 453 463 454 lib.nxiclosegroup_.restype = c_int455 lib.nxiclosegroup_.argtypes = [c_void_p]464 nxlib.nxiclosegroup_.restype = c_int 465 nxlib.nxiclosegroup_.argtypes = [c_void_p] 456 466 def closegroup(self): 457 467 """ … … 463 473 """ 464 474 #print "close group" 465 status = self.lib.nxiclosegroup_(self.handle)475 status = nxlib.nxiclosegroup_(self.handle) 466 476 group = self.path.pop() 467 477 if status == ERROR: 468 478 raise RuntimeError, "Could not close %s:"%(group,self._loc()) 469 479 470 lib.nxigetinfo_.restype = c_int471 lib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_char_p, c_char_p]480 nxlib.nxigetinfo_.restype = c_int 481 nxlib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_char_p, c_char_p] 472 482 def getgroupinfo(self): 473 483 """ … … 484 494 nxclass = ctypes.create_string_buffer(MAXNAMELEN) 485 495 n = c_int(0) 486 status = self.lib.nxigetgroupinfo_(self.handle,_ref(n),path,nxclass)496 status = nxlib.nxigetgroupinfo_(self.handle,_ref(n),path,nxclass) 487 497 if status == ERROR: 488 498 raise ValueError, "Could not get group info: %s"%(self._loc()) … … 490 500 return n.value,path.value,nxclass.value 491 501 492 lib.nxiinitgroupdir_.restype = c_int493 lib.nxiinitgroupdir_.argtypes = [c_void_p]502 nxlib.nxiinitgroupdir_.restype = c_int 503 nxlib.nxiinitgroupdir_.argtypes = [c_void_p] 494 504 def initgroupdir(self): 495 505 """ … … 500 510 Corresponds to NXinitgroupdir(handle) 501 511 """ 502 status = self.lib.nxiinitgroupdir_(self.handle)512 status = nxlib.nxiinitgroupdir_(self.handle) 503 513 if status == ERROR: 504 514 raise RuntimeError, \ 505 515 "Could not reset group scan: %s"%(self._loc()) 506 516 507 lib.nxigetnextentry_.restype = c_int508 lib.nxigetnextentry_.argtypes = [c_void_p, c_char_p, c_char_p, c_int_p]517 nxlib.nxigetnextentry_.restype = c_int 518 nxlib.nxigetnextentry_.argtypes = [c_void_p, c_char_p, c_char_p, c_int_p] 509 519 def getnextentry(self): 510 520 """ … … 522 532 nxclass = ctypes.create_string_buffer(MAXNAMELEN) 523 533 storage = c_int(0) 524 status = self.lib.nxigetnextentry_(self.handle,name,nxclass,_ref(storage))534 status = nxlib.nxigetnextentry_(self.handle,name,nxclass,_ref(storage)) 525 535 if status == ERROR or status == EOD: 526 536 raise RuntimeError, \ … … 572 582 573 583 # ==== Data ==== 574 lib.nxigetinfo_.restype = c_int575 lib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p]584 nxlib.nxigetinfo_.restype = c_int 585 nxlib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 576 586 def getinfo(self): 577 587 """ … … 596 606 shape = numpy.zeros(MAXRANK, 'i') 597 607 storage = c_int(0) 598 status = self.lib.nxigetinfo_(self.handle, _ref(rank), shape.ctypes.data,608 status = nxlib.nxigetinfo_(self.handle, _ref(rank), shape.ctypes.data, 599 609 _ref(storage)) 600 610 if status == ERROR: … … 605 615 return shape,dtype 606 616 607 lib.nxiopendata_.restype = c_int608 lib.nxiopendata_.argtypes = [c_void_p, c_char_p]617 nxlib.nxiopendata_.restype = c_int 618 nxlib.nxiopendata_.argtypes = [c_void_p, c_char_p] 609 619 def opendata(self, name): 610 620 """ … … 616 626 """ 617 627 #print "opening data",name 618 status = self.lib.nxiopendata_(self.handle, name)628 status = nxlib.nxiopendata_(self.handle, name) 619 629 if status == ERROR: 620 630 raise ValueError, "Could not open data %s: %s"%(name, self._loc()) 621 631 self.path.append(name) 622 632 623 lib.nxiclosedata_.restype = c_int624 lib.nxiclosedata_.argtypes = [c_void_p]633 nxlib.nxiclosedata_.restype = c_int 634 nxlib.nxiclosedata_.argtypes = [c_void_p] 625 635 def closedata(self): 626 636 """ … … 633 643 """ 634 644 #print "closing data" 635 status = self.lib.nxiclosedata_(self.handle)645 status = nxlib.nxiclosedata_(self.handle) 636 646 name = self.path.pop() 637 647 if status == ERROR: … … 639 649 "Could not close data %s: %s"%(name,self._loc()) 640 650 641 lib.nximakedata_.restype = c_int642 lib.nximakedata_.argtypes = [c_void_p, c_char_p, c_int, c_int, c_int_p]651 nxlib.nximakedata_.restype = c_int 652 nxlib.nximakedata_.argtypes = [c_void_p, c_char_p, c_int, c_int, c_int_p] 643 653 def makedata(self, name, dtype=None, shape=None): 644 654 """ … … 660 670 storage = _nxtype_code[str(dtype)] 661 671 shape = numpy.array(shape,'i') 662 status = self.lib.nximakedata_(self.handle,name,storage,len(shape),672 status = nxlib.nximakedata_(self.handle,name,storage,len(shape), 663 673 shape.ctypes.data_as(c_int_p)) 664 674 if status == ERROR: 665 675 raise ValueError, "Could not create data %s: %s"%(name,self._loc()) 666 676 667 lib.nxicompmakedata_.restype = c_int668 lib.nxicompmakedata_.argtypes = [c_void_p, c_char_p, c_int, c_int, c_int_p,677 nxlib.nxicompmakedata_.restype = c_int 678 nxlib.nxicompmakedata_.argtypes = [c_void_p, c_char_p, c_int, c_int, c_int_p, 669 679 c_int, c_int_p] 670 680 def compmakedata(self, name, dtype=None, shape=None, mode='lzw', … … 693 703 else: 694 704 chunks = numpy.array(chunks,'i') 695 status = self.lib.nxicompmakedata_(self.handle,name,storage,len(dims),705 status = nxlib.nxicompmakedata_(self.handle,name,storage,len(dims), 696 706 dims.ctypes.data_as(c_int_p), 697 707 _compression_code[mode], … … 701 711 "Could not create compressed data %s: %s"%(name,self._loc()) 702 712 703 lib.nxigetdata_.restype = c_int704 lib.nxigetdata_.argtypes = [c_void_p, c_void_p]713 nxlib.nxigetdata_.restype = c_int 714 nxlib.nxigetdata_.argtypes = [c_void_p, c_void_p] 705 715 def getdata(self): 706 716 """ … … 709 719 length 1), a python numeric scalar is returned. 710 720 711 Raises RuntimeError if this fails.721 Raises ValueError if this fails. 712 722 713 723 Corresponds to NXgetdata(handle, data) … … 716 726 shape,dtype = self.getinfo() 717 727 datafn,pdata,size = self._poutput(dtype,shape) 718 status = self.lib.nxigetdata_(self.handle,pdata)728 status = nxlib.nxigetdata_(self.handle,pdata) 719 729 if status == ERROR: 720 730 raise ValueError, "Could not read data: %s"%(self._loc()) … … 722 732 return datafn() 723 733 724 lib.nxigetslab_.restype = c_int725 lib.nxigetslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p]734 nxlib.nxigetslab_.restype = c_int 735 nxlib.nxigetslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p] 726 736 def getslab(self, slab_offset, slab_shape): 727 737 """ … … 740 750 slab_offset = numpy.array(slab_offset,'i') 741 751 slab_shape = numpy.array(slab_shape,'i') 742 status = self.lib.nxigetslab_(self.handle,pdata,752 status = nxlib.nxigetslab_(self.handle,pdata, 743 753 slab_offset.ctypes.data_as(c_int_p), 744 754 slab_shape.ctypes.data_as(c_int_p)) … … 748 758 return datafn() 749 759 750 lib.nxiputdata_.restype = c_int751 lib.nxiputdata_.argtypes = [c_void_p, c_void_p]760 nxlib.nxiputdata_.restype = c_int 761 nxlib.nxiputdata_.argtypes = [c_void_p, c_void_p] 752 762 def putdata(self, data): 753 763 """ … … 760 770 shape,dtype = self.getinfo() 761 771 data,pdata = self._pinput(data,dtype,shape) 762 status = self.lib.nxiputdata_(self.handle,pdata)772 status = nxlib.nxiputdata_(self.handle,pdata) 763 773 if status == ERROR: 764 774 raise ValueError, "Could not write data: %s"%(self._loc()) 765 775 766 lib.nxiputslab_.restype = c_int767 lib.nxiputslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p]776 nxlib.nxiputslab_.restype = c_int 777 nxlib.nxiputslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p] 768 778 def putslab(self, data, slab_offset, slab_shape): 769 779 """ … … 782 792 slab_shape = numpy.array(slab_shape,'i') 783 793 #print "slab",offset,size,data 784 status = self.lib.nxiputslab_(self.handle,pdata,794 status = nxlib.nxiputslab_(self.handle,pdata, 785 795 slab_offset.ctypes.data_as(c_int_p), 786 796 slab_shape.ctypes.data_as(c_int_p)) … … 791 801 792 802 # ==== Attributes ==== 793 lib.nxiinitattrdir_.restype = c_int794 lib.nxiinitattrdir_.argtypes = [c_void_p]803 nxlib.nxiinitattrdir_.restype = c_int 804 nxlib.nxiinitattrdir_.argtypes = [c_void_p] 795 805 def initattrdir(self): 796 806 """ … … 801 811 Corresponds to NXinitattrdir(handle) 802 812 """ 803 status = self.lib.nxiinitattrdir_(self.handle)813 status = nxlib.nxiinitattrdir_(self.handle) 804 814 if status == ERROR: 805 815 raise RuntimeError, \ 806 816 "Could not reset attribute list: %s"%(self._loc()) 807 817 808 lib.nxigetattrinfo_.restype = c_int809 lib.nxigetattrinfo_.argtypes = [c_void_p, c_int_p]818 nxlib.nxigetattrinfo_.restype = c_int 819 nxlib.nxigetattrinfo_.argtypes = [c_void_p, c_int_p] 810 820 def getattrinfo(self): 811 821 """ … … 819 829 """ 820 830 n = c_int(0) 821 status = self.lib.nxigetattrinfo_(self.handle,_ref(n))831 status = nxlib.nxigetattrinfo_(self.handle,_ref(n)) 822 832 if status == ERROR: 823 833 raise RuntimeError, "Could not get attr info: %s"%(self._loc()) … … 825 835 return n.value 826 836 827 lib.nxigetnextattr_.restype = c_int828 lib.nxigetnextattr_.argtypes = [c_void_p, c_char_p, c_int_p, c_int_p]837 nxlib.nxigetnextattr_.restype = c_int 838 nxlib.nxigetnextattr_.argtypes = [c_void_p, c_char_p, c_int_p, c_int_p] 829 839 def getnextattr(self): 830 840 """ … … 847 857 length = c_int(0) 848 858 storage = c_int(0) 849 status = self.lib.nxigetnextattr_(self.handle,name,_ref(length),_ref(storage))859 status = nxlib.nxigetnextattr_(self.handle,name,_ref(length),_ref(storage)) 850 860 if status == ERROR or status == EOD: 851 861 raise RuntimeError, "Could not get next attr: %s"%(self._loc()) … … 856 866 # TODO: Resolve discrepency between NeXus API documentation and 857 867 # TODO: apparent behaviour for getattr/putattr length. 858 lib.nxigetattr_.restype = c_int859 lib.nxigetattr_.argtypes = [c_void_p, c_char_p, c_void_p, c_int_p, c_int_p]868 nxlib.nxigetattr_.restype = c_int 869 nxlib.nxigetattr_.argtypes = [c_void_p, c_char_p, c_void_p, c_int_p, c_int_p] 860 870 def getattr(self, name, length, dtype): 861 871 """ … … 870 880 #print "retrieving",name,length,dtype,size 871 881 size = c_int(size) 872 status = self.lib.nxigetattr_(self.handle,name,pdata,_ref(size),_ref(storage))882 status = nxlib.nxigetattr_(self.handle,name,pdata,_ref(size),_ref(storage)) 873 883 if status == ERROR: 874 884 raise ValueError, "Could not read attr %s: %s" % (name,self._loc()) … … 876 886 return datafn() 877 887 878 lib.nxiputattr_.restype = c_int879 lib.nxiputattr_.argtypes = [c_void_p, c_char_p, c_void_p, c_int, c_int]888 nxlib.nxiputattr_.restype = c_int 889 nxlib.nxiputattr_.argtypes = [c_void_p, c_char_p, c_void_p, c_int, c_int] 880 890 def putattr(self, name, value, dtype = None): 881 891 """ … … 883 893 or a scalar. 884 894 885 Raises ValueError if the attribute could not be saved. 895 Raises TypeError if the value type is incorrect. 896 Raises RuntimeError if the attribute could not be saved. 886 897 887 898 Corresponds to NXputattr(handle,name,data,length,storage) … … 921 932 # Perform the call 922 933 storage = c_int(_nxtype_code[dtype]) 923 status = self.lib.nxiputattr_(self.handle,name,data,length,storage)924 if status == ERROR: 925 raise ValueError, "Could not write attr %s: %s"%(name,self._loc())934 status = nxlib.nxiputattr_(self.handle,name,data,length,storage) 935 if status == ERROR: 936 raise RuntimeError, "Could not write attr %s: %s"%(name,self._loc()) 926 937 927 938 def attrs(self): … … 946 957 947 958 # ==== Linking ==== 948 lib.nxigetgroupid_.restype = c_int949 lib.nxigetgroupid_.argtypes = [c_void_p, c_NXlink_p]959 nxlib.nxigetgroupid_.restype = c_int 960 nxlib.nxigetgroupid_.argtypes = [c_void_p, c_NXlink_p] 950 961 def getgroupID(self): 951 962 """ … … 957 968 """ 958 969 ID = _NXlink() 959 status = self.lib.nxigetgroupid_(self.handle,_ref(ID))970 status = nxlib.nxigetgroupid_(self.handle,_ref(ID)) 960 971 if status == ERROR: 961 972 raise RuntimeError, "Could not link to group: %s"%(self._loc()) 962 973 return ID 963 974 964 lib.nxigetdataid_.restype = c_int965 lib.nxigetdataid_.argtypes = [c_void_p, c_NXlink_p]975 nxlib.nxigetdataid_.restype = c_int 976 nxlib.nxigetdataid_.argtypes = [c_void_p, c_NXlink_p] 966 977 def getdataID(self): 967 978 """ … … 973 984 """ 974 985 ID = _NXlink() 975 status = self.lib.nxigetdataid_(self.handle,_ref(ID))986 status = nxlib.nxigetdataid_(self.handle,_ref(ID)) 976 987 if status == ERROR: 977 988 raise RuntimeError, "Could not link to data: %s"%(self._loc()) 978 989 return ID 979 990 980 lib.nximakelink_.restype = c_int981 lib.nximakelink_.argtypes = [c_void_p, c_NXlink_p]991 nxlib.nximakelink_.restype = c_int 992 nxlib.nximakelink_.argtypes = [c_void_p, c_NXlink_p] 982 993 def makelink(self, ID): 983 994 """ … … 989 1000 Corresponds to NXmakelink(handle, &ID) 990 1001 """ 991 status = self.lib.nximakelink_(self.handle,_ref(ID))1002 status = nxlib.nximakelink_(self.handle,_ref(ID)) 992 1003 if status == ERROR: 993 1004 raise RuntimeError, "Could not make link: %s"%(self._loc()) 994 1005 995 lib.nximakenamedlink_.restype = c_int996 lib.nximakenamedlink_.argtypes = [c_void_p, c_char_p, c_NXlink_p]1006 nxlib.nximakenamedlink_.restype = c_int 1007 nxlib.nximakenamedlink_.argtypes = [c_void_p, c_char_p, c_NXlink_p] 997 1008 def makenamedlink(self,name,ID): 998 1009 """ … … 1004 1015 Corresponds to NXmakenamedlink(handle,name,&ID) 1005 1016 """ 1006 status = self.lib.nximakenamedlink_(self.handle,name,_ref(ID))1017 status = nxlib.nximakenamedlink_(self.handle,name,_ref(ID)) 1007 1018 if status == ERROR: 1008 1019 raise RuntimeError, "Could not make link %s: %s"%(name,self._loc()) 1009 1020 1010 lib.nxisameid_.restype = c_int1011 lib.nxisameid_.argtypes = [c_void_p, c_NXlink_p, c_NXlink_p]1021 nxlib.nxisameid_.restype = c_int 1022 nxlib.nxisameid_.argtypes = [c_void_p, c_NXlink_p, c_NXlink_p] 1012 1023 def sameID(self, ID1, ID2): 1013 1024 """ … … 1018 1029 Corresponds to NXsameID(handle,&ID1,&ID2) 1019 1030 """ 1020 status = self.lib.nxisameid_(self.handle, _ref(ID1), _ref(ID2))1031 status = nxlib.nxisameid_(self.handle, _ref(ID1), _ref(ID2)) 1021 1032 return status == OK 1022 1033 1023 lib.nxiopensourcegroup_.restype = c_int1024 lib.nxiopensourcegroup_.argtyps = [c_void_p]1034 nxlib.nxiopensourcegroup_.restype = c_int 1035 nxlib.nxiopensourcegroup_.argtyps = [c_void_p] 1025 1036 def opensourcegroup(self): 1026 1037 """ … … 1031 1042 perhaps the existence of a 'target' attribute in the current item. 1032 1043 1033 Raises RuntimeError 1044 Raises RuntimeError. 1034 1045 1035 1046 Corresponds to NXopensourcegroup(handle) 1036 1047 """ 1037 status = self.lib.nxiopensourcegroup_(self.handle)1048 status = nxlib.nxiopensourcegroup_(self.handle) 1038 1049 if status == ERROR: 1039 1050 raise RuntimeError, "Could not open source group: %s"%(self._loc()) … … 1067 1078 1068 1079 # ==== External linking ==== 1069 lib.nxiinquirefile_.restype = c_int1070 lib.nxiinquirefile_.argtypes = [c_void_p, c_char_p, c_int]1080 nxlib.nxiinquirefile_.restype = c_int 1081 nxlib.nxiinquirefile_.argtypes = [c_void_p, c_char_p, c_int] 1071 1082 def inquirefile(self, maxnamelen=MAXPATHLEN): 1072 1083 """ … … 1080 1091 """ 1081 1092 filename = ctypes.create_string_buffer(maxnamelen) 1082 status = self.lib.nxiinquirefile_(self.handle,filename,maxnamelen)1093 status = nxlib.nxiinquirefile_(self.handle,filename,maxnamelen) 1083 1094 if status == ERROR: 1084 1095 raise RuntimeError,\ … … 1086 1097 return filename.value 1087 1098 1088 lib.nxilinkexternal_.restype = c_int1089 lib.nxilinkexternal_.argtyps = [c_void_p, c_char_p,1099 nxlib.nxilinkexternal_.restype = c_int 1100 nxlib.nxilinkexternal_.argtyps = [c_void_p, c_char_p, 1090 1101 c_char_p, c_char_p] 1091 1102 def linkexternal(self, name, nxclass, url): … … 1094 1105 otherwise return None. 1095 1106 1107 Raises RuntimeError if link fails. 1108 1096 1109 Corresponds to NXisexternalgroup(&handle,name,nxclass,file,len) 1097 1110 """ 1098 status = self.lib.nxilinkexternal_(self.handle,name,nxclass,url)1111 status = nxlib.nxilinkexternal_(self.handle,name,nxclass,url) 1099 1112 if status == ERROR: 1100 1113 raise RuntimeError,\ … … 1103 1116 1104 1117 1105 lib.nxiisexternalgroup_.restype = c_int1106 lib.nxiisexternalgroup_.argtyps = [c_void_p, c_char_p,1118 nxlib.nxiisexternalgroup_.restype = c_int 1119 nxlib.nxiisexternalgroup_.argtyps = [c_void_p, c_char_p, 1107 1120 c_char_p, c_char_p, c_int] 1108 1121 def isexternalgroup(self, name, nxclass, maxnamelen=MAXPATHLEN): … … 1114 1127 """ 1115 1128 url = ctypes.create_string_buffer(maxnamelen) 1116 status = self.lib.nxiisexternalgroup_(self.handle,name,nxclass,1129 status = nxlib.nxiisexternalgroup_(self.handle,name,nxclass, 1117 1130 url,maxnamelen) 1118 1131 if status == ERROR:
Note: See TracChangeset
for help on using the changeset viewer.
