Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
c0fec0de committed Nov 25, 2017
1 parent f1130dc commit 1228208
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions anytree/importer/jsonimporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ def __init__(self, dictimporter=None, **kwargs):
self.dictimporter = dictimporter
self.kwargs = kwargs

def import_(self, data):
"""Read JSON from `data`."""
def __import(self, data):
dictimporter = self.dictimporter or DictImporter()
data = json.loads(data, **self.kwargs)
return dictimporter.import_(data)

def import_(self, data):
"""Read JSON from `data`."""
return self.__import(json.loads(data, **self.kwargs))

def read(self, filehandle):
"""Read JSON from `filehandle`."""
dictimporter = self.dictimporter or DictImporter()
data = json.load(filehandle, **self.kwargs)
return dictimporter.import_(data)
return self.__import(json.load(filehandle, **self.kwargs))

0 comments on commit 1228208

Please sign in to comment.