cookiecutter-flit

A Cookiecutter template for a Flit package
git clone git://git.danielmoch.com/cookiecutter-flit.git
Log | Files | Refs | LICENSE

commit b053afeb3880c3e029b9d0328813e7a7f03f9116
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Sun, 19 Aug 2018 06:54:37 -0400

Initial commit

Diffstat:
ALICENSE | 21+++++++++++++++++++++
Acookiecutter.json | 13+++++++++++++
A{{cookiecutter.project_slug}}/LICENSE | 111+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A{{cookiecutter.project_slug}}/README.md | 7+++++++
A{{cookiecutter.project_slug}}/pyproject.toml | 21+++++++++++++++++++++
A{{cookiecutter.project_slug}}/tests/__init__.py | 3+++
A{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py | 8++++++++
A{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}.py | 3+++
9 files changed, 243 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Daniel Moch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/cookiecutter.json b/cookiecutter.json @@ -0,0 +1,13 @@ +{ + "full_name": "Daniel Moch", + "email": "djmoch@example.com", + "github_username": "djmoch", + "project_name": "Flit Boilerplate", + "project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}", + "project_homepage": "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug.replace('_', '-') }}", + "project_short_description": "Flit Boilerplate contains all the boilerplate you need to create a Python Flit package.", + "pypi_username": "{{ cookiecutter.github_username }}", + "version": "0.1.0", + "use_pytest": "n", + "open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"] +} diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE @@ -0,0 +1,111 @@ +{% if cookiecutter.open_source_license == 'MIT license' -%} +MIT License + +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +{% elif cookiecutter.open_source_license == 'BSD license' %} + +BSD License + +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. +{% elif cookiecutter.open_source_license == 'ISC license' -%} +ISC License + +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%} +Apache Software License 2.0 + +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%} +GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + {{ cookiecutter.project_short_description }} + Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.full_name }} + + This program 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. + + This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. +{% endif %} diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md @@ -0,0 +1,7 @@ +# {{ cookiecutter.project_name }} + +{{ cookiecutter.project_short_description }} + +# Features + +* TODO diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml @@ -0,0 +1,21 @@ +[build-system] +requires = ["flit"] +build-backend = "flit.buildapi" + +[tool.flit.metadata] +module = "{{ cookiecutter.project_slug }}" +author = "{{ cookiecutter.full_name }}" +author-email = "{{ cookiecutter.email }}" +home-page = "{{ cookiecutter.project_homepage }}" +description-file = "README.md" +{% if cookiecutter.open_source_license == 'MIT license' -%} +classifiers = ["License :: OSI Approved :: MIT License"] +{% elif cookiecutter.open_source_license == 'BSD license' %} +classifiers = ["License :: OSI Approved :: BSD License"] +{% elif cookiecutter.open_source_license == 'ISC license' -%} +classifiers = ["License :: OSI Approved :: ISC License (ISCL)"] +{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%} +classifiers = ["License :: OSI Approved :: Apache Software License"] +{% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%} +classifiers = ["License :: OSI Approved :: GNU General Public License v3 (GPLv3)"] +{% endif %} diff --git a/{{cookiecutter.project_slug}}/tests/__init__.py b/{{cookiecutter.project_slug}}/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +"""Unit test package for {{ cookiecutter.project_slug }}.""" diff --git a/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py b/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +"""Tests for `{{ cookiecutter.project_slug }}` package.""" + +{% if cookiecutter.use_pytest == 'y' -%} +import pytest +{% else %} +import unittest +{%- endif %} + +from {{ cookiecutter.project_slug }} import {{ cookiecutter.project_slug }} + +{%- if cookiecutter.use_pytest == 'y' %} + + +@pytest.fixture +def response(): + """Sample pytest fixture. + + See more at: http://doc.pytest.org/en/latest/fixture.html + """ + # import requests + # return requests.get('https://github.com/audreyr/cookiecutter-pypackage') + + +def test_content(response): + """Sample pytest test function with the pytest fixture as an argument.""" + # from bs4 import BeautifulSoup + # assert 'GitHub' in BeautifulSoup(response.content).title.string +{%- else %} + + +class Test{{ cookiecutter.project_slug|title }}(unittest.TestCase): + """Tests for `{{ cookiecutter.project_slug }}` package.""" + + def setUp(self): + """Set up test fixtures, if any.""" + + def tearDown(self): + """Tear down test fixtures, if any.""" + + def test_000_something(self): + """Test something.""" +{%- if cookiecutter.command_line_interface|lower == 'click' %} + + def test_command_line_interface(self): + """Test the CLI.""" + runner = CliRunner() + result = runner.invoke(cli.main) + assert result.exit_code == 0 + assert '{{ cookiecutter.project_slug }}.cli.main' in result.output + help_result = runner.invoke(cli.main, ['--help']) + assert help_result.exit_code == 0 + assert '--help Show this message and exit.' in help_result.output +{%- endif %} +{%- endif %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +"""{{ cookiecutter.project_short_description }}""" + +__author__ = '{{ cookiecutter.full_name }}' +__email__ = '{{ cookiecutter.email }}' +__version__ = '{{ cookiecutter.version }}' +__copyright__ = 'Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }}' diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +"""Main module."""