# Path: lamvery/utils.py
# def previous_alias(alias):
#     return '{}-pre'.format(alias)
# 
# def parse_env_args(env):
#     if not isinstance(env, list):
#         return None
# 
#     ret = {}
#     for e in env:
#         matches = ENV_PATTERN.match(e)
# 
#         if matches is None:
#             raise Exception(
#                 'The format of "env" option must be "NAME=VALUE": {}'.format(e))
# 
#         name = matches.group('name')
#         value = matches.group('value')
#         k, v = shlex.split('{} {}'.format(name, value))
#         ret[k] = v
# 
#     return ret
# 
# def confirm_overwrite(path):
#     ret = True
#     if os.path.exists(path):
#         print('Overwrite {}? [y/n]: '.format(path))
#         y_n = sys.stdin.readline()
#         if not y_n.startswith('y'):
#             ret = False
#     return ret


from unittest import TestCase
from nose.tools import eq_, raises
from mock import Mock, patch
from lamvery.utils import (
    previous_alias,
    parse_env_args,
    confirm_overwrite
)
# -*- coding: utf-8 -*-




class UtilsActionTestCase(TestCase):

    def test_previous_alias(self):
        eq_(previous_alias('foo'), 'foo-pre')

    def test_parse_env_args(self):
        eq_(parse_env_args('foo'), None)

# Path: lamvery/utils.py
# def previous_alias(alias):
#     return '{}-pre'.format(alias)
# 
# def parse_env_args(env):
#     if not isinstance(env, list):
#         return None
# 
#     ret = {}
#     for e in env:
#         matches = ENV_PATTERN.match(e)
# 
#         if matches is None:
#             raise Exception(
#                 'The format of "env" option must be "NAME=VALUE": {}'.format(e))
# 
#         name = matches.group('name')
#         value = matches.group('value')
#         k, v = shlex.split('{} {}'.format(name, value))
#         ret[k] = v
# 
#     return ret
# 
# def confirm_overwrite(path):
#     ret = True
#     if os.path.exists(path):
#         print('Overwrite {}? [y/n]: '.format(path))
#         y_n = sys.stdin.readline()
#         if not y_n.startswith('y'):
#             ret = False
#     return ret


# Path: tests/lamvery/utils_test.py
from unittest import TestCase
from nose.tools import eq_, raises
from mock import Mock, patch
from lamvery.utils import (
    previous_alias,
    parse_env_args,
    confirm_overwrite
)

# -*- coding: utf-8 -*-




class UtilsActionTestCase(TestCase):

    def test_previous_alias(self):
        eq_(previous_alias('foo'), 'foo-pre')

    def test_parse_env_args(self):
        eq_(parse_env_args('foo'), None)

        eq_(parse_env_args(['foo=bar']), {'foo': 'bar'})