quiz: Add copyright metadata
authorW. Trevor King <wking@tremily.us>
Fri, 15 Feb 2013 06:03:17 +0000 (01:03 -0500)
committerW. Trevor King <wking@tremily.us>
Fri, 15 Feb 2013 06:05:54 +0000 (01:05 -0500)
Because quizzer may be used to administer quizzes that are not under
the GPLv3+, make it easy to store and access per-quiz copyrights.

Also add a `copyright` command to ui.cli.QuestionCommandLine and add
copyright blurbs to the individual quizzes.

.update-copyright.conf
quizzer/quiz.py
quizzer/ui/cli.py
quizzes/git.json
quizzes/monty-python.json
quizzes/posix-shell.json
quizzes/posix-utilities.json

index 6e12b86b861d5f7c36c3c199ecc0c50352be9e60..bf05aee03f0c8f7ee7c976d453097e2724d9082a 100644 (file)
@@ -6,7 +6,7 @@ vcs: Git
 authors: yes
 files: yes
 ignored: COPYING | README | .update-copyright.conf | .git* | */.gitignore |
-  *.pyc
+  quizzes/ | *.pyc
 
 [copyright]
 short: {project} comes with ABSOLUTELY NO WARRANTY and is licensed under the GNU General Public License.
index f1aed0038bf99a915c0eff2e5ee732193282ef4a..4a36f86c9856f4995a104d2fe1c9d6a9c1def514 100644 (file)
@@ -22,14 +22,15 @@ from . import question as _question
 
 
 class Quiz (list):
-    def __init__(self, introduction=None, questions=None, path=None,
-                 encoding=None):
-        self.introduction = introduction
+    def __init__(self, questions=None, path=None, encoding=None,
+                 copyright=None, introduction=None):
         if questions is None:
             questions = []
         super(Quiz, self).__init__(questions)
         self.path = path
         self.encoding = encoding
+        self.copyright = copyright
+        self.introduction = introduction
 
     def _open(self, mode='r', path=None, encoding=None):
         if path:
@@ -45,6 +46,7 @@ class Quiz (list):
         if version != __version__:
             raise NotImplementedError('upgrade from {} to {}'.format(
                     version, __version__))
+        self.copyright = data.get('copyright', None)
         self.introduction = data.get('introduction', None)
         for state in data['questions']:
             question_class_name = state.pop('class', 'Question')
@@ -60,6 +62,7 @@ class Quiz (list):
             state['class'] = type(question).__name__
         data = {
             'version': __version__,
+            'copyright': self.copyright,
             'introduction': self.introduction,
             'questions': questions,
             }
index 22d4b9b3e017ce25734307f7d850f939d5a52b31..464faec2ee62c0942299354684b03ab9e6228084 100644 (file)
@@ -157,6 +157,13 @@ class QuestionCommandLine (_cmd.Cmd):
         self._reset()
         print(self.question.format_help())
 
+    def do_copyright(self, arg):
+        "Print the quiz copyright notice"
+        if self.ui.quiz.copyright:
+            print('\n'.join(self.ui.quiz.copyright))
+        else:
+            print(self.ui.quiz.copyright)
+
     def do_help(self, arg):
         'List available commands with "help" or detailed help with "help cmd"'
         if not arg:
index e9b74f2056c35c033a7c7ab8ed165f993ecf9fd7..dc9a53a20644fc6571f0ef5994a2d898eb7a0438 100644 (file)
@@ -1,5 +1,22 @@
 {
        "version": "0.1",
+       "copyright": [
+               "Copyright (C) 2013 W. Trevor King <wking@tremily.us>",
+               "",
+               "This file is part of quizzer.",
+               "",
+               "quizzer is free software: you can redistribute it and/or modify it under the",
+               "terms of the GNU General Public License as published by the Free Software",
+               "Foundation, either version 3 of the License, or (at your option) any later",
+               "version.",
+               "",
+               "quizzer is distributed in the hope that it will be useful, but WITHOUT ANY",
+               "WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR",
+               "A PARTICULAR PURPOSE.  See the GNU General Public License for more details.",
+               "",
+               "You should have received a copy of the GNU General Public License along with",
+               "quizzer.  If not, see <http://www.gnu.org/licenses/>."
+               ],
        "introduction": "Test your knowledge of the Git version control system.",
        "questions": [
                {
index 882af9695b2ea59bdc1b6d9583500e53e52d81ee..b0d87c6f3612f0bacb8fa52ccc8e753f1869817f 100644 (file)
@@ -1,5 +1,26 @@
 {
        "version": "0.1",
+       "copyright": [
+               "Copyright (C) 2013 W. Trevor King <wking@tremily.us>",
+               "",
+               "This file is part of quizzer.",
+               "",
+               "quizzer is free software: you can redistribute it and/or modify it under the",
+               "terms of the GNU General Public License as published by the Free Software",
+               "Foundation, either version 3 of the License, or (at your option) any later",
+               "version.",
+               "",
+               "quizzer is distributed in the hope that it will be useful, but WITHOUT ANY",
+               "WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR",
+               "A PARTICULAR PURPOSE.  See the GNU General Public License for more details.",
+               "",
+               "You should have received a copy of the GNU General Public License along with",
+               "quizzer.  If not, see <http://www.gnu.org/licenses/>."
+               "",
+               "The quotations from \"Monty Python and the Holy Grail\" are copyright someone",
+               "else (possibly Freeway Cam (UK) Limited?), but the quotes are short and",
+               "should fall under \"fair use\"."
+               ],
        "introduction": "Test your knowledge of Monty Python and the Holy Grail!",
        "questions": [
                {
index 30b966b15cd49d0bc3231a0c847dd066d8b7cef2..5fff7fe2dd9f60dda9d13fb7cb08bca5f9f15419 100644 (file)
@@ -1,5 +1,22 @@
 {
        "version": "0.1",
+       "copyright": [
+               "Copyright (C) 2013 W. Trevor King <wking@tremily.us>",
+               "",
+               "This file is part of quizzer.",
+               "",
+               "quizzer is free software: you can redistribute it and/or modify it under the",
+               "terms of the GNU General Public License as published by the Free Software",
+               "Foundation, either version 3 of the License, or (at your option) any later",
+               "version.",
+               "",
+               "quizzer is distributed in the hope that it will be useful, but WITHOUT ANY",
+               "WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR",
+               "A PARTICULAR PURPOSE.  See the GNU General Public License for more details.",
+               "",
+               "You should have received a copy of the GNU General Public License along with",
+               "quizzer.  If not, see <http://www.gnu.org/licenses/>."
+               ],
        "introduction": "Test your knowledge of the POSIX shell.",
        "questions": [
                {
index cc2f88052d08774dd5ac86a2e15992563df2b049..ade759860abeb498fcdf4312535c3c4e71e06353 100644 (file)
@@ -1,5 +1,22 @@
 {
        "version": "0.1",
+       "copyright": [
+               "Copyright (C) 2013 W. Trevor King <wking@tremily.us>",
+               "",
+               "This file is part of quizzer.",
+               "",
+               "quizzer is free software: you can redistribute it and/or modify it under the",
+               "terms of the GNU General Public License as published by the Free Software",
+               "Foundation, either version 3 of the License, or (at your option) any later",
+               "version.",
+               "",
+               "quizzer is distributed in the hope that it will be useful, but WITHOUT ANY",
+               "WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR",
+               "A PARTICULAR PURPOSE.  See the GNU General Public License for more details.",
+               "",
+               "You should have received a copy of the GNU General Public License along with",
+               "quizzer.  If not, see <http://www.gnu.org/licenses/>."
+               ],
        "introduction": "Test your knowledge of POSIX utilities.",
        "questions": [
                {