users of pycurl here?

Fredrik Lundh fredrik at pythonware.com
Mon Oct 10 04:30:17 EDT 2005


Michele Simionato wrote:

> the README says "for a usage example, see the sanity.py test
> script" but there is not such a script in the distribution :-(

looks like a distutils glitch...  try this one:

# $Id$
# minimal sanity check

import string

TESTS = [
    "# examples taken from ftpparse.c",
    "+i8388621.29609,m824255902,/,\tdev",
    "+i8388621.44468,m839956783,r,s10376,\tRFCEPLF",
    "-rw-r--r--   1 root     other        531 Jan 29 03:26 README",
    "dr-xr-xr-x   2 root     other        512 Apr  8  1994 etc",
    "dr-xr-xr-x   2 root     512 Apr  8  1994 etc",
    "lrwxrwxrwx   1 root     other          7 Jan 25 00:17 bin -> usr/bin",
    "04-27-00  09:09PM       <DIR>          licensed",
    "07-18-00  10:16AM       <DIR>          pub",
    "04-14-00  03:47PM                  589 readme.htm",
]

import _ftpparse

# parse sample strings
for line in TESTS:
    print repr(line), "->"
    try:
        item = _ftpparse.parse(line)
    except ValueError:
        print "***", "cannot parse this line"
    else:
        print "   ", (item.name, item.size, item.mtime, item.id, item.trycwd)

# check behaviour for unknown attributes
try:
    item.unknown
except AttributeError:
    pass

# end

on my machine, this prints:

'# examples taken from ftpparse.c' ->
*** cannot parse this line
'+i8388621.29609,m824255902,/,\tdev' ->
    ('dev', None, 824255902, '8388621.29609', True)
'+i8388621.44468,m839956783,r,s10376,\tRFCEPLF' ->
    ('RFCEPLF', 10376, 839956783, '8388621.44468', False)
'-rw-r--r--   1 root     other        531 Jan 29 03:26 README' ->
    ('README', 531, 1106969160, None, False)
'dr-xr-xr-x   2 root     other        512 Apr  8  1994 etc' ->
    ('etc', 512, 765763200, None, True)
'dr-xr-xr-x   2 root     512 Apr  8  1994 etc' ->
    ('etc', 512, 765763200, None, True)
'lrwxrwxrwx   1 root     other          7 Jan 25 00:17 bin -> usr/bin' ->
    ('bin', 7, 1106612220, None, True)
'04-27-00  09:09PM       <DIR>          licensed' ->
    ('licensed', None, 956869740, None, True)
'07-18-00  10:16AM       <DIR>          pub' ->
    ('pub', None, 963915360, None, True)
'04-14-00  03:47PM                  589 readme.htm' ->
    ('readme.htm', 589, 955727220, None, False)

</F>






More information about the Python-list mailing list