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

Re: CVS update: subversion/tools check-license.py

From: Greg Stein <gstein_at_lyra.org>
Date: 2000-11-22 22:28:03 CET

Karl: just update the "Mumbo jumbo" and run this baby. It should do bulk of
the work for you :-)

Cheers,
-g

On Wed, Nov 22, 2000 at 09:10:23PM -0000, gstein@tigris.org wrote:
> User: gstein
> Date: 00/11/22 13:10:23
>
> Modified: tools check-license.py
> Log:
> add the -C switch to support changing licenses in files
>
> Revision Changes Path
> 1.2 +33 -6 subversion/tools/check-license.py
>
> Index: check-license.py
> ===================================================================
> RCS file: /cvs/subversion/tools/check-license.py,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -r1.1 -r1.2
> --- check-license.py 2000/11/17 09:12:26 1.1
> +++ check-license.py 2000/11/22 21:10:23 1.2
> @@ -2,16 +2,17 @@
> #
> # check if a file has the proper license in it
> #
> -# USAGE: check-license.py file1 file2 ... fileN
> +# USAGE: check-license.py [-C] file1 file2 ... fileN
> #
> # If the license cannot be found, then the filename is printed to stdout.
> # Typical usage:
> # $ find . -name "*.[ch]" | xargs check-license.py > bad-files
> #
> -# todo: add a switch for rewriting the file with the right license
> +# -C switch is used to change licenses. Typical usage:
> +# $ find . -name "*.[ch]" | xargs check-license.py -C
> #
>
> -LICENSE = '''\
> +OLD_LICENSE = '''\
> * ================================================================
> * Copyright (c) 2000 CollabNet. All rights reserved.
> *
> @@ -58,14 +59,40 @@
> * individuals on behalf of CollabNet.
> '''
>
> +NEW_LICENSE = '''\
> + * ================================================================
> + * Copyright (c) 2000 CollabNet. All rights reserved.
> + *
> + * Mumbo jumbo goes here
> + *
> + * ====================================================================
> + *
> + * This software consists of voluntary contributions made by many
> + * individuals on behalf of CollabNet.
> +'''
> +
> import sys
> import string
>
> def check_file(fname):
> s = open(fname).read()
> - if string.find(s, LICENSE) == -1:
> + if string.find(s, OLD_LICENSE) == -1:
> print fname
>
> +def change_license(fname):
> + s = open(fname).read()
> + if string.find(s, OLD_LICENSE) == -1:
> + print 'ERROR: missing old license:', fname
> + else:
> + s = string.replace(s, OLD_LICENSE, NEW_LICENSE)
> + open(fname, 'w').write(s)
> + print 'Changed:', fname
> +
> if __name__ == '__main__':
> - for f in sys.argv[1:]:
> - check_file(f)
> + if sys.argv[1] == '-C':
> + print 'Changing license text...'
> + for f in sys.argv[2:]:
> + change_license(f)
> + else:
> + for f in sys.argv[1:]:
> + check_file(f)
>
>
>

-- 
Greg Stein, http://www.lyra.org/
Received on Sat Oct 21 14:36:15 2006

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

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