# Path: fabfile/constants.py
# VER_FILE = os.path.join(LIB_DIR, 'climenu.py')
# 
# DOCS_CONF_FILE = os.path.join(LIB_DIR, 'docs', 'conf.py')
# 
# Path: fabfile/helpers.py
# def true(value):
#     '''Since fabric task inputs are always text, we need a way to convert it
#     to a boolean.
#     '''
#     if isinstance(value, bool):
#         return value
#     elif isinstance(value, basestring):
#         return value.lower()[0] in ['y', 't', '1']
# 
#     # Use the default representation
#     return bool(value)


import re
from fabric.api import task
from .constants import VER_FILE, DOCS_CONF_FILE
from .helpers import true
        raise Exception("Could not get version")

    return match.group('version')


@task
def rev():
    """Increases the 'minor' version number by 1"""
    text = open(VER_FILE).read()
    whole, ver = re.search("^(__version__\s+=\s+['\"](.*?)['\"]\s*)$", text, re.MULTILINE).groups()
    major, minor, patch = ver.split('.', 2)
    new_minor = str(int(minor) + 1)

    # NOTE: When reving minor, it's customary to set patch to "0"
    new_ver = ".".join([major, new_minor, "0"])

    print("Old version number is [%s]" % ver)
    print("New version number is [%s]" % new_ver)
    val = raw_input("OK [Yn]? ")
    while not true(val):
        new_ver = raw_input("Enter new version: ")
        print("Using new version [%s]" % new_ver)
        val = raw_input("OK [Yn]? ")

    text = text.replace(ver, new_ver)
    with open(VER_FILE, "wb") as fh:
        fh.write(text)

    text = open(DOCS_CONF_FILE).read()
    text = re.sub("(version|release) = u'.*?'", r"\1 = u'%s'" % new_ver, text)

# Path: fabfile/constants.py
# VER_FILE = os.path.join(LIB_DIR, 'climenu.py')
# 
# DOCS_CONF_FILE = os.path.join(LIB_DIR, 'docs', 'conf.py')
# 
# Path: fabfile/helpers.py
# def true(value):
#     '''Since fabric task inputs are always text, we need a way to convert it
#     to a boolean.
#     '''
#     if isinstance(value, bool):
#         return value
#     elif isinstance(value, basestring):
#         return value.lower()[0] in ['y', 't', '1']
# 
#     # Use the default representation
#     return bool(value)


# Path: fabfile/ver.py
import re
from fabric.api import task
from .constants import VER_FILE, DOCS_CONF_FILE
from .helpers import true

        raise Exception("Could not get version")

    return match.group('version')


@task
def rev():
    """Increases the 'minor' version number by 1"""
    text = open(VER_FILE).read()
    whole, ver = re.search("^(__version__\s+=\s+['\"](.*?)['\"]\s*)$", text, re.MULTILINE).groups()
    major, minor, patch = ver.split('.', 2)
    new_minor = str(int(minor) + 1)

    # NOTE: When reving minor, it's customary to set patch to "0"
    new_ver = ".".join([major, new_minor, "0"])

    print("Old version number is [%s]" % ver)
    print("New version number is [%s]" % new_ver)
    val = raw_input("OK [Yn]? ")
    while not true(val):
        new_ver = raw_input("Enter new version: ")
        print("Using new version [%s]" % new_ver)
        val = raw_input("OK [Yn]? ")

    text = text.replace(ver, new_ver)
    with open(VER_FILE, "wb") as fh:
        fh.write(text)

    text = open(DOCS_CONF_FILE).read()
    text = re.sub("(version|release) = u'.*?'", r"\1 = u'%s'" % new_ver, text)

    with open(DOCS_CONF_FILE, 'wb') as fh: