question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@with_category discarded

See original GitHub issue

I don’t know if it’s a cmd2 problem or with my code.

There are some member functions for which I have:

    @is_loaded
    @with_category("mptcp")
    def do_list_mptcp_connections(self, *args):
         print("john doe")

with

def is_loaded(f):
    """
    Decorator checking that dataset has correct columns
    """
    def wrapped(self, *args):
        if self.data is not None:
            return f(self, *args)
        else:
            raise mp.MpTcpException("Please load a pcap with `load_pcap` first")
        return None
    return wrapped

These functions don’t appear in the “mptcp” category. If I remove the is_loaded decorator, they do appear. I tried swapping the order of decorators but either way the function is not listed.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tleonhardtcommented, Sep 28, 2018

@anselor Actually It looks like we accidentally forgot to use @functools.wraps in the with_category decorator as well. We will need to fix that.

1reaction
anselorcommented, Sep 28, 2018

When you decorate a function you are replacing a function with a wrapper function that adds additional behavior before/after calling your function. Because of this, the function that is actually in the object is no longer the original function. It won’t have the original function’s name or attributes.

To get around the problem functools.wraps copies this information so that the original function’s metadata gets presented.

Try adding: @functools.wraps(f) def wrapped(....

Read more comments on GitHub >

github_iconTop Results From Across the Web

Waste Stream Disposal –Quick Sheet - UConn Health
medications, including sugars, salts, and electrolytes, these can be discarded down the sink. (Unused empty bags may be disposed in regular trash).
Read more >
Planning Guidance for Handling Category A Solid Waste
DOT is committed to ensuring that information is available in appropriate alternative formats to meet the requirements of persons who have a ...
Read more >
CATEGORIES OF BIO-MEDICAL WASTE
Black: Discarded Medicines, Cytotoxic Drugs are to be stored at black dustbins. Never throw any Non-Infectious wastes in the bins meant for Bio...
Read more >
Hazardous Materials & Waste Management | Safety Security EM
The following are the various categories of waste that the hospital generates: Biohazardous Waste; Pathological Waste; Sharps; Pharmaceutical Waste ...
Read more >
Defining Hazardous Waste: Listed, Characteristic and Mixed ...
Listed wastes are wastes from common manufacturing and industrial processes, specific industries and can be generated from discarded ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found