-
Notifications
You must be signed in to change notification settings - Fork 6
apidocs
Read a packet from a file using the fidonet.MessageFactory
method:
>>> import fidonet >>> msg = fidonet.MessageFactory(open('tests/sample.msg'))
You can access message data as a dictionary:
>>> msg['fromUsername'] 'Lars'
Or using dot notation:
>>> msg.fromUsername 'Lars'
The origAddr
and destAddr
properties return the corresponding
address as a fidonet.Address
instance:
>>> msg.origAddr.ftn '322/761'
You can assign an Address object to this property to update the packet:
>>> from fidonet.address import Address >>> msg.origAddr = Address('1:100/100') >>> msg.origAddr.ftn '1:100/100'
The body
property returns a MessageBody instance:
>>> b = msg.body >>> b.klines['MSGID:'] ['1:322/761 ea6ec1dd'] >>> b.area = 'FIDO_UTIL' >>> msg.body = b
Write a message to an open file using the write
method:
>>> msg.write(open('updated.msg', 'w'))
Read a packet from a file using the fidonet.PacketFactory
method:
>>> import fidonet >>> pkt = fidonet.PacketFactory(open('tests/sample.pkt'))
You can access packet data as a dictionary:
>>> pkt['origZone'] 1
Or using dot notation:
>>> pkt.origZone 1
The origAddr
and destAddr
properties return the corresponding
address as a fidonet.Address
instance:
>>> pkt.origAddr.ftn '1:322/761'
You can assign an Address object to this property to update the packet:
>>> from fidonet.address import Address >>> pkt.origAddr = Address('1:100/100') >>> pkt.origAddr.ftn '1:100/100'
The time
method returns a time.struct_time
instance:
>>> pkt.time time.struct_time(tm_year=2011, tm_mon=2, tm_mday=25, tm_hour=21, tm_min=58, tm_sec=17, tm_wday=0, tm_yday=0, tm_isdst=-1)
Assining a time.struct_time
instance will update the packet:
>>> import time >>> pkt.time = time.localtime(1298689930) >>> pkt.time time.struct_time(tm_year=2011, tm_mon=2, tm_mday=25, tm_hour=22, tm_min=12, tm_sec=10, tm_wday=0, tm_yday=0, tm_isdst=-1)
Write a packet to an open file using the write
method:
>>> pkt.write(open('updated.pkt', 'w'))