Skip to content

Commit

Permalink
make write_json just use write_file(...json.dumps())
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Beck committed Aug 8, 2018
1 parent 7c8260c commit 2a8929c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
4 changes: 1 addition & 3 deletions dbt/clients/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ def write_file(path, contents=''):


def write_json(path, data):
make_directory(os.path.dirname(path))
dbt.compat.write_json(path, data, cls=dbt.utils.JSONEncoder)
return True
return write_file(path, json.dumps(data, cls=dbt.utils.JSONEncoder))


def _windows_rmdir_readonly(func, path, exc):
Expand Down
18 changes: 5 additions & 13 deletions dbt/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,10 @@ def to_string(s):
return str(s)


def _open(path, mode):
def write_file(path, s):
if WHICH_PYTHON == 2:
return codecs.open(path, mode, encoding='utf-8')
with codecs.open(path, 'w', encoding='utf-8') as f:
return f.write(to_string(s))
else:
return open(path, 'w')


def write_file(path, s):
with _open(path, 'w') as fp:
return fp.write(to_string(s))


def write_json(path, data, **kwargs):
with _open(path, 'w') as fp:
json.dump(data, fp, **kwargs)
with open(path, 'w') as f:
return f.write(to_string(s))

0 comments on commit 2a8929c

Please sign in to comment.