[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Proof of concept higher-level python bindings for SoC project

From: David Glasser <glasser_at_mit.edu>
Date: 2007-05-02 19:49:57 CEST

On 5/2/07, David Glasser <glasser@mit.edu> wrote:
> Great, David! I can now run autogen.py and example.py works! Time to
> write the script that I wanted to write...

I have to get back to work now, but pasted below is my work in
progress, which shows anyone following along from home how to play
with apr_hash_t's...

--dave

#!/usr/bin/env python2.5

from csvn.core import *
from csvn.client import ClientSession, ClientURI

def dict_from_apr_hash(h, val_type, pool):
    d = {}

    hi = apr_hash_first(pool, h)

    # This *can't* be 'hi is not None' even though I thought NULL maps
    # to None...
    while hi:
        key_vp = c_void_p()
        val_vp = c_void_p()
        apr_hash_this(hi, byref(key_vp), None, byref(val_vp))

        key_as_string = cast(key_vp, c_char_p).value
        d[key_as_string] = cast(val_vp, val_type)

        hi = apr_hash_next(hi)

    return d

s = ClientSession("http://svn.collab.net/repos/svn/trunk")

h = POINTER(apr_hash_t)()

svn_ra_get_dir(s,
               "",
               -1, # bah, SVN_INVALID_REVNUM is not exported
               byref(h),
               None,
               None,
               s.pool)

print dict_from_apr_hash(h, POINTER(svn_dirent_t), s.pool)

-- 
David Glasser | glasser_at_mit.edu | http://www.davidglasser.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed May 2 19:50:09 2007

This is an archived mail posted to the Subversion Dev mailing list.