Skip to content

for console redirection from mako-render with python2 #271

Description

@sqlalchemy-bot

Migrated issue, originally created by Patate Tomate (@patatetom)

input can be changed with ## -- coding: utf-8 -- :-)
but nothing for changing output :-(

         "template is read from stdin, the value defaults to be "
         "the current directory, otherwise it defaults to be the "
         "parent directory of the file provided.")
+    parser.add_argument(
+        "--output-encoding", default=None,
+        help="force output encoding")
     parser.add_argument('input', nargs='?', default='-')
 
     options = parser.parse_args(argv)
+
+    output_encoding = options.output_encoding
+
     if options.input == '-':
         lookup_dirs = options.template_dir or ["."]
         lookup = TemplateLookup(lookup_dirs)
         try:
-            template = Template(sys.stdin.read(), lookup=lookup)
+            template = Template(sys.stdin.read(), lookup=lookup, output_encoding=output_encoding)
         except:
             _exit()
     else:
@@ -52,7 +58,7 @@ def cmdline(argv=None):
         lookup_dirs = options.template_dir or [dirname(filename)]
         lookup = TemplateLookup(lookup_dirs)
         try:
-            template = Template(filename=filename, lookup=lookup)
+            template = Template(filename=filename, lookup=lookup, output_encoding=output_encoding)
         except:
             _exit()

Activity

  1. sqlalchemy-bot commented on Nov 15, 2017

    @sqlalchemy-bot
    Author

    Michael Bayer (@zzzeek) wrote:

    ill have to merge your patch by hand since you deleted your fork in the PR

  2. sqlalchemy-bot commented on Nov 15, 2017

    @sqlalchemy-bot
    Author

    Michael Bayer (@zzzeek) wrote:

    or if you can just redo your PR that would help thanks!

  3. sqlalchemy-bot commented on Nov 15, 2017

    @sqlalchemy-bot
    Author

    Michael Bayer (@zzzeek) wrote:

    Add --output-encoding to mako-render

    Fixes: #271
    Change-Id: I88b46cfbdea9eda0b4c478dd97829bee8431ff58

    → c480854

  4. sqlalchemy-bot commented on Nov 15, 2017

    @sqlalchemy-bot
    Author

    Changes by Michael Bayer (@zzzeek):

    • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions