5 """Update copyright information with information from the VCS repository.
7 Run from the project's repository root.
9 Replaces every line starting with ``^# Copyright`` and continuing with
10 ``^#`` with an auto-generated copyright blurb. If you want to add
11 ``#``-commented material after a copyright blurb, please insert a blank
12 line between the blurb and your comment, so the next run of
13 ``update_copyright.py`` doesn't clobber your comment.
15 If no files are given, a list of files to update is generated
19 import logging as _logging
21 from update_copyright import LOG as _LOG
22 from update_copyright.project import Project
25 if __name__ == '__main__':
29 usage = "%%prog [options] [file ...]"
31 p = optparse.OptionParser(usage=usage, description=__doc__)
32 p.add_option('--config', dest='config', default='.update-copyright.conf',
33 metavar='PATH', help='path to project config file (%default)')
34 p.add_option('--no-authors', dest='authors', default=True,
35 action='store_false', help="Don't generate AUTHORS")
36 p.add_option('--no-files', dest='files', default=True,
37 action='store_false', help="Don't update file copyrights")
38 p.add_option('--no-pyfile', dest='pyfile', default=True,
39 action='store_false', help="Don't update the pyfile")
40 p.add_option('--dry-run', dest='dry_run', default=False,
41 action='store_true', help="Don't make any changes")
42 p.add_option('-v', '--verbose', dest='verbose', default=0,
43 action='count', help='Increment verbosity')
44 options,args = p.parse_args()
46 _LOG.setLevel(max(0, _logging.ERROR - 10*options.verbose))
49 project.load_config(open(options.config, 'r'))
51 project.update_authors(dry_run=options.dry_run)
53 project.update_files(files=args, dry_run=options.dry_run)
55 project.update_pyfile(dry_run=options.dry_run)