From 5909e7f37e61b513a8bafb68b537f1e7eaedd52a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 15 Feb 2013 01:03:17 -0500 Subject: [PATCH] quiz: Add copyright metadata 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 | 2 +- quizzer/quiz.py | 9 ++++++--- quizzer/ui/cli.py | 7 +++++++ quizzes/git.json | 17 +++++++++++++++++ quizzes/monty-python.json | 21 +++++++++++++++++++++ quizzes/posix-shell.json | 17 +++++++++++++++++ quizzes/posix-utilities.json | 17 +++++++++++++++++ 7 files changed, 86 insertions(+), 4 deletions(-) diff --git a/.update-copyright.conf b/.update-copyright.conf index 6e12b86..bf05aee 100644 --- a/.update-copyright.conf +++ b/.update-copyright.conf @@ -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. diff --git a/quizzer/quiz.py b/quizzer/quiz.py index f1aed00..4a36f86 100644 --- a/quizzer/quiz.py +++ b/quizzer/quiz.py @@ -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, } diff --git a/quizzer/ui/cli.py b/quizzer/ui/cli.py index 22d4b9b..464faec 100644 --- a/quizzer/ui/cli.py +++ b/quizzer/ui/cli.py @@ -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: diff --git a/quizzes/git.json b/quizzes/git.json index e9b74f2..dc9a53a 100644 --- a/quizzes/git.json +++ b/quizzes/git.json @@ -1,5 +1,22 @@ { "version": "0.1", + "copyright": [ + "Copyright (C) 2013 W. Trevor King ", + "", + "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 ." + ], "introduction": "Test your knowledge of the Git version control system.", "questions": [ { diff --git a/quizzes/monty-python.json b/quizzes/monty-python.json index 882af96..b0d87c6 100644 --- a/quizzes/monty-python.json +++ b/quizzes/monty-python.json @@ -1,5 +1,26 @@ { "version": "0.1", + "copyright": [ + "Copyright (C) 2013 W. Trevor King ", + "", + "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 ." + "", + "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": [ { diff --git a/quizzes/posix-shell.json b/quizzes/posix-shell.json index 30b966b..5fff7fe 100644 --- a/quizzes/posix-shell.json +++ b/quizzes/posix-shell.json @@ -1,5 +1,22 @@ { "version": "0.1", + "copyright": [ + "Copyright (C) 2013 W. Trevor King ", + "", + "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 ." + ], "introduction": "Test your knowledge of the POSIX shell.", "questions": [ { diff --git a/quizzes/posix-utilities.json b/quizzes/posix-utilities.json index cc2f880..ade7598 100644 --- a/quizzes/posix-utilities.json +++ b/quizzes/posix-utilities.json @@ -1,5 +1,22 @@ { "version": "0.1", + "copyright": [ + "Copyright (C) 2013 W. Trevor King ", + "", + "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 ." + ], "introduction": "Test your knowledge of POSIX utilities.", "questions": [ { -- 2.26.2