Implement fix-copyright and fix some of them
This commit is contained in:
parent
4c24cde923
commit
99e8077f59
@ -19,6 +19,14 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
source_exts = [ '.py', '.c', '.h', '.cpp' ]
|
||||||
|
|
||||||
|
def is_source(path):
|
||||||
|
for ext in source_exts:
|
||||||
|
if path.endswith(ext):
|
||||||
|
return True
|
||||||
|
|
||||||
def get_name_and_version():
|
def get_name_and_version():
|
||||||
f = open('configure.ac', 'r')
|
f = open('configure.ac', 'r')
|
||||||
@ -35,8 +43,9 @@ def get_name_and_version():
|
|||||||
|
|
||||||
def cmd_help():
|
def cmd_help():
|
||||||
print 'Usage: \n\
|
print 'Usage: \n\
|
||||||
maint-helper.py build-snapshot - build a source snapshot \n\
|
maint-helper.py build-snapshot - build a source snapshot \n\
|
||||||
maint-helper.py check-licenses - check licenses in the source'
|
maint-helper.py fix-copyright [path] - fix the copyright year \n\
|
||||||
|
maint-helper.py check-licenses - check licenses in the source'
|
||||||
|
|
||||||
def cmd_build_snapshot():
|
def cmd_build_snapshot():
|
||||||
[ name, version ] = get_name_and_version()
|
[ name, version ] = get_name_and_version()
|
||||||
@ -53,7 +62,6 @@ def cmd_build_snapshot():
|
|||||||
def check_licenses(path, license, missing):
|
def check_licenses(path, license, missing):
|
||||||
matchers = { 'LGPL' : 'GNU Lesser General Public',
|
matchers = { 'LGPL' : 'GNU Lesser General Public',
|
||||||
'GPL' : 'GNU General Public License' }
|
'GPL' : 'GNU General Public License' }
|
||||||
source_exts = [ '.py', '.c', '.h', '.cpp' ]
|
|
||||||
|
|
||||||
license_file = os.path.join(path, '.license')
|
license_file = os.path.join(path, '.license')
|
||||||
if os.path.isfile(license_file):
|
if os.path.isfile(license_file):
|
||||||
@ -67,10 +75,7 @@ def check_licenses(path, license, missing):
|
|||||||
if os.path.isdir(full_path):
|
if os.path.isdir(full_path):
|
||||||
check_licenses(full_path, license, missing)
|
check_licenses(full_path, license, missing)
|
||||||
else:
|
else:
|
||||||
check_source = False
|
check_source = is_source(item)
|
||||||
for ext in source_exts:
|
|
||||||
if item.endswith(ext):
|
|
||||||
check_source = True
|
|
||||||
|
|
||||||
# Special cases.
|
# Special cases.
|
||||||
if item.find('marshal') > 0 or \
|
if item.find('marshal') > 0 or \
|
||||||
@ -105,9 +110,52 @@ def cmd_check_licenses():
|
|||||||
print path
|
print path
|
||||||
print '\n'
|
print '\n'
|
||||||
|
|
||||||
|
COPYRIGHT = 'Copyright (C) '
|
||||||
|
|
||||||
|
def fix_copyright(path):
|
||||||
|
for item in os.listdir(path):
|
||||||
|
full_path = os.path.join(path, item)
|
||||||
|
|
||||||
|
if os.path.isdir(full_path):
|
||||||
|
fix_copyright(full_path)
|
||||||
|
elif is_source(item):
|
||||||
|
f = open(full_path, 'r')
|
||||||
|
source = f.read()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
year_start = -1
|
||||||
|
year_end = -1
|
||||||
|
|
||||||
|
i1 = source.find(COPYRIGHT)
|
||||||
|
if i1 != -1:
|
||||||
|
i1 += len(COPYRIGHT)
|
||||||
|
i2 = i1 + source[i1:].find(' ')
|
||||||
|
if i1 > 0:
|
||||||
|
try:
|
||||||
|
year_start = int(source[i1:i1 + 4])
|
||||||
|
year_end = int(source[i1 + 6: i1 + 10])
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if year_start > 0 and year_end < 0:
|
||||||
|
year_end = year_start
|
||||||
|
|
||||||
|
year = datetime.date.today().year
|
||||||
|
if year_end < year:
|
||||||
|
result = '%s%d-%d%s' % (source[:i1], year_start,
|
||||||
|
year, source[i2:])
|
||||||
|
f = open(full_path, 'w')
|
||||||
|
f.write(result)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
def cmd_fix_copyright(path):
|
||||||
|
fix_copyright(path)
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
cmd_help()
|
cmd_help()
|
||||||
elif sys.argv[1] == 'build-snapshot':
|
elif sys.argv[1] == 'build-snapshot':
|
||||||
cmd_build_snapshot()
|
cmd_build_snapshot()
|
||||||
elif sys.argv[1] == 'check-licenses':
|
elif sys.argv[1] == 'check-licenses':
|
||||||
cmd_check_licenses()
|
cmd_check_licenses()
|
||||||
|
elif sys.argv[1] == 'fix-copyright' and len(sys.argv) > 2:
|
||||||
|
cmd_fix_copyright(sys.argv[2])
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
This is currently the only reference for what an
|
This is currently the only reference for what an
|
||||||
activity must do to participate in the Sugar desktop.
|
activity must do to participate in the Sugar desktop.
|
||||||
"""
|
"""
|
||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Shell side object which manages request to start activity"""
|
"""Shell side object which manages request to start activity"""
|
||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
# Copyright (C) 2007, One Laptop Per Child
|
# Copyright (C) 2007, One Laptop Per Child
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Calculates file-paths for the Sugar working environment"""
|
"""Calculates file-paths for the Sugar working environment"""
|
||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Logging module configuration for Sugar"""
|
"""Logging module configuration for Sugar"""
|
||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
|
||||||
# ltihooks.py: python import hooks that understand libtool libraries.
|
# ltihooks.py: python import hooks that understand libtool libraries.
|
||||||
# Copyright (C) 2000 James Henstridge.
|
# Copyright (C) 2000-2007 James Henstridge.
|
||||||
# renamed to gstltihooks.py so it does not accidentally get imported by
|
# renamed to gstltihooks.py so it does not accidentally get imported by
|
||||||
# an installed copy of gtk
|
# an installed copy of gtk
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""User settings/configuration loading"""
|
"""User settings/configuration loading"""
|
||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Various utility functions"""
|
"""Various utility functions"""
|
||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
Loading…
Reference in New Issue
Block a user