<commit_before>
import jinja2

from wadl2html.nodes.base import BaseNode
from wadl2html.templates import templates


class MethodNode(BaseNode):
    template = templates['method']
    doc_names = ["wadl:doc", "doc"]
    para_names = ["para", "p", "db:para", "xhtml:p"]


    def to_html(self):
        # this was a link that could not be resolved, so don't show anything
        if "href" in self.attributes:
            return ""

        template = jinja2.Template(self.template)
        return template.render(**self.get_template_arguments())

    def get_template_arguments(self):
        """ Get the arguments for the jinja2 template.  Since the wadls vary so
        widly, this is written to be super defensive. """

        resource = None
        params = None
        docs = None
        short_desc = None

        try:
            resource = self.find_first("resource")
            params = resource.find_first("params")
            docs = self.find_one_of(self.doc_names)
            short_desc = docs.find_one_of(self.para_names)
        except Exception, e:
            # we handle failures here below
            pass

        # defaults for the output
        output = {
            "method_name": "",
            "full_path": "",
            "title": "",
            "docs_html": "",
            "params_html": "",
            "child_html": ""
        }

        if docs is not None:
            output["docs_html"] = docs.to_html()

            if "title" in docs.attributes:
                output["title"] = docs.attributes['title']

        if short_desc is not None:
            output["desc_html"] =  short_desc.to_html()

        if "name" in self.attributes:
            output["method_name"] = self.attributes['name']

        if (resource is not None) and ("full_path" in resource.attributes):
            output["full_path"] = resource.attributes['full_path']

        for child in self.children:
            # skip these, we're placing them manually
            if child in [docs, resource, params]:
                continue

            output['child_html'] += child.to_html()

        return output<commit_msg>cleaned up some flake8 issues<commit_after>
import jinja2

from wadl2html.nodes.base import BaseNode
from wadl2html.templates import templates


class MethodNode(BaseNode):
    template = templates['method']
    doc_names = ["wadl:doc", "doc"]
    para_names = ["para", "p", "db:para", "xhtml:p"]

    def to_html(self):
        # this was a link that could not be resolved, so don't show anything
        if "href" in self.attributes:
            return ""

        template = jinja2.Template(self.template)
        return template.render(**self.get_template_arguments())

    def get_template_arguments(self):
        """ Get the arguments for the jinja2 template.  Since the wadls vary so
        widly, this is written to be super defensive. """

        resource = None
        params = None
        docs = None
        short_desc = None

        try:
            resource = self.find_first("resource")
            params = resource.find_first("params")
            docs = self.find_one_of(self.doc_names)
            short_desc = docs.find_one_of(self.para_names)
        except Exception:
            # we handle failures here below
            pass

        # defaults for the output
        output = {
            "method_name": "",
            "full_path": "",
            "title": "",
            "docs_html": "",
            "params_html": "",
            "child_html": ""
        }

        if docs is not None:
            output["docs_html"] = docs.to_html()

            if "title" in docs.attributes:
                output["title"] = docs.attributes['title']

        if short_desc is not None:
            output["desc_html"] = short_desc.to_html()

        if "name" in self.attributes:
            output["method_name"] = self.attributes['name']

        if (resource is not None) and ("full_path" in resource.attributes):
            output["full_path"] = resource.attributes['full_path']

        for child in self.children:
            # skip these, we're placing them manually
            if child in [docs, resource, params]:
                continue

            output['child_html'] += child.to_html()

        return output
{'fraction_non_alphanumeric': 0.10598648963428837, 'fraction_numerical': 0.002562310738411367, 'mean_word_length': 1.9986033519553073, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2456361', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1144, 'n_words': 330}