You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Karl Fogel <kf...@galois.collab.net> on 2000/11/22 19:16:43 UTC

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

Greg Stein <gs...@lyra.org> writes:
> Karl: just update the "Mumbo jumbo" and run this baby. It should do bulk of
> the work for you :-)

You rock, thanks!

I'm waiting for us all to sort out the `future version' thing before I
make the change, of course.

-K

> 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/