martin-ueding/copyright-updater — pull request #6 by rich-pixley (2013-05-12 03:47:46+00:00)
Title: many changes, primarily dealing with options and tests

Here's my day and a half on it.

Many changes today.

First, the caveats. I've done nothing about vim support. Nothing at
all.

Also, there are a few new library requirements, but they're all in the
standard python library, although argparse now forces us to drop support
for python-2.6 and python-3.1, both of which lacked argparse.

Primarily, I was interested in better testing. To make that happen, I
had to rationalize the parameters that came from config file and
command line. I did that by inventing class ParamBlock.

Linelimit is now a configfile option.

I revamped the "unicode" option. It's now "symbol-style" and allows
you to either force the copyright symbol to be an arbitrary string,
(presumably "(C)", "(c)", or "©"), remove it entirely using "", or
leave it unchanged, (if unset).

I dropped the email field. It's trivial to add as part of the name
and I couldn't see any value to carrying it separately from the name.

The year to use in the copyright rewrite is now also a possible
option.

I've added an option for warning about files for which no suitable
copyright line can be found.

I've completely revamped the configfile. Options are now all in the
same 'copyrightupdate' section and look like this:

[copyrightupdate]
linelimit = 6
name = Joe Blow
symbol_style = "(C)"
year = 1999
warn = yes

And there are a slew of new tests covering most of these cases.

Among the bugs squashed:
* Unicode wasn't rewriting "(C)"
* If nothing is changed, source file is not rewritten. This is a
performance optimization from several angles. First, no time is
spent writing an unchanged file. And second, things like indexers,
source code control, editors, etc, which key off the last modification
time of the file are only alerted when a file actually changes.
* parameterized the year to use when updating - makes tests easier and
adds a feature to the suite.
* recompile regex only when necessary, (was too many times)
* read configfile only once, (was too many times)
* a couple of bugs in regex's