Skip to content

Commit

Permalink
read_template method for Template:
Browse files Browse the repository at this point in the history
  • Loading branch information
lee212 committed Oct 27, 2016
1 parent c5aed8d commit a77a56e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions simpleazure/template/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import json
import datadiff
from datadiff.tools import assert_equal
from urlparse import urlparse
import urllib

class Templates(OrderedDict):
_list = None
Expand Down Expand Up @@ -262,6 +264,15 @@ def diff(self, b):
if not equal:
print datadiff.diff(dict(self), dict(b))

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 = json.loads(temp.read())
self.update(template)

class Deploy(object):
"""Constructs a :class:`Deploy <Deploy>`.
Returns :class:`Deploy <Deploy>` instance.
Expand Down

0 comments on commit a77a56e

Please sign in to comment.