Skip to content

Commit

Permalink
used cookiecutter
Browse files Browse the repository at this point in the history
  • Loading branch information
eyal0 committed Feb 7, 2017
1 parent 3228272 commit 0806a1d
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 44 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include README.md
recursive-include octoprint_slic3r *
6 changes: 6 additions & 0 deletions babel.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[python: */**.py]
[jinja2: */**.jinja2]
extensions=jinja2.ext.autoescape, jinja2.ext.with_

[javascript: */**.js]
extract_messages = gettext, ngettext
8 changes: 8 additions & 0 deletions extras/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Currently Cookiecutter generates the following helpful extras to this folder:

slic3r.md
Data file for plugins.octoprint.org. Fill in the missing TODOs once your
plugin is ready for release and file a PR as described at
http://plugins.octoprint.org/help/registering/ to get it published.

This folder may be safely removed if you don't need it.
55 changes: 55 additions & 0 deletions extras/slic3r.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
layout: plugin

id: slic3r
title: OctoPrint-Slic3r
description: TODO
author: You
license: AGPLv3

# TODO
date: today's date in format YYYY-MM-DD, e.g. 2015-04-21

homepage: https://github.com/you/OctoPrint-Slic3r
source: https://github.com/you/OctoPrint-Slic3r
archive: https://github.com/you/OctoPrint-Slic3r/archive/master.zip

# TODO set this to true if your plugin uses the dependency_links setup parameter to include
# library versions not yet published on PyPi. SHOULD ONLY BE USED IF THERE IS NO OTHER OPTION!
follow_dependency_links: false

# TODO
tags:
- a list
- of tags
- that apply
- to your plugin
- (take a look at the existing plugins for what makes sense here)

# TODO
screenshots:
- url: url of a screenshot
alt: alt-text of a screenshot
caption: caption of a screenshot
- url: url of another screenshot
alt: alt-text of another screenshot
caption: caption of another screenshot
- ...

# TODO
featuredimage: url of a featured image for your plugin

compatibility:
# list of compatible versions, for example 1.2.0. If left empty no specific version requirement will be assumed
octoprint:
- 1.2.0

# list of compatible operating systems, valid values are linux, windows, macos, leaving empty defaults to all
os:
- linux
- windows
- macos
---

**TODO**: Longer description of your plugin, configuration examples etc. This part will be visible on the page at
http://plugins.octoprint.org/plugin/slic3r/
26 changes: 13 additions & 13 deletions octoprint_slic3r/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# coding=utf-8
from __future__ import absolute_import

__author__ = "Gina Häußge <[email protected]>"
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"

import logging
import logging.handlers
import os
Expand Down Expand Up @@ -50,12 +46,12 @@ def get_update_information(self):

# version check: github repository
type="github_release",
user="Javierma",
user="OctoPrint",
repo="OctoPrint-Slic3r",
current=self._plugin_version,

# update method: pip
pip="https://github.com/eyal0/OctoPrint-Slic3r/archive/{target_version}.zip"
pip="https://github.com/OctoPrint/OctoPrint-Slic3r/archive/{target_version}.zip"
)
)

Expand Down Expand Up @@ -141,7 +137,7 @@ def importSlic3rProfile(self):
r.headers["Location"] = result["resource"]
return r

##~~ AssetPlugin API
##~~ AssetPlugin mixin

def get_assets(self):
return {
Expand All @@ -150,7 +146,7 @@ def get_assets(self):
"css": ["css/slic3r.css"]
}

##~~ SettingsPlugin API
##~~ SettingsPlugin mixin

def on_settings_save(self, data):
old_debug_logging = self._settings.get_boolean(["debug_logging"])
Expand Down Expand Up @@ -321,8 +317,12 @@ def _sanitize_name(name):
return sanitized_name.lower()

__plugin_name__ = "Slic3r"
__plugin_version__ = "0.1"
__plugin_implementation__ = Slic3rPlugin()
__plugin_hooks__ = {
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
}

def __plugin_load__():
global __plugin_implementation__
__plugin_implementation__ = Slic3rPlugin()

global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
}
10 changes: 9 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
OctoPrint
###
# This file is only here to make sure that something like
#
# pip install -e .
#
# works as expected. Requirements can be found in setup.py.
###

.
110 changes: 80 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,91 @@
# coding=utf-8
import setuptools

def package_data_dirs(source, sub_folders):
import os
dirs = []
# The plugin's identifier, has to be unique
plugin_identifier = "slic3r"

for d in sub_folders:
for dirname, _, files in os.walk(os.path.join(source, d)):
dirname = os.path.relpath(dirname, source)
for f in files:
dirs.append(os.path.join(dirname, f))
# The plugin's python package, should be "octoprint_<plugin identifier>", has to be unique
plugin_package = "octoprint_slic3r"

return dirs
# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the
# plugin module
plugin_name = "OctoPrint-Slic3r"

def params():
name = "OctoPrint-Slic3r"
version = "0.1"
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.0.0"

description = "Adds support for slicing via Slic3r from within OctoPrint"
author = "Gina Häußge"
author_email = "[email protected]"
url = "http://github.com/OctoPrint/OctoPrint-Slic3r"
license = "AGPLv3"
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
plugin_description = """Adds support for slicing via Slic3r from within OctoPrint"""

packages = ["octoprint_slic3r"]
package_data = {"octoprint_slic3r": package_data_dirs('octoprint_slic3r', ['static', 'templates', 'profiles'])}
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module
plugin_author = "Gina Häußge"

include_package_data = True
zip_safe = False
install_requires = open("requirements.txt").read().split("\n")
# The plugin's author's mail address.
plugin_author_email = "[email protected]"

entry_points = {
"octoprint.plugin": [
"slic3r = octoprint_slic3r"
]
}
# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module
plugin_url = "http://github.com/OctoPrint/OctoPrint-Slic3r"

return locals()
# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module
plugin_license = "AGPLv3"

setuptools.setup(**params())
# Any additional requirements besides OctoPrint should be listed here
plugin_requires = []

### --------------------------------------------------------------------------------------------------------------------
### More advanced options that you usually shouldn't have to touch follow after this point
### --------------------------------------------------------------------------------------------------------------------

# Additional package data to install for this plugin. The subfolders "templates", "static" and "translations" will
# already be installed automatically if they exist.
plugin_additional_data = []

# Any additional python packages you need to install with your plugin that are not contained in <plugin_package>.*
plugin_additional_packages = []

# Any python packages within <plugin_package>.* you do NOT want to install with your plugin
plugin_ignored_packages = []

# Additional parameters for the call to setuptools.setup. If your plugin wants to register additional entry points,
# define dependency links or other things like that, this is the place to go. Will be merged recursively with the
# default setup parameters as provided by octoprint_setuptools.create_plugin_setup_parameters using
# octoprint.util.dict_merge.
#
# Example:
# plugin_requires = ["someDependency==dev"]
# additional_setup_parameters = {"dependency_links": ["https://github.com/someUser/someRepo/archive/master.zip#egg=someDependency-dev"]}
additional_setup_parameters = {}

########################################################################################################################

from setuptools import setup

try:
import octoprint_setuptools
except:
print("Could not import OctoPrint's setuptools, are you sure you are running that under "
"the same python installation that OctoPrint is installed under?")
import sys
sys.exit(-1)

setup_parameters = octoprint_setuptools.create_plugin_setup_parameters(
identifier=plugin_identifier,
package=plugin_package,
name=plugin_name,
version=plugin_version,
description=plugin_description,
author=plugin_author,
mail=plugin_author_email,
url=plugin_url,
license=plugin_license,
requires=plugin_requires,
additional_packages=plugin_additional_packages,
ignored_packages=plugin_ignored_packages,
additional_data=plugin_additional_data
)

if len(additional_setup_parameters):
from octoprint.util import dict_merge
setup_parameters = dict_merge(setup_parameters, additional_setup_parameters)

setup(**setup_parameters)
28 changes: 28 additions & 0 deletions translations/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Your plugin's translations will reside here. The provided setup.py supports a
couple of additional commands to make managing your translations easier:

babel_extract
Extracts any translateable messages (marked with Jinja's `_("...")` or
JavaScript's `gettext("...")`) and creates the initial `messages.pot` file.
babel_refresh
Reruns extraction and updates the `messages.pot` file.
babel_new --locale=<locale>
Creates a new translation folder for locale `<locale>`.
babel_compile
Compiles the translations into `mo` files, ready to be used within
OctoPrint.
babel_pack --locale=<locale> [ --author=<author> ]
Packs the translation for locale `<locale>` up as an installable
language pack that can be manually installed by your plugin's users. This is
interesting for languages you can not guarantee to keep up to date yourself
with each new release of your plugin and have to depend on contributors for.

If you want to bundle translations with your plugin, create a new folder
`octoprint_slic3r/translations`. When that folder exists,
an additional command becomes available:

babel_bundle --locale=<locale>
Moves the translation for locale `<locale>` to octoprint_slic3r/translations,
effectively bundling it with your plugin. This is interesting for languages
you can guarantee to keep up to date yourself with each new release of your
plugin.

0 comments on commit 0806a1d

Please sign in to comment.