home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/python
- #
- # Copyright (c) 1996 by Lele Gaifax. All Rights Reserved
- #
- # This file is part of the PyObjC package.
- #
- # $RCSfile: StructUser.py,v $
- # $Revision: 1.1.1.2 $
- # $Date: 1996/11/14 01:49:58 $
- #
- # Created Mon Sep 9 18:34:01 1996.
- #
-
- import ObjC
-
- NXBundle = ObjC.lookup_class ('NXBundle')
-
- su_bundle = NXBundle.alloc().initForDirectory__ ('StructUser.bundle')
- StructUser = su_bundle.principalClass()
-
- if StructUser:
- print "Building a StructUser with a default contents..."
- me = StructUser.me()
- me.show()
-
- print
- print "Fetching the passwd entry of user #4..."
- uucp = StructUser.alloc().initWithUserId__ (4)
- uucp.show()
- print "... and getting its value via the appropriate method..."
- try:
- print uucp.pwdEntry()
- except ObjC.error, m:
- print m, "... Sorry!"
-
- print
- print "Building a custom User Entry..."
- other = StructUser.alloc()
- other.initWithPasswd__ (('other', 'ThisIsThePassword', 104, 401, 10, 'Comments?', '', '/usr/local/spool/uucppublic', '/usr/local/lib/uucp/uucico'))
- other.show()
- print "... and getting its value via the appropriate method..."
- try:
- print other.pwdEntry()
- except ObjC.error, m:
- print m, "... Sorry!"
-
- # This does not work yet.
- print
- print "Trying float/double handling code..."
- #entry = other.pwdEntry()
- #uid = entry[2]
- uid = 4
- #print entry, uid
- okresult = uid * 3.14159
- result = uucp.multiplyUserIdBy__ (3.14159)
- print result
- if round (result, 5) != round (okresult, 5):
- print "as expected, it does not work yet: should be", okresult
- else:
- print "Great!! it works!"
-
- print
- print "Building a custom User Entry with wrong data..."
- other = StructUser.alloc()
- try:
- other.initWithPasswd__ (('other', 'ThisIsThePassword', 401, 10, 'Comments?', '', '/usr/local/spool/uucppublic', '/usr/local/lib/uucp/uucico'))
- other.show()
- except ObjC.error, m:
- print "Correctly, the module generated an exception:", m
- else:
- print "Wrong behaviour!"
- # end try
-
- # end if
-
-
-