# Path: handson/myyaml.py
# def stanza(k, new_val=None):
#     global _cache
#     load()
#     if new_val is not None:
#         assert k in tree_stanzas.keys(), (
#             "YAML stanza {!r} not permitted".format(k)
#         )
#         _cache[k] = new_val
#         write()
#     stanza_is_sane(k)
#     return _cache[k]


import boto.ec2
import boto.vpc
import logging
from handson.myyaml import stanza
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

# from handson.util import read_user_data

log = logging.getLogger(__name__)


class Region(object):

    def __init__(self, args):
        self.args = args
        self._region = {
            'ec2_conn': None,
            'region_str': None,
            'vpc_conn': None,
            'az': None
        }

    def region(self):
        """
            gets region from yaml, default to eu-west-1
        """
        if self._region['region_str']:
            return self._region['region_str']

# Path: handson/myyaml.py
# def stanza(k, new_val=None):
#     global _cache
#     load()
#     if new_val is not None:
#         assert k in tree_stanzas.keys(), (
#             "YAML stanza {!r} not permitted".format(k)
#         )
#         _cache[k] = new_val
#         write()
#     stanza_is_sane(k)
#     return _cache[k]


# Path: handson/region.py
import boto.ec2
import boto.vpc
import logging
from handson.myyaml import stanza

# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

# from handson.util import read_user_data

log = logging.getLogger(__name__)


class Region(object):

    def __init__(self, args):
        self.args = args
        self._region = {
            'ec2_conn': None,
            'region_str': None,
            'vpc_conn': None,
            'az': None
        }

    def region(self):
        """
            gets region from yaml, default to eu-west-1
        """
        if self._region['region_str']:
            return self._region['region_str']

        self._region['region_str'] = stanza('region')['region_str']