]> Savannah Git Hosting - gnulib.git/commitdiff
generator: __enter__ and __exit__ methods
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 22 Oct 2017 20:55:25 +0000 (23:55 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 22 Oct 2017 20:55:25 +0000 (23:55 +0300)
pygnulib/generator.py

index eb8fc9bd8d47f5fd418528352dd5721eb4c6b52f..9274eae561439c175355fb15191b78d126fbd383 100644 (file)
@@ -39,14 +39,25 @@ class Generator:
         "# 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 @@ class POMakefile(Generator):
         "# 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 @@ class InitMacroHeader(InitMacro):
         "  gl_COMMON",
     )
 
+
     def __init__(self, config, macro_prefix=None):
         """
         config: gnulib configuration