Skip to content

Commit

Permalink
loading template
Browse files Browse the repository at this point in the history
  • Loading branch information
lee212 committed Oct 26, 2016
1 parent 3993d64 commit c5aed8d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions simpleazure/template/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import urllib
from urlparse import urlparse
from pprint import pprint
from .template import Template

class Reader(object):
"""Constructs a :class:`Reader <Reader>`.
Expand All @@ -25,20 +26,20 @@ class Reader(object):
"""

default_dir = os.path.dirname(os.path.realpath(__file__)) + "/defaults/"
template = {}
template = Template()

def __init__(self, path_or_uri=None):
if path_or_uri:
self.template = self.read_template(path_or_uri)
self.read_template(path_or_uri)

def read_template(self, path_or_uri):

if urlparse(path_or_uri).scheme is not "":
template = json.loads(urllib.urlopen(path_or_uri).read())
else:
with open(path_or_uri, "r") as temp:
template = temp.read()
self.template = template
template = json.loads(temp.read())
self.template = Template(template)

def get_defaults(self):
return self.read_defaults()
Expand Down

0 comments on commit c5aed8d

Please sign in to comment.