Avoid discarding the entire copyrights.csv when running the update on Windows, and force slashes in file path strings if adding new files.
* Also rename hash object to avoid collision with built-in hash function.
* Clarified file object is representing a file path string as opposed to an actual open file object.
This should prevent accidental uses of commas in fields without quotes.
It would have caught the previous issue of str.join() not quoting fields
that contain commas. For now though, it found a different issue: three
rows added in commit c631345314 had duplicated MD5 fields.
str.join() isn't smart enough to quote CSV fields when necessary, so
a field containing field separators (commas) would get parsed by the
second update_copyrights run as multiple fields. Upon finding some rows
containing an extra field, the csv.reader() object then added an extra
blank field to each of all the other rows.
Use csv.writer() instead of str.join() to write proper CSV output.
This commit also undoes the removal of commas from fields that was
necessary in commit 676c1fa2b9.
Commit 97c8feb8ca (pull #7903) specified for 58 of LordBob's portraits
a license of "GNU GPL v2+;CC BY-SA 4.0". I don't know if the semicolon
is supposed to mean "and" or "or".
"And" (e.g. a GNU GPL v2+ file with CC BY-SA 4.0 modifications) isn't
legally possible. "Or" appears incorrect, because LordBob [licensed][1]
his portraits under "the GNU GPL" and I can't find any evidence of him
also licensing them under CC BY-SA 4.0.
Also make update_copyrights check for possibly invalid licenses like
"GNU GPL v2+;CC BY-SA 4.0".
[1]: https://forums.wesnoth.org/viewtopic.php?p=329342#p329342
Commit 97c8feb8ca (pull #7903) included a comma in the "Notes" field
of four files, which instead of being enclosed in quotes, overflowed
into the "Needs Update" field. So if those files are updated,
update_copyrights would clobber part of the notes.
Commit 1ecd4f4d59 (pull #8195) updated the "Date" field but didn't
clear "Needs Update" after update_copyrights set "Needs Update" and
"MD5" for data/core/images/units/monsters/raven/harbinger.png.
Make update_copyrights check for and warn about "Needs Update" instead
of clobbering it. This should trigger CI failures if someone forgets
to update a row or accidentally puts into the "Needs Update" field
important information that shouldn't be clobbered on future updates.
When the tool finds new or changed files, it puts them at the top of
the output .csv file for easy editing. However, this means that those
lines move when update_copyrights is run again. It also means that any
two PRs touching images are likely to have merge conflicts, as they'll
change line 2 of copyrights.csv.
Make the CI fail unless the file has been sorted again after editing.