Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add errorhandler decorator for the blueprintplugin #1059

Merged
merged 1 commit into from Sep 11, 2015

Conversation

Projects
None yet
2 participants
@hellow554
Copy link

commented Sep 11, 2015

for description refer to #1058

Sorry for the branch thing. I totally forgot that.

Marcel Hellwig
add errorhandler decorator to blueprintplugin
This will allow you to add an errorhandler for your blueprint easily.
@foosel

This comment has been minimized.

Copy link
Owner

commented Sep 11, 2015

No problem. Want to also add yourself to AUTHORS.md or should I?

@hellow554

This comment has been minimized.

Copy link
Author

commented Sep 11, 2015

It is easier if you do it ;) but thanks

btw.

$ find . -name '*.py' -exec grep '     ' {} \+ | wc -l
3766

@foosel

This comment has been minimized.

Copy link
Owner

commented Sep 11, 2015

Ah... you were referring to the alignment whitespace, not the indentation whitespace. That's what's commonly referred to as "smart tabs".

foosel added a commit that referenced this pull request Sep 11, 2015

Merge pull request #1059 from punkkeks/devel
Add errorhandler decorator for the blueprintplugin

@foosel foosel merged commit 96f54ff into foosel:devel Sep 11, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@hellow554

This comment has been minimized.

Copy link
Author

commented Sep 11, 2015

Sorry, forgot the ^ Then wc -l will only print out 2071. But okay. I aggree with you, that the blame will print out nothing acceptable anymore. Thanks for the merge ;)

@hellow554 hellow554 deleted the hellow554:devel branch Sep 11, 2015

@foosel

This comment has been minimized.

Copy link
Owner

commented Sep 11, 2015

If it helps, I bite myself in the arse for not converting the source to spaces back when I forked from Cura ;) I could bite myself for a lot of things that are now hard to change without making debugging more complicated, merging of bug fixes impossible etc or just have a completely wrong cost/usefulness ratio...

The ^ will btw also capture stuff like:

class CuraPlugin(octoprint.plugin.SlicerPlugin,
                 octoprint.plugin.SettingsPlugin,
                 octoprint.plugin.TemplatePlugin,
                 octoprint.plugin.AssetPlugin,
                 octoprint.plugin.BlueprintPlugin,
                 octoprint.plugin.StartupPlugin):

which again is a case of smart tabs at work and

deprecated = warning_decorator_factory(DeprecationWarning)
"""
A decorator for deprecated methods. Logs a deprecation warning via Python's `:mod:`warnings` module including the
supplied ``message``. The call stack level used (for adding the source location of the offending call to the
warning) can be overridden using the optional ``stacklevel`` parameter. If both ``since`` and ``includedoc`` are
provided, a deprecation warning will also be added to the function's docstring by providing or extending its ``__doc__``
property.

Arguments:
    message (string): The message to include in the deprecation warning.
    stacklevel (int): Stack level for including the caller of the offending method in the logged warning. Defaults to 1,
        meaning the direct caller of the method. It might make sense to increase this in case of the function call
        happening dynamically from a fixed position to not shadow the real caller (e.g. in case of overridden
        ``getattr`` methods).
    includedoc (string): Message about the deprecation to include in the wrapped function's docstring.
    extenddoc (boolean): If True the original docstring of the wrapped function will be extended by the deprecation
        message, if False (default) it will be replaced with the deprecation message.
    since (string): Version since when the function was deprecated, must be present for the docstring to get extended.

Returns:
    function: The wrapped function with the deprecation warnings in place.
"""

which is a valid napoleon docstring.

However, that high number you saw there got me curious, so I just went through the output of $ find . -name '*.py' -exec grep '^ ' {} \+ | less in ./src/ where it got me 382 lines (not 2071, in which folder did you execute that?) and fixed the files with hits that were indeed not either smart tabs at the start of the line or generated (src/octoprint/_version.py) in commit 2c0eed2.

@hellow554

This comment has been minimized.

Copy link
Author

commented Sep 11, 2015

Stupid me: in the root of octoprint of course :D something called versioneer.py has 1371 of the 2071 indentions. When i use the src/octoprint path, I will get 682, which is higher than your number though. Nevermind. Keep on the good work

@foosel

This comment has been minimized.

Copy link
Owner

commented Sep 11, 2015

Yeah, versioneer.py is a) pep8 code and b) what generates the src/octoprint/_version.py. You really tickled my curiousity now why you see 300 more hits, but I guess I should try to refrain from diving deeper now and get back to pounding the javascript code into shape ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.