Skip to content
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
Closed

for console redirection from mako-render with python2 #271

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

Comments

@sqlalchemy-bot
Copy link

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
Copy link
Author

Michael Bayer (@zzzeek) wrote:

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

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

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

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

Add --output-encoding to mako-render

Fixes: #271
Change-Id: I88b46cfbdea9eda0b4c478dd97829bee8431ff58

c480854

@sqlalchemy-bot
Copy link
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
Projects
None yet
Development

No branches or pull requests

1 participant