Package dlinklist
[hide private]
[frames] | no frames]

Package dlinklist

source code

Overview

The Python API is a ctypes representation of the C API. It has slightly different functionality that the C API, however its usage is very similar.

Instead of function in a module it has been implimented as a class therefore taking advantage of private and protected objects to give a cleaner interface.

Installation

It is simple to install the Python egg:

 $ sudo easy_install linklist-2.0.0.tar.gz

 or

 $ cd linklist-2.0.0
 $ make egg
 $ sudo easy_install dist/DLinklist*.egg

Usage

The first thing that needs to be done is to create your Info class. There are two ways to do this.

  1. Use the class that is already created:
     from dlinklist import Info
    
     Info._fields_.append(('field01', c_char * 100))
     Info._fields_.append(('field02', c_char * 100))
    
  2. Make a new class:
     from ctypes import Structure
    
     class Info(Structure):
         _fields_ = (
             ('field01', c_char * 100),
             ('field02', c_char * 100),
             )
    

Note: If you need to make a reference to the Info class itself it will need to be done as in number 1 above, even if you create your own class.

The next thing that needs to be done is to create the List object. We actually will not be creating a List object as we did with the Info class, this will be done within the library itself.

Instantiate the DLinklist class and create the List object:

 from dlinklist import *
 from ctypes import sizeof

 dll = DLinklist()
 dll.create(sizeof(Info))

And you are done, just call any method in the DLinklist class on the dll object.


Note: All the pFun objects in the API need to return < 0, 0, and > 0 as in the Python cmp function. The compare method in the API is very basic, so you will probably need to write your own. However, use the compare method in the source code as an example of how it should be written.

Submodules [hide private]

Classes [hide private]
  BaseLinklistException
The base exception for all Dlinklist exceptions.
  LibraryNotFoundException
Raised if the C link list library is not found.
  FunctionException
Raised if the Return.NORMAL value is not returned by a C function.
  APIException
Raised if the low level C functions encounter an error.
Variables [hide private]
  _RES_PATH = '/home/cnobile/src/linklist/linklist-2.0.0/src/dli...
  __package__ = 'dlinklist'

Imports: _res, Return, SrchOrigin, SrchDir, InsertDir, Info, DLinklist


Variables Details [hide private]

_RES_PATH

Value:
'/home/cnobile/src/linklist/linklist-2.0.0/src/dlinklist/libdll.so'