# Path: mako/ext/babelplugin.py
# def extract(fileobj, keywords, comment_tags, options):
#     """Extract messages from Mako templates.
# 
#     :param fileobj: the file-like object the messages should be extracted from
#     :param keywords: a list of keywords (i.e. function names) that should be
#                      recognized as translation functions
#     :param comment_tags: a list of translator tags to search for and include
#                          in the results
#     :param options: a dictionary of additional options (optional)
#     :return: an iterator over ``(lineno, funcname, message, comments)`` tuples
#     :rtype: ``iterator``
#     """
#     extractor = BabelMakoExtractor(keywords, comment_tags, options)
#     yield from extractor(fileobj)
# 
# Path: mako/testing/assertions.py
# def eq_(a, b, msg=None):
#     """Assert a == b, with repr messaging on failure."""
#     assert a == b, msg or "%r != %r" % (a, b)
# 
# Path: mako/testing/config.py
# class Config(ReadsCfg):
# 
# Path: mako/testing/exclusions.py
# def _pygments_version():
# def requires_no_pygments_exceptions(fn):
#     def go(*arg, **kw):
# 
# Path: mako/testing/fixtures.py
# class TemplateTest:
#     def _file_template(self, filename, **kw):
#         filepath = self._file_path(filename)
#         return Template(
#             uri=filename,
#             filename=filepath,
#             module_directory=config.module_base,
#             **kw,
#         )
# 
#     def _file_path(self, filename):
#         name, ext = os.path.splitext(filename)
#         py3k_path = os.path.join(config.template_base, name + "_py3k" + ext)
#         if os.path.exists(py3k_path):
#             return py3k_path
# 
#         return os.path.join(config.template_base, filename)
# 
#     def _do_file_test(
#         self,
#         filename,
#         expected,
#         filters=None,
#         unicode_=True,
#         template_args=None,
#         **kw,
#     ):
#         t1 = self._file_template(filename, **kw)
#         self._do_test(
#             t1,
#             expected,
#             filters=filters,
#             unicode_=unicode_,
#             template_args=template_args,
#         )
# 
#     def _do_memory_test(
#         self,
#         source,
#         expected,
#         filters=None,
#         unicode_=True,
#         template_args=None,
#         **kw,
#     ):
#         t1 = Template(text=source, **kw)
#         self._do_test(
#             t1,
#             expected,
#             filters=filters,
#             unicode_=unicode_,
#             template_args=template_args,
#         )
# 
#     def _do_test(
#         self,
#         template,
#         expected,
#         filters=None,
#         template_args=None,
#         unicode_=True,
#     ):
#         if template_args is None:
#             template_args = {}
#         if unicode_:
#             output = template.render_unicode(**template_args)
#         else:
#             output = template.render(**template_args)
# 
#         if filters:
#             output = filters(output)
#         eq_(output, expected)


import io
import os
from mako.ext.babelplugin import extract
from mako.testing.assertions import eq_
from mako.testing.config import config
from mako.testing.exclusions import requires_babel
from mako.testing.fixtures import TemplateTest
                (44, "_", "Babel", []),
                (45, "ungettext", ("hella", "hellas", None), []),
                (62, "_", "The", ["TRANSLATOR: Ensure so and", "so, thanks"]),
                (62, "ungettext", ("bunny", "bunnies", None), []),
                (68, "_", "Goodbye, really!", ["TRANSLATOR: HTML comment"]),
                (71, "_", "P.S. byebye", []),
                (77, "_", "Top", []),
                (83, "_", "foo", []),
                (83, "_", "hoho", []),
                (85, "_", "bar", []),
                (92, "_", "Inside a p tag", ["TRANSLATOR: <p> tag is ok?"]),
                (95, "_", "Later in a p tag", ["TRANSLATOR: also this"]),
                (99, "_", "No action at a distance.", []),
            ]
        eq_(expected, messages)

    def test_extract_utf8(self):
        with open(
            os.path.join(config.template_base, "gettext_utf8.mako"), "rb"
        ) as mako_tmpl:
            message = next(
                extract(mako_tmpl, {"_", None}, [], {"encoding": "utf-8"})
            )
            assert message == (1, "_", "K\xf6ln", [])

    def test_extract_cp1251(self):
        with open(
            os.path.join(config.template_base, "gettext_cp1251.mako"), "rb"
        ) as mako_tmpl:
            message = next(

# Path: mako/ext/babelplugin.py
# def extract(fileobj, keywords, comment_tags, options):
#     """Extract messages from Mako templates.
# 
#     :param fileobj: the file-like object the messages should be extracted from
#     :param keywords: a list of keywords (i.e. function names) that should be
#                      recognized as translation functions
#     :param comment_tags: a list of translator tags to search for and include
#                          in the results
#     :param options: a dictionary of additional options (optional)
#     :return: an iterator over ``(lineno, funcname, message, comments)`` tuples
#     :rtype: ``iterator``
#     """
#     extractor = BabelMakoExtractor(keywords, comment_tags, options)
#     yield from extractor(fileobj)
# 
# Path: mako/testing/assertions.py
# def eq_(a, b, msg=None):
#     """Assert a == b, with repr messaging on failure."""
#     assert a == b, msg or "%r != %r" % (a, b)
# 
# Path: mako/testing/config.py
# class Config(ReadsCfg):
# 
# Path: mako/testing/exclusions.py
# def _pygments_version():
# def requires_no_pygments_exceptions(fn):
#     def go(*arg, **kw):
# 
# Path: mako/testing/fixtures.py
# class TemplateTest:
#     def _file_template(self, filename, **kw):
#         filepath = self._file_path(filename)
#         return Template(
#             uri=filename,
#             filename=filepath,
#             module_directory=config.module_base,
#             **kw,
#         )
# 
#     def _file_path(self, filename):
#         name, ext = os.path.splitext(filename)
#         py3k_path = os.path.join(config.template_base, name + "_py3k" + ext)
#         if os.path.exists(py3k_path):
#             return py3k_path
# 
#         return os.path.join(config.template_base, filename)
# 
#     def _do_file_test(
#         self,
#         filename,
#         expected,
#         filters=None,
#         unicode_=True,
#         template_args=None,
#         **kw,
#     ):
#         t1 = self._file_template(filename, **kw)
#         self._do_test(
#             t1,
#             expected,
#             filters=filters,
#             unicode_=unicode_,
#             template_args=template_args,
#         )
# 
#     def _do_memory_test(
#         self,
#         source,
#         expected,
#         filters=None,
#         unicode_=True,
#         template_args=None,
#         **kw,
#     ):
#         t1 = Template(text=source, **kw)
#         self._do_test(
#             t1,
#             expected,
#             filters=filters,
#             unicode_=unicode_,
#             template_args=template_args,
#         )
# 
#     def _do_test(
#         self,
#         template,
#         expected,
#         filters=None,
#         template_args=None,
#         unicode_=True,
#     ):
#         if template_args is None:
#             template_args = {}
#         if unicode_:
#             output = template.render_unicode(**template_args)
#         else:
#             output = template.render(**template_args)
# 
#         if filters:
#             output = filters(output)
#         eq_(output, expected)


# Path: test/ext/test_babelplugin.py
import io
import os
from mako.ext.babelplugin import extract
from mako.testing.assertions import eq_
from mako.testing.config import config
from mako.testing.exclusions import requires_babel
from mako.testing.fixtures import TemplateTest

                (44, "_", "Babel", []),
                (45, "ungettext", ("hella", "hellas", None), []),
                (62, "_", "The", ["TRANSLATOR: Ensure so and", "so, thanks"]),
                (62, "ungettext", ("bunny", "bunnies", None), []),
                (68, "_", "Goodbye, really!", ["TRANSLATOR: HTML comment"]),
                (71, "_", "P.S. byebye", []),
                (77, "_", "Top", []),
                (83, "_", "foo", []),
                (83, "_", "hoho", []),
                (85, "_", "bar", []),
                (92, "_", "Inside a p tag", ["TRANSLATOR: <p> tag is ok?"]),
                (95, "_", "Later in a p tag", ["TRANSLATOR: also this"]),
                (99, "_", "No action at a distance.", []),
            ]
        eq_(expected, messages)

    def test_extract_utf8(self):
        with open(
            os.path.join(config.template_base, "gettext_utf8.mako"), "rb"
        ) as mako_tmpl:
            message = next(
                extract(mako_tmpl, {"_", None}, [], {"encoding": "utf-8"})
            )
            assert message == (1, "_", "K\xf6ln", [])

    def test_extract_cp1251(self):
        with open(
            os.path.join(config.template_base, "gettext_cp1251.mako"), "rb"
        ) as mako_tmpl:
            message = next(

                extract(mako_tmpl, {"_", None}, [], {"encoding": "cp1251"})