Skip to content

Commit

Permalink
revert cli.py
Browse files Browse the repository at this point in the history
just change context.py
  • Loading branch information
Dayan123 committed Sep 4, 2016
1 parent ffdde22 commit 5be1003
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions j2cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os, sys, codecs
import os, sys
import argparse

import jinja2
Expand Down Expand Up @@ -98,7 +98,7 @@ def render_command(cwd, environ, stdin, argv):
if args.data == '-' and args.format == 'env':
input_data_f = None
else:
input_data_f = stdin if args.data == '-' else codecs.open(args.data, encoding='utf-8')
input_data_f = stdin if args.data == '-' else open(args.data)

# Read data
context = read_context_data(
Expand Down
10 changes: 9 additions & 1 deletion j2cli/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,16 @@ def _parse_env(data_string):
one.strip()
for one in line.split('=',1)
]
for line in data_string.split("\n"))
for line in data_string.split("\n")
)
)
data=dict(data)
for k,v in data.items():
try:
data[k] = v.decode('utf-8')
except:
pass

else:
data = data_string
if isinstance(data, os._Environ):
Expand Down

0 comments on commit 5be1003

Please sign in to comment.