jdiegodcp / ramlfications

Python parser for RAML
https://ramlfications.readthedocs.org
Apache License 2.0
234 stars 50 forks source link

Find resource by method and path #112

Open johnlinp opened 7 years ago

johnlinp commented 7 years ago

When I want to find resource by method and path, I use this function:

def get_resource(resources, method, path):
    for resource in resources:
        if resource.method is None or resource.path is None:
            continue
        if resource.method.lower() == method.lower() and resource.path == path:
            return resource
    return None

Is there any built-in function in ramlfications to achieve that?

econchick commented 7 years ago

hey @johnlinp! Unfortunately, not; your filter method seems like the best approach at the moment. I'll keep this issue open to consider putting a feature in for a 0.2.x release.