Run update-copyright.py
project: Fallback to directory name if project/name isn't set I recommend folks set this explicitly, but Greg Wilson wanted a way for folks to use update-copyright without having to tweak this name after forking [1]. The approach I've used here isn't the same as the one discussed in that issue (using the name of the upstream Git repository), but I think it's a better choice. Pros and cons: + Simple, VCS-agnostic implementation + Doesn't make assumptions about the upstream repository naming - Assumes folks name their local repository appropriately - Won't handle several projects stored in the same Git repository For example, if you have a branch for project-a and another for project-b that are both in your local project-a repository, you'll have to explicitly set project.name in the project-b branch's .update-copyright.conf. [1]: https://github.com/swcarpentry/lesson-template/pull/197#discussion_r26456407
project: Require project/vcs We use the configured VCS for the author list and per-file updates, so there's nothing we can do if the user hasn't set it. Instead of crashing with: Traceback (most recent call last): File "./bin/update-copyright.py", line 80, in <module> project.update_authors(dry_run=args.dry_run) File "/.../update_copyright/project.py", line 162, in update_authors authors = self._vcs.authors() AttributeError: 'NoneType' object has no attribute 'authors' Die earlier with: Traceback (most recent call last): File "./bin/update-copyright.py", line 78, in <module> project.load_config(open(args.config, 'r')) File "/home/wking/src/update-copyright/update_copyright/project.py", line 66, in load_config loader(parser=parser) File "/home/wking/src/update-copyright/update_copyright/project.py", line 89, in _load_project_conf raise NotImplementedError('vcs: {}'.format(vcs)) NotImplementedError: vcs: None We may want to add some auto-detection logic here in the future.
project: Convert parser access to use the mapping protocol Use the more dict-like access [1] instead of the API that's specific to ConfigParser. This is likely to be more familiar to future developers, and reduces the cognitive load of dealing with another API. The only place I couldn't drop the old API was in load_config, where I kept parser.sections() [2] because using parser.keys() was giving me: AttributeError: 'Project' object has no attribute '_load_DEFAULT_conf' The: try: section = parser['...'] except KeyError: section = {} blocks are also more awkward than a dicts: section = parser.get('...', {}) but we can't use that API because it's clobbered by ConfigParser.get(section, option, ...) [3]. Maybe someday they'll support: section = parser.get('...', default={}) (or with 'fallback' instead of 'default'). [1]: https://docs.python.org/3/library/configparser.html#mapping-protocol-access [2]: https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.sections [3]: https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.get
Run update-copyright.py
vcs.bazaar: Remove Bazaar support As of 2013-05-19, Bazaar had no Python 3 compatibility, and no likelyhood of adding it in the near future [1]. This module could be ported to use the command line client (like Git), but I also haven't seen a Bazaar repository in a while ;). [1]: https://answers.launchpad.net/bzr/+question/229048#comment-0
project: Replace original_year and final_year with years Rather than automatically bumping the final year to the current year, only bump to the last year for which a file was changed. I've kept the 'first-last' syntax, but update_copyright.utils.copyright_string is not the only place you have to edit if you prefer to list them all explicitly: Copyright (C) year-1, year-2, ..., year-n A. U. Thor ...
Ran update-copyright.py
project: Load files.authors and files.files as booleans Because both `bool('yes')` and `bool('no')` are True.
project: don't explicitly convert configured options to unicode strings Python 3's ConfigParser does this for us.
project: add Project._split_paragraph(). Now we split on double-newlines, not single newlines. This is how our README example and internal .update-copyright.conf are formatted.
project: use (start, middle, end) prefixes in copyright_string() calls
project|utils: expand info into kwargs for format().
project|(vcs:utils): convert unicode() -> str().
Upgrade to Python 3.2 bzrlib and mercurial aren't Python 3 compatible yet (and seem unlikely to become compatible in the near future), so if you're using them, you should stick with an older version of update-copyright. Note that the version of Python used by update-copyright has nothing to do with the version of Python you use in your project. You project doesn't even have to use Python at all.
Update exception handling to use `except X as Y` syntax.
project: for consistency, also separate ignored paths with pipes.
project: for consistency, also separate alias authors with pipes.
project: use pipe symbols (|) to separate author-hack authors. Author names may contain commas (e.g. "Red Hat, Inc."), but are unlikely to contain pipe symbols.
project: configured author keys should be converted to unicode.