|
| 1 | +from datetime import datetime |
| 2 | + |
| 3 | + |
| 4 | +def render(plugin_metadata) -> str: |
| 5 | + """Render LICENSE.rst.""" |
| 6 | + license_name = plugin_metadata["info"]["package_license"] |
| 7 | + kwds = { |
| 8 | + "full_name": plugin_metadata["info"]["package_author"], |
| 9 | + "year": datetime.now().year, |
| 10 | + "project_short_description": plugin_metadata["info"]["summary"], |
| 11 | + } |
| 12 | + |
| 13 | + return LICENSE[license_name].format(**kwds) |
| 14 | + |
| 15 | + |
| 16 | +LICENSE = { |
| 17 | + "MIT License": """\ |
| 18 | +MIT License |
| 19 | +=========== |
| 20 | +
|
| 21 | +Copyright (c) *{year}*, *{full_name}* |
| 22 | +
|
| 23 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 24 | +of this software and associated documentation files (the "Software"), to deal |
| 25 | +in the Software without restriction, including without limitation the rights |
| 26 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 27 | +copies of the Software, and to permit persons to whom the Software is |
| 28 | +furnished to do so, subject to the following conditions: |
| 29 | +
|
| 30 | +The above copyright notice and this permission notice shall be included in all |
| 31 | +copies or substantial portions of the Software. |
| 32 | +
|
| 33 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 34 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 35 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 36 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 37 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 38 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 39 | +SOFTWARE.\ |
| 40 | +""", |
| 41 | + "BSD License": """\ |
| 42 | +BSD License |
| 43 | +=========== |
| 44 | +
|
| 45 | +Copyright (c) *{year}*, *{full_name}* |
| 46 | +All rights reserved. |
| 47 | +
|
| 48 | +Redistribution and use in source and binary forms, with or without modification, |
| 49 | +are permitted provided that the following conditions are met: |
| 50 | +
|
| 51 | +* Redistributions of source code must retain the above copyright notice, this |
| 52 | + list of conditions and the following disclaimer. |
| 53 | +
|
| 54 | +* Redistributions in binary form must reproduce the above copyright notice, this |
| 55 | + list of conditions and the following disclaimer in the documentation and/or |
| 56 | + other materials provided with the distribution. |
| 57 | +
|
| 58 | +* Neither the name of the copyright holder nor the names of its |
| 59 | + contributors may be used to endorse or promote products derived from this |
| 60 | + software without specific prior written permission. |
| 61 | +
|
| 62 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 63 | +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 64 | +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 65 | +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 66 | +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 67 | +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 68 | +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 69 | +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 70 | +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 71 | +OF THE POSSIBILITY OF SUCH DAMAGE. |
| 72 | +""", |
| 73 | + "ISC License": """\ |
| 74 | +ISC License |
| 75 | +=========== |
| 76 | +
|
| 77 | +Copyright (c) *{year}*, *{full_name}* |
| 78 | +
|
| 79 | +Permission to use, copy, modify, and/or distribute this software for any purpose |
| 80 | +with or without fee is hereby granted, provided that the above copyright notice |
| 81 | +and this permission notice appear in all copies. |
| 82 | +
|
| 83 | +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 84 | +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 85 | +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 86 | +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 87 | +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 88 | +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 89 | +PERFORMANCE OF THIS SOFTWARE.\ |
| 90 | +""", |
| 91 | + "Apache Software License 2.0": """\ |
| 92 | +Apache Software License 2.0 |
| 93 | +=========================== |
| 94 | +
|
| 95 | +Copyright (c) *{year}*, *{full_name}* |
| 96 | +
|
| 97 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 98 | +you may not use this file except in compliance with the License. |
| 99 | +You may obtain a copy of the License at |
| 100 | +
|
| 101 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 102 | +
|
| 103 | +Unless required by applicable law or agreed to in writing, software |
| 104 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 105 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 106 | +See the License for the specific language governing permissions and |
| 107 | +limitations under the License.\ |
| 108 | +""", |
| 109 | + "GNU General Public License v3": """\ |
| 110 | +GNU GENERAL PUBLIC LICENSE |
| 111 | +========================== |
| 112 | +
|
| 113 | + Version 3, 29 June 2007 |
| 114 | +
|
| 115 | + {project_short_description} |
| 116 | + Copyright (c) *{year}*, *{full_name}* |
| 117 | +
|
| 118 | + This program is free software: you can redistribute it and/or modify |
| 119 | + it under the terms of the GNU General Public License as published by |
| 120 | + the Free Software Foundation, either version 3 of the License, or |
| 121 | + (at your option) any later version. |
| 122 | +
|
| 123 | + This program is distributed in the hope that it will be useful, |
| 124 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 125 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 126 | + GNU General Public License for more details. |
| 127 | +
|
| 128 | + You should have received a copy of the GNU General Public License |
| 129 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 130 | +
|
| 131 | +Also add information on how to contact you by electronic and paper mail. |
| 132 | +
|
| 133 | + You should also get your employer (if you work as a programmer) or school, |
| 134 | +if any, to sign a "copyright disclaimer" for the program, if necessary. |
| 135 | +For more information on this, and how to apply and follow the GNU GPL, see |
| 136 | +<http://www.gnu.org/licenses/>. |
| 137 | +
|
| 138 | + The GNU General Public License does not permit incorporating your program |
| 139 | +into proprietary programs. If your program is a subroutine library, you |
| 140 | +may consider it more useful to permit linking proprietary applications with |
| 141 | +the library. If this is what you want to do, use the GNU Lesser General |
| 142 | +Public License instead of this License. But first, please read |
| 143 | +<http://www.gnu.org/philosophy/why-not-lgpl.html>.\ |
| 144 | +""", |
| 145 | +} |
0 commit comments