Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

apidocs

Lars Kellogg-Stedman edited this page Feb 27, 2011 · 2 revisions

API Documentation

Messages

Reading a message

Read a packet from a file using the fidonet.MessageFactory method:

>>> import fidonet
>>> msg = fidonet.MessageFactory(open('tests/sample.msg'))

Accessing message data

You can access message data as a dictionary:

>>> msg['fromUsername']
'Lars'

Or using dot notation:

>>> msg.fromUsername
'Lars'

Special properties

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

Writing a message

Write a message to an open file using the write method:

>>> msg.write(open('updated.msg', 'w'))

Packets

Reading a packet

Read a packet from a file using the fidonet.PacketFactory method:

>>> import fidonet
>>> pkt = fidonet.PacketFactory(open('tests/sample.pkt'))

Accessing packet data

You can access packet data as a dictionary:

>>> pkt['origZone']
1

Or using dot notation:

>>> pkt.origZone
1

Special properties

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)

Writing a packet

Write a packet to an open file using the write method:

>>> pkt.write(open('updated.pkt', 'w'))
Clone this wiki locally