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

Re: How to get proplist for a file in a python script

From: Stephane Bortzmeyer <bortzmeyer_at_nic.fr>
Date: 2005-10-07 11:10:47 CEST

On Thu, Oct 06, 2005 at 02:29:53PM -0400,
 Yves Bergeron <yves.bergeron@shq.gouv.qc.ca> wrote
 a message of 19 lines which said:

> Hi,

Bonjour,
 
> I know there is a perl script doing this thing
> (contrib/hook-scripts/check-mime-type.pl) but I prefer python since
> I already done a lot of job in that language.

Here is how I do it:

#!/usr/bin/python

import pysvn
import getopt
import sys
import string
import time

# Options by default
path = "." # Current directory
recurse = False
MAX = 60

try:
    optlist, args = getopt.getopt (sys.argv[1:], "p:r",
                                   ["path=", "recurse!"])
    for option, value in optlist:
        if option == "--path" or option == "-p":
            path = value
        elif option == "--recurse" or option == "-r":
            recurse = True
        else:
            raise Exception ("Unknown option " + str(option))
except getopt.error, reason:
    raise Exception ("Usage: " + sys.argv[0] + ": " + str(reason))
if len(args) > 0:
    raise Exception ("Usage: " + sys.argv[0] + ": no arguments expected")
client = pysvn.Client()
files = client.ls(path, recurse=recurse)
for file in files:
    property = client.propget("svn:eol-style", "%s" % file['name'])
    if len(property) > 0:
        print file['name']

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Oct 7 11:13:24 2005

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.