New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for console redirection from mako-render with python2 #271

Closed
sqlalchemy-bot opened this Issue Nov 15, 2017 · 4 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Nov 15, 2017

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()
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 15, 2017

Michael Bayer (@zzzeek) wrote:

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

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 15, 2017

Michael Bayer (@zzzeek) wrote:

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

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 15, 2017

Michael Bayer (@zzzeek) wrote:

Add --output-encoding to mako-render

Fixes: #271
Change-Id: I88b46cfbdea9eda0b4c478dd97829bee8431ff58

c480854

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 15, 2017

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