# Path: liam2/compat.py
# PY2 = sys.version_info[0] == 2
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def csv_open(filename, mode='r'):
#     class metaclass(meta):


import errno
import fnmatch
import os
import re
import stat
import subprocess
import sys
import urllib
import zipfile
from datetime import date
from os import chdir, makedirs
from os.path import exists, abspath, dirname
from shutil import copytree, copy2, rmtree as _rmtree
from subprocess import check_output, STDOUT, CalledProcessError
from liam2.compat import input
    :param url: url of the remote repository
    :param branch: an optional branch (defaults to 'refs/heads/master')
    :return: name/hash of the last revision
    """
    if branch is None:
        branch = 'refs/heads/master'
    output = call('git ls-remote %s %s' % (url, branch))
    for line in output.splitlines():
        if line.endswith(branch):
            return line.split()[0]
    raise Exception("Could not determine revision number")


def branchname(statusline):
    """
    computes the branch name from a "git status -b -s" line
    ## master...origin/master
    """
    statusline = statusline.replace('#', '').strip()
    pos = statusline.find('...')
    return statusline[:pos] if pos != -1 else statusline


def yes(msg, default='y'):
    choices = ' (%s/%s) ' % tuple(c.capitalize() if c == default else c
                                  for c in ('y', 'n'))
    answer = None
    while answer not in ('', 'y', 'n'):
        if answer is not None:
            print("answer should be 'y', 'n', or <return>")

# Path: liam2/compat.py
# PY2 = sys.version_info[0] == 2
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def csv_open(filename, mode='r'):
#     class metaclass(meta):


# Path: make_release.py
import errno
import fnmatch
import os
import re
import stat
import subprocess
import sys
import urllib
import zipfile
from datetime import date
from os import chdir, makedirs
from os.path import exists, abspath, dirname
from shutil import copytree, copy2, rmtree as _rmtree
from subprocess import check_output, STDOUT, CalledProcessError
from liam2.compat import input

    :param url: url of the remote repository
    :param branch: an optional branch (defaults to 'refs/heads/master')
    :return: name/hash of the last revision
    """
    if branch is None:
        branch = 'refs/heads/master'
    output = call('git ls-remote %s %s' % (url, branch))
    for line in output.splitlines():
        if line.endswith(branch):
            return line.split()[0]
    raise Exception("Could not determine revision number")


def branchname(statusline):
    """
    computes the branch name from a "git status -b -s" line
    ## master...origin/master
    """
    statusline = statusline.replace('#', '').strip()
    pos = statusline.find('...')
    return statusline[:pos] if pos != -1 else statusline


def yes(msg, default='y'):
    choices = ' (%s/%s) ' % tuple(c.capitalize() if c == default else c
                                  for c in ('y', 'n'))
    answer = None
    while answer not in ('', 'y', 'n'):
        if answer is not None:
            print("answer should be 'y', 'n', or <return>")

        answer = input(msg + choices).lower()