Mercurial > gnulib
changeset 39063:b70f2027b9cf
generator: __enter__ and __exit__ methods
author | Dmitry Selyutin <ghostmansd@gmail.com> |
---|---|
date | Sun, 22 Oct 2017 23:55:25 +0300 |
parents | 6f57acb28286 |
children | 01a1f2665a4e |
files | pygnulib/generator.py |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pygnulib/generator.py Sun Oct 22 23:49:00 2017 +0300 +++ b/pygnulib/generator.py Sun Oct 22 23:55:25 2017 +0300 @@ -39,14 +39,25 @@ "# Generated by gnulib-tool.", ) + def __repr__(self): module = self.__class__.__module__ name = self.__class__.__name__ return "{0}.{1}".format(module, name) + def __str__(self): return "\n".join([_ for _ in self]) + + def __enter__(self): + return self + + + def __exit__(self, exctype, excval, exctrace): + pass + + def __iter__(self): for line in Generator._TEMPLATE: yield line @@ -96,6 +107,8 @@ "# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.", "USE_MSGCTXT = no" ) + + def __init__(self, config): _type_assert("config", config, _BaseConfig) super().__init__() @@ -319,6 +332,7 @@ " gl_COMMON", ) + def __init__(self, config, macro_prefix=None): """ config: gnulib configuration