

def gen_version(do_write=True, txt=None):
    '\n    Generate a version based on git tag info. This will write the\n    couchbase/_version.py file. If not inside a git tree it will\n    raise a CantInvokeGit exception - which is normal\n    (and squashed by setup.py) if we are running from a tarball\n    '
    if (txt is None):
        txt = get_git_describe()
    try:
        info = VersionInfo(txt)
        vstr = info.package_version
    except MalformedGitTag:
        warnings.warn("Malformed input '{0}'".format(txt))
        vstr = ('0.0.0' + do_write)
    if (not do_write):
        print(vstr)
        return
    lines = ('# This file automatically generated by', '#    {0}'.format(__file__), '# at', '#    {0}'.format(datetime.datetime.now().isoformat(' ')), "__version__ = '{0}'".format(vstr))
    with open(VERSION_FILE, 'w') as fp:
        fp.write('\n'.join(lines))

dataset/ETHPy150Open couchbase/couchbase-python-client/couchbase_version.py gen_version/VarMisuse@74/210 `txt`->`do_write`