File size: 151,728 Bytes
c7f4bd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"get_root","parameters":"()","argument_list":"","return_statement":"return root","docstring":"Get the project root directory.\n\n    We require that all commands are run from the project root, i.e. the\n    directory that contains setup.py, setup.cfg, and versioneer.py .","docstring_summary":"Get the project root directory.","docstring_tokens":["Get","the","project","root","directory","."],"function":"def get_root():\n    \"\"\"Get the project root directory.\n\n    We require that all commands are run from the project root, i.e. the\n    directory that contains setup.py, setup.cfg, and versioneer.py .\n    \"\"\"\n    root = os.path.realpath(os.path.abspath(os.getcwd()))\n    setup_py = os.path.join(root, \"setup.py\")\n    versioneer_py = os.path.join(root, \"versioneer.py\")\n    if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):\n        # allow 'python path\/to\/setup.py COMMAND'\n        root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0])))\n        setup_py = os.path.join(root, \"setup.py\")\n        versioneer_py = os.path.join(root, \"versioneer.py\")\n    if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):\n        err = (\"Versioneer was unable to run the project root directory. \"\n               \"Versioneer requires setup.py to be executed from \"\n               \"its immediate directory (like 'python setup.py COMMAND'), \"\n               \"or in a way that lets it use sys.argv[0] to find the root \"\n               \"(like 'python path\/to\/setup.py COMMAND').\")\n        raise VersioneerBadRootError(err)\n    try:\n        # Certain runtime workflows (setup.py install\/develop in a setuptools\n        # tree) execute all dependencies in a single python process, so\n        # \"versioneer\" may be imported multiple times, and python's shared\n        # module-import table will cache the first one. So we can't use\n        # os.path.dirname(__file__), as that will find whichever\n        # versioneer.py was first imported, even in later projects.\n        me = os.path.realpath(os.path.abspath(__file__))\n        me_dir = os.path.normcase(os.path.splitext(me)[0])\n        vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0])\n        if me_dir != vsr_dir:\n            print(\"Warning: build in %s is using versioneer.py from %s\"\n                  % (os.path.dirname(me), versioneer_py))\n    except NameError:\n        pass\n    return root","function_tokens":["def","get_root","(",")",":","root","=","os",".","path",".","realpath","(","os",".","path",".","abspath","(","os",".","getcwd","(",")",")",")","setup_py","=","os",".","path",".","join","(","root",",","\"setup.py\"",")","versioneer_py","=","os",".","path",".","join","(","root",",","\"versioneer.py\"",")","if","not","(","os",".","path",".","exists","(","setup_py",")","or","os",".","path",".","exists","(","versioneer_py",")",")",":","# allow 'python path\/to\/setup.py COMMAND'","root","=","os",".","path",".","dirname","(","os",".","path",".","realpath","(","os",".","path",".","abspath","(","sys",".","argv","[","0","]",")",")",")","setup_py","=","os",".","path",".","join","(","root",",","\"setup.py\"",")","versioneer_py","=","os",".","path",".","join","(","root",",","\"versioneer.py\"",")","if","not","(","os",".","path",".","exists","(","setup_py",")","or","os",".","path",".","exists","(","versioneer_py",")",")",":","err","=","(","\"Versioneer was unable to run the project root directory. \"","\"Versioneer requires setup.py to be executed from \"","\"its immediate directory (like 'python setup.py COMMAND'), \"","\"or in a way that lets it use sys.argv[0] to find the root \"","\"(like 'python path\/to\/setup.py COMMAND').\"",")","raise","VersioneerBadRootError","(","err",")","try",":","# Certain runtime workflows (setup.py install\/develop in a setuptools","# tree) execute all dependencies in a single python process, so","# \"versioneer\" may be imported multiple times, and python's shared","# module-import table will cache the first one. So we can't use","# os.path.dirname(__file__), as that will find whichever","# versioneer.py was first imported, even in later projects.","me","=","os",".","path",".","realpath","(","os",".","path",".","abspath","(","__file__",")",")","me_dir","=","os",".","path",".","normcase","(","os",".","path",".","splitext","(","me",")","[","0","]",")","vsr_dir","=","os",".","path",".","normcase","(","os",".","path",".","splitext","(","versioneer_py",")","[","0","]",")","if","me_dir","!=","vsr_dir",":","print","(","\"Warning: build in %s is using versioneer.py from %s\"","%","(","os",".","path",".","dirname","(","me",")",",","versioneer_py",")",")","except","NameError",":","pass","return","root"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L296-L332"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"get_config_from_root","parameters":"(root)","argument_list":"","return_statement":"return cfg","docstring":"Read the project setup.cfg file to determine Versioneer config.","docstring_summary":"Read the project setup.cfg file to determine Versioneer config.","docstring_tokens":["Read","the","project","setup",".","cfg","file","to","determine","Versioneer","config","."],"function":"def get_config_from_root(root):\n    \"\"\"Read the project setup.cfg file to determine Versioneer config.\"\"\"\n    # This might raise EnvironmentError (if setup.cfg is missing), or\n    # configparser.NoSectionError (if it lacks a [versioneer] section), or\n    # configparser.NoOptionError (if it lacks \"VCS=\"). See the docstring at\n    # the top of versioneer.py for instructions on writing your setup.cfg .\n    setup_cfg = os.path.join(root, \"setup.cfg\")\n    parser = configparser.SafeConfigParser()\n    with open(setup_cfg, \"r\") as f:\n        parser.readfp(f)\n    VCS = parser.get(\"versioneer\", \"VCS\")  # mandatory\n\n    def get(parser, name):\n        if parser.has_option(\"versioneer\", name):\n            return parser.get(\"versioneer\", name)\n        return None\n    cfg = VersioneerConfig()\n    cfg.VCS = VCS\n    cfg.style = get(parser, \"style\") or \"\"\n    cfg.versionfile_source = get(parser, \"versionfile_source\")\n    cfg.versionfile_build = get(parser, \"versionfile_build\")\n    cfg.tag_prefix = get(parser, \"tag_prefix\")\n    if cfg.tag_prefix in (\"''\", '\"\"'):\n        cfg.tag_prefix = \"\"\n    cfg.parentdir_prefix = get(parser, \"parentdir_prefix\")\n    cfg.verbose = get(parser, \"verbose\")\n    return cfg","function_tokens":["def","get_config_from_root","(","root",")",":","# This might raise EnvironmentError (if setup.cfg is missing), or","# configparser.NoSectionError (if it lacks a [versioneer] section), or","# configparser.NoOptionError (if it lacks \"VCS=\"). See the docstring at","# the top of versioneer.py for instructions on writing your setup.cfg .","setup_cfg","=","os",".","path",".","join","(","root",",","\"setup.cfg\"",")","parser","=","configparser",".","SafeConfigParser","(",")","with","open","(","setup_cfg",",","\"r\"",")","as","f",":","parser",".","readfp","(","f",")","VCS","=","parser",".","get","(","\"versioneer\"",",","\"VCS\"",")","# mandatory","def","get","(","parser",",","name",")",":","if","parser",".","has_option","(","\"versioneer\"",",","name",")",":","return","parser",".","get","(","\"versioneer\"",",","name",")","return","None","cfg","=","VersioneerConfig","(",")","cfg",".","VCS","=","VCS","cfg",".","style","=","get","(","parser",",","\"style\"",")","or","\"\"","cfg",".","versionfile_source","=","get","(","parser",",","\"versionfile_source\"",")","cfg",".","versionfile_build","=","get","(","parser",",","\"versionfile_build\"",")","cfg",".","tag_prefix","=","get","(","parser",",","\"tag_prefix\"",")","if","cfg",".","tag_prefix","in","(","\"''\"",",","'\"\"'",")",":","cfg",".","tag_prefix","=","\"\"","cfg",".","parentdir_prefix","=","get","(","parser",",","\"parentdir_prefix\"",")","cfg",".","verbose","=","get","(","parser",",","\"verbose\"",")","return","cfg"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L335-L361"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"register_vcs_handler","parameters":"(vcs, method)","argument_list":"","return_statement":"return decorate","docstring":"Decorator to mark a method as the handler for a particular VCS.","docstring_summary":"Decorator to mark a method as the handler for a particular VCS.","docstring_tokens":["Decorator","to","mark","a","method","as","the","handler","for","a","particular","VCS","."],"function":"def register_vcs_handler(vcs, method):  # decorator\n    \"\"\"Decorator to mark a method as the handler for a particular VCS.\"\"\"\n    def decorate(f):\n        \"\"\"Store f in HANDLERS[vcs][method].\"\"\"\n        if vcs not in HANDLERS:\n            HANDLERS[vcs] = {}\n        HANDLERS[vcs][method] = f\n        return f\n    return decorate","function_tokens":["def","register_vcs_handler","(","vcs",",","method",")",":","# decorator","def","decorate","(","f",")",":","\"\"\"Store f in HANDLERS[vcs][method].\"\"\"","if","vcs","not","in","HANDLERS",":","HANDLERS","[","vcs","]","=","{","}","HANDLERS","[","vcs","]","[","method","]","=","f","return","f","return","decorate"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L373-L381"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"run_command","parameters":"(commands, args, cwd=None, verbose=False, hide_stderr=False,\n                env=None)","argument_list":"","return_statement":"return stdout, p.returncode","docstring":"Call the given command(s).","docstring_summary":"Call the given command(s).","docstring_tokens":["Call","the","given","command","(","s",")","."],"function":"def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,\n                env=None):\n    \"\"\"Call the given command(s).\"\"\"\n    assert isinstance(commands, list)\n    p = None\n    for c in commands:\n        try:\n            dispcmd = str([c] + args)\n            # remember shell=False, so use git.cmd on windows, not just git\n            p = subprocess.Popen([c] + args, cwd=cwd, env=env,\n                                 stdout=subprocess.PIPE,\n                                 stderr=(subprocess.PIPE if hide_stderr\n                                         else None))\n            break\n        except EnvironmentError:\n            e = sys.exc_info()[1]\n            if e.errno == errno.ENOENT:\n                continue\n            if verbose:\n                print(\"unable to run %s\" % dispcmd)\n                print(e)\n            return None, None\n    else:\n        if verbose:\n            print(\"unable to find command, tried %s\" % (commands,))\n        return None, None\n    stdout = p.communicate()[0].strip()\n    if sys.version_info[0] >= 3:\n        stdout = stdout.decode()\n    if p.returncode != 0:\n        if verbose:\n            print(\"unable to run %s (error)\" % dispcmd)\n            print(\"stdout was %s\" % stdout)\n        return None, p.returncode\n    return stdout, p.returncode","function_tokens":["def","run_command","(","commands",",","args",",","cwd","=","None",",","verbose","=","False",",","hide_stderr","=","False",",","env","=","None",")",":","assert","isinstance","(","commands",",","list",")","p","=","None","for","c","in","commands",":","try",":","dispcmd","=","str","(","[","c","]","+","args",")","# remember shell=False, so use git.cmd on windows, not just git","p","=","subprocess",".","Popen","(","[","c","]","+","args",",","cwd","=","cwd",",","env","=","env",",","stdout","=","subprocess",".","PIPE",",","stderr","=","(","subprocess",".","PIPE","if","hide_stderr","else","None",")",")","break","except","EnvironmentError",":","e","=","sys",".","exc_info","(",")","[","1","]","if","e",".","errno","==","errno",".","ENOENT",":","continue","if","verbose",":","print","(","\"unable to run %s\"","%","dispcmd",")","print","(","e",")","return","None",",","None","else",":","if","verbose",":","print","(","\"unable to find command, tried %s\"","%","(","commands",",",")",")","return","None",",","None","stdout","=","p",".","communicate","(",")","[","0","]",".","strip","(",")","if","sys",".","version_info","[","0","]",">=","3",":","stdout","=","stdout",".","decode","(",")","if","p",".","returncode","!=","0",":","if","verbose",":","print","(","\"unable to run %s (error)\"","%","dispcmd",")","print","(","\"stdout was %s\"","%","stdout",")","return","None",",","p",".","returncode","return","stdout",",","p",".","returncode"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L384-L418"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"git_get_keywords","parameters":"(versionfile_abs)","argument_list":"","return_statement":"return keywords","docstring":"Extract version information from the given file.","docstring_summary":"Extract version information from the given file.","docstring_tokens":["Extract","version","information","from","the","given","file","."],"function":"def git_get_keywords(versionfile_abs):\n    \"\"\"Extract version information from the given file.\"\"\"\n    # the code embedded in _version.py can just fetch the value of these\n    # keywords. When used from setup.py, we don't want to import _version.py,\n    # so we do it with a regexp instead. This function is not used from\n    # _version.py.\n    keywords = {}\n    try:\n        f = open(versionfile_abs, \"r\")\n        for line in f.readlines():\n            if line.strip().startswith(\"git_refnames =\"):\n                mo = re.search(r'=\\s*\"(.*)\"', line)\n                if mo:\n                    keywords[\"refnames\"] = mo.group(1)\n            if line.strip().startswith(\"git_full =\"):\n                mo = re.search(r'=\\s*\"(.*)\"', line)\n                if mo:\n                    keywords[\"full\"] = mo.group(1)\n            if line.strip().startswith(\"git_date =\"):\n                mo = re.search(r'=\\s*\"(.*)\"', line)\n                if mo:\n                    keywords[\"date\"] = mo.group(1)\n        f.close()\n    except EnvironmentError:\n        pass\n    return keywords","function_tokens":["def","git_get_keywords","(","versionfile_abs",")",":","# the code embedded in _version.py can just fetch the value of these","# keywords. When used from setup.py, we don't want to import _version.py,","# so we do it with a regexp instead. This function is not used from","# _version.py.","keywords","=","{","}","try",":","f","=","open","(","versionfile_abs",",","\"r\"",")","for","line","in","f",".","readlines","(",")",":","if","line",".","strip","(",")",".","startswith","(","\"git_refnames =\"",")",":","mo","=","re",".","search","(","r'=\\s*\"(.*)\"'",",","line",")","if","mo",":","keywords","[","\"refnames\"","]","=","mo",".","group","(","1",")","if","line",".","strip","(",")",".","startswith","(","\"git_full =\"",")",":","mo","=","re",".","search","(","r'=\\s*\"(.*)\"'",",","line",")","if","mo",":","keywords","[","\"full\"","]","=","mo",".","group","(","1",")","if","line",".","strip","(",")",".","startswith","(","\"git_date =\"",")",":","mo","=","re",".","search","(","r'=\\s*\"(.*)\"'",",","line",")","if","mo",":","keywords","[","\"date\"","]","=","mo",".","group","(","1",")","f",".","close","(",")","except","EnvironmentError",":","pass","return","keywords"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L945-L970"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"git_versions_from_keywords","parameters":"(keywords, tag_prefix, verbose)","argument_list":"","return_statement":"return {\"version\": \"0+unknown\",\n            \"full-revisionid\": keywords[\"full\"].strip(),\n            \"dirty\": False, \"error\": \"no suitable tags\", \"date\": None}","docstring":"Get version information from git keywords.","docstring_summary":"Get version information from git keywords.","docstring_tokens":["Get","version","information","from","git","keywords","."],"function":"def git_versions_from_keywords(keywords, tag_prefix, verbose):\n    \"\"\"Get version information from git keywords.\"\"\"\n    if not keywords:\n        raise NotThisMethod(\"no keywords at all, weird\")\n    date = keywords.get(\"date\")\n    if date is not None:\n        # git-2.2.0 added \"%cI\", which expands to an ISO-8601 -compliant\n        # datestamp. However we prefer \"%ci\" (which expands to an \"ISO-8601\n        # -like\" string, which we must then edit to make compliant), because\n        # it's been around since git-1.5.3, and it's too difficult to\n        # discover which version we're using, or to work around using an\n        # older one.\n        date = date.strip().replace(\" \", \"T\", 1).replace(\" \", \"\", 1)\n    refnames = keywords[\"refnames\"].strip()\n    if refnames.startswith(\"$Format\"):\n        if verbose:\n            print(\"keywords are unexpanded, not using\")\n        raise NotThisMethod(\"unexpanded keywords, not a git-archive tarball\")\n    refs = set([r.strip() for r in refnames.strip(\"()\").split(\",\")])\n    # starting in git-1.8.3, tags are listed as \"tag: foo-1.0\" instead of\n    # just \"foo-1.0\". If we see a \"tag: \" prefix, prefer those.\n    TAG = \"tag: \"\n    tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])\n    if not tags:\n        # Either we're using git < 1.8.3, or there really are no tags. We use\n        # a heuristic: assume all version tags have a digit. The old git %d\n        # expansion behaves like git log --decorate=short and strips out the\n        # refs\/heads\/ and refs\/tags\/ prefixes that would let us distinguish\n        # between branches and tags. By ignoring refnames without digits, we\n        # filter out many common branch names like \"release\" and\n        # \"stabilization\", as well as \"HEAD\" and \"master\".\n        tags = set([r for r in refs if re.search(r'\\d', r)])\n        if verbose:\n            print(\"discarding '%s', no digits\" % \",\".join(refs - tags))\n    if verbose:\n        print(\"likely tags: %s\" % \",\".join(sorted(tags)))\n    for ref in sorted(tags):\n        # sorting will prefer e.g. \"2.0\" over \"2.0rc1\"\n        if ref.startswith(tag_prefix):\n            r = ref[len(tag_prefix):]\n            if verbose:\n                print(\"picking %s\" % r)\n            return {\"version\": r,\n                    \"full-revisionid\": keywords[\"full\"].strip(),\n                    \"dirty\": False, \"error\": None,\n                    \"date\": date}\n    # no suitable tags, so version is \"0+unknown\", but full hex is still there\n    if verbose:\n        print(\"no suitable tags, using unknown + full revision id\")\n    return {\"version\": \"0+unknown\",\n            \"full-revisionid\": keywords[\"full\"].strip(),\n            \"dirty\": False, \"error\": \"no suitable tags\", \"date\": None}","function_tokens":["def","git_versions_from_keywords","(","keywords",",","tag_prefix",",","verbose",")",":","if","not","keywords",":","raise","NotThisMethod","(","\"no keywords at all, weird\"",")","date","=","keywords",".","get","(","\"date\"",")","if","date","is","not","None",":","# git-2.2.0 added \"%cI\", which expands to an ISO-8601 -compliant","# datestamp. However we prefer \"%ci\" (which expands to an \"ISO-8601","# -like\" string, which we must then edit to make compliant), because","# it's been around since git-1.5.3, and it's too difficult to","# discover which version we're using, or to work around using an","# older one.","date","=","date",".","strip","(",")",".","replace","(","\" \"",",","\"T\"",",","1",")",".","replace","(","\" \"",",","\"\"",",","1",")","refnames","=","keywords","[","\"refnames\"","]",".","strip","(",")","if","refnames",".","startswith","(","\"$Format\"",")",":","if","verbose",":","print","(","\"keywords are unexpanded, not using\"",")","raise","NotThisMethod","(","\"unexpanded keywords, not a git-archive tarball\"",")","refs","=","set","(","[","r",".","strip","(",")","for","r","in","refnames",".","strip","(","\"()\"",")",".","split","(","\",\"",")","]",")","# starting in git-1.8.3, tags are listed as \"tag: foo-1.0\" instead of","# just \"foo-1.0\". If we see a \"tag: \" prefix, prefer those.","TAG","=","\"tag: \"","tags","=","set","(","[","r","[","len","(","TAG",")",":","]","for","r","in","refs","if","r",".","startswith","(","TAG",")","]",")","if","not","tags",":","# Either we're using git < 1.8.3, or there really are no tags. We use","# a heuristic: assume all version tags have a digit. The old git %d","# expansion behaves like git log --decorate=short and strips out the","# refs\/heads\/ and refs\/tags\/ prefixes that would let us distinguish","# between branches and tags. By ignoring refnames without digits, we","# filter out many common branch names like \"release\" and","# \"stabilization\", as well as \"HEAD\" and \"master\".","tags","=","set","(","[","r","for","r","in","refs","if","re",".","search","(","r'\\d'",",","r",")","]",")","if","verbose",":","print","(","\"discarding '%s', no digits\"","%","\",\"",".","join","(","refs","-","tags",")",")","if","verbose",":","print","(","\"likely tags: %s\"","%","\",\"",".","join","(","sorted","(","tags",")",")",")","for","ref","in","sorted","(","tags",")",":","# sorting will prefer e.g. \"2.0\" over \"2.0rc1\"","if","ref",".","startswith","(","tag_prefix",")",":","r","=","ref","[","len","(","tag_prefix",")",":","]","if","verbose",":","print","(","\"picking %s\"","%","r",")","return","{","\"version\"",":","r",",","\"full-revisionid\"",":","keywords","[","\"full\"","]",".","strip","(",")",",","\"dirty\"",":","False",",","\"error\"",":","None",",","\"date\"",":","date","}","# no suitable tags, so version is \"0+unknown\", but full hex is still there","if","verbose",":","print","(","\"no suitable tags, using unknown + full revision id\"",")","return","{","\"version\"",":","\"0+unknown\"",",","\"full-revisionid\"",":","keywords","[","\"full\"","]",".","strip","(",")",",","\"dirty\"",":","False",",","\"error\"",":","\"no suitable tags\"",",","\"date\"",":","None","}"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L974-L1025"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"git_pieces_from_vcs","parameters":"(tag_prefix, root, verbose, run_command=run_command)","argument_list":"","return_statement":"return pieces","docstring":"Get version from 'git describe' in the root of the source tree.\n\n    This only gets called if the git-archive 'subst' keywords were *not*\n    expanded, and _version.py hasn't already been rewritten with a short\n    version string, meaning we're inside a checked out source tree.","docstring_summary":"Get version from 'git describe' in the root of the source tree.","docstring_tokens":["Get","version","from","git","describe","in","the","root","of","the","source","tree","."],"function":"def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):\n    \"\"\"Get version from 'git describe' in the root of the source tree.\n\n    This only gets called if the git-archive 'subst' keywords were *not*\n    expanded, and _version.py hasn't already been rewritten with a short\n    version string, meaning we're inside a checked out source tree.\n    \"\"\"\n    GITS = [\"git\"]\n    if sys.platform == \"win32\":\n        GITS = [\"git.cmd\", \"git.exe\"]\n\n    out, rc = run_command(GITS, [\"rev-parse\", \"--git-dir\"], cwd=root,\n                          hide_stderr=True)\n    if rc != 0:\n        if verbose:\n            print(\"Directory %s not under git control\" % root)\n        raise NotThisMethod(\"'git rev-parse --git-dir' returned error\")\n\n    # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]\n    # if there isn't one, this yields HEX[-dirty] (no NUM)\n    describe_out, rc = run_command(GITS, [\"describe\", \"--tags\", \"--dirty\",\n                                          \"--always\", \"--long\",\n                                          \"--match\", \"%s*\" % tag_prefix],\n                                   cwd=root)\n    # --long was added in git-1.5.5\n    if describe_out is None:\n        raise NotThisMethod(\"'git describe' failed\")\n    describe_out = describe_out.strip()\n    full_out, rc = run_command(GITS, [\"rev-parse\", \"HEAD\"], cwd=root)\n    if full_out is None:\n        raise NotThisMethod(\"'git rev-parse' failed\")\n    full_out = full_out.strip()\n\n    pieces = {}\n    pieces[\"long\"] = full_out\n    pieces[\"short\"] = full_out[:7]  # maybe improved later\n    pieces[\"error\"] = None\n\n    # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]\n    # TAG might have hyphens.\n    git_describe = describe_out\n\n    # look for -dirty suffix\n    dirty = git_describe.endswith(\"-dirty\")\n    pieces[\"dirty\"] = dirty\n    if dirty:\n        git_describe = git_describe[:git_describe.rindex(\"-dirty\")]\n\n    # now we have TAG-NUM-gHEX or HEX\n\n    if \"-\" in git_describe:\n        # TAG-NUM-gHEX\n        mo = re.search(r'^(.+)-(\\d+)-g([0-9a-f]+)$', git_describe)\n        if not mo:\n            # unparseable. Maybe git-describe is misbehaving?\n            pieces[\"error\"] = (\"unable to parse git-describe output: '%s'\"\n                               % describe_out)\n            return pieces\n\n        # tag\n        full_tag = mo.group(1)\n        if not full_tag.startswith(tag_prefix):\n            if verbose:\n                fmt = \"tag '%s' doesn't start with prefix '%s'\"\n                print(fmt % (full_tag, tag_prefix))\n            pieces[\"error\"] = (\"tag '%s' doesn't start with prefix '%s'\"\n                               % (full_tag, tag_prefix))\n            return pieces\n        pieces[\"closest-tag\"] = full_tag[len(tag_prefix):]\n\n        # distance: number of commits since tag\n        pieces[\"distance\"] = int(mo.group(2))\n\n        # commit: short hex revision ID\n        pieces[\"short\"] = mo.group(3)\n\n    else:\n        # HEX: no tags\n        pieces[\"closest-tag\"] = None\n        count_out, rc = run_command(GITS, [\"rev-list\", \"HEAD\", \"--count\"],\n                                    cwd=root)\n        pieces[\"distance\"] = int(count_out)  # total number of commits\n\n    # commit date: see ISO-8601 comment in git_versions_from_keywords()\n    date = run_command(GITS, [\"show\", \"-s\", \"--format=%ci\", \"HEAD\"],\n                       cwd=root)[0].strip()\n    pieces[\"date\"] = date.strip().replace(\" \", \"T\", 1).replace(\" \", \"\", 1)\n\n    return pieces","function_tokens":["def","git_pieces_from_vcs","(","tag_prefix",",","root",",","verbose",",","run_command","=","run_command",")",":","GITS","=","[","\"git\"","]","if","sys",".","platform","==","\"win32\"",":","GITS","=","[","\"git.cmd\"",",","\"git.exe\"","]","out",",","rc","=","run_command","(","GITS",",","[","\"rev-parse\"",",","\"--git-dir\"","]",",","cwd","=","root",",","hide_stderr","=","True",")","if","rc","!=","0",":","if","verbose",":","print","(","\"Directory %s not under git control\"","%","root",")","raise","NotThisMethod","(","\"'git rev-parse --git-dir' returned error\"",")","# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]","# if there isn't one, this yields HEX[-dirty] (no NUM)","describe_out",",","rc","=","run_command","(","GITS",",","[","\"describe\"",",","\"--tags\"",",","\"--dirty\"",",","\"--always\"",",","\"--long\"",",","\"--match\"",",","\"%s*\"","%","tag_prefix","]",",","cwd","=","root",")","# --long was added in git-1.5.5","if","describe_out","is","None",":","raise","NotThisMethod","(","\"'git describe' failed\"",")","describe_out","=","describe_out",".","strip","(",")","full_out",",","rc","=","run_command","(","GITS",",","[","\"rev-parse\"",",","\"HEAD\"","]",",","cwd","=","root",")","if","full_out","is","None",":","raise","NotThisMethod","(","\"'git rev-parse' failed\"",")","full_out","=","full_out",".","strip","(",")","pieces","=","{","}","pieces","[","\"long\"","]","=","full_out","pieces","[","\"short\"","]","=","full_out","[",":","7","]","# maybe improved later","pieces","[","\"error\"","]","=","None","# parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]","# TAG might have hyphens.","git_describe","=","describe_out","# look for -dirty suffix","dirty","=","git_describe",".","endswith","(","\"-dirty\"",")","pieces","[","\"dirty\"","]","=","dirty","if","dirty",":","git_describe","=","git_describe","[",":","git_describe",".","rindex","(","\"-dirty\"",")","]","# now we have TAG-NUM-gHEX or HEX","if","\"-\"","in","git_describe",":","# TAG-NUM-gHEX","mo","=","re",".","search","(","r'^(.+)-(\\d+)-g([0-9a-f]+)$'",",","git_describe",")","if","not","mo",":","# unparseable. Maybe git-describe is misbehaving?","pieces","[","\"error\"","]","=","(","\"unable to parse git-describe output: '%s'\"","%","describe_out",")","return","pieces","# tag","full_tag","=","mo",".","group","(","1",")","if","not","full_tag",".","startswith","(","tag_prefix",")",":","if","verbose",":","fmt","=","\"tag '%s' doesn't start with prefix '%s'\"","print","(","fmt","%","(","full_tag",",","tag_prefix",")",")","pieces","[","\"error\"","]","=","(","\"tag '%s' doesn't start with prefix '%s'\"","%","(","full_tag",",","tag_prefix",")",")","return","pieces","pieces","[","\"closest-tag\"","]","=","full_tag","[","len","(","tag_prefix",")",":","]","# distance: number of commits since tag","pieces","[","\"distance\"","]","=","int","(","mo",".","group","(","2",")",")","# commit: short hex revision ID","pieces","[","\"short\"","]","=","mo",".","group","(","3",")","else",":","# HEX: no tags","pieces","[","\"closest-tag\"","]","=","None","count_out",",","rc","=","run_command","(","GITS",",","[","\"rev-list\"",",","\"HEAD\"",",","\"--count\"","]",",","cwd","=","root",")","pieces","[","\"distance\"","]","=","int","(","count_out",")","# total number of commits","# commit date: see ISO-8601 comment in git_versions_from_keywords()","date","=","run_command","(","GITS",",","[","\"show\"",",","\"-s\"",",","\"--format=%ci\"",",","\"HEAD\"","]",",","cwd","=","root",")","[","0","]",".","strip","(",")","pieces","[","\"date\"","]","=","date",".","strip","(",")",".","replace","(","\" \"",",","\"T\"",",","1",")",".","replace","(","\" \"",",","\"\"",",","1",")","return","pieces"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1029-L1117"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"do_vcs_install","parameters":"(manifest_in, versionfile_source, ipy)","argument_list":"","return_statement":"","docstring":"Git-specific installation logic for Versioneer.\n\n    For Git, this means creating\/changing .gitattributes to mark _version.py\n    for export-subst keyword substitution.","docstring_summary":"Git-specific installation logic for Versioneer.","docstring_tokens":["Git","-","specific","installation","logic","for","Versioneer","."],"function":"def do_vcs_install(manifest_in, versionfile_source, ipy):\n    \"\"\"Git-specific installation logic for Versioneer.\n\n    For Git, this means creating\/changing .gitattributes to mark _version.py\n    for export-subst keyword substitution.\n    \"\"\"\n    GITS = [\"git\"]\n    if sys.platform == \"win32\":\n        GITS = [\"git.cmd\", \"git.exe\"]\n    files = [manifest_in, versionfile_source]\n    if ipy:\n        files.append(ipy)\n    try:\n        me = __file__\n        if me.endswith(\".pyc\") or me.endswith(\".pyo\"):\n            me = os.path.splitext(me)[0] + \".py\"\n        versioneer_file = os.path.relpath(me)\n    except NameError:\n        versioneer_file = \"versioneer.py\"\n    files.append(versioneer_file)\n    present = False\n    try:\n        f = open(\".gitattributes\", \"r\")\n        for line in f.readlines():\n            if line.strip().startswith(versionfile_source):\n                if \"export-subst\" in line.strip().split()[1:]:\n                    present = True\n        f.close()\n    except EnvironmentError:\n        pass\n    if not present:\n        f = open(\".gitattributes\", \"a+\")\n        f.write(\"%s export-subst\\n\" % versionfile_source)\n        f.close()\n        files.append(\".gitattributes\")\n    run_command(GITS, [\"add\", \"--\"] + files)","function_tokens":["def","do_vcs_install","(","manifest_in",",","versionfile_source",",","ipy",")",":","GITS","=","[","\"git\"","]","if","sys",".","platform","==","\"win32\"",":","GITS","=","[","\"git.cmd\"",",","\"git.exe\"","]","files","=","[","manifest_in",",","versionfile_source","]","if","ipy",":","files",".","append","(","ipy",")","try",":","me","=","__file__","if","me",".","endswith","(","\".pyc\"",")","or","me",".","endswith","(","\".pyo\"",")",":","me","=","os",".","path",".","splitext","(","me",")","[","0","]","+","\".py\"","versioneer_file","=","os",".","path",".","relpath","(","me",")","except","NameError",":","versioneer_file","=","\"versioneer.py\"","files",".","append","(","versioneer_file",")","present","=","False","try",":","f","=","open","(","\".gitattributes\"",",","\"r\"",")","for","line","in","f",".","readlines","(",")",":","if","line",".","strip","(",")",".","startswith","(","versionfile_source",")",":","if","\"export-subst\"","in","line",".","strip","(",")",".","split","(",")","[","1",":","]",":","present","=","True","f",".","close","(",")","except","EnvironmentError",":","pass","if","not","present",":","f","=","open","(","\".gitattributes\"",",","\"a+\"",")","f",".","write","(","\"%s export-subst\\n\"","%","versionfile_source",")","f",".","close","(",")","files",".","append","(","\".gitattributes\"",")","run_command","(","GITS",",","[","\"add\"",",","\"--\"","]","+","files",")"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1120-L1155"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"versions_from_parentdir","parameters":"(parentdir_prefix, root, verbose)","argument_list":"","return_statement":"","docstring":"Try to determine the version from the parent directory name.\n\n    Source tarballs conventionally unpack into a directory that includes both\n    the project name and a version string. We will also support searching up\n    two directory levels for an appropriately named parent directory","docstring_summary":"Try to determine the version from the parent directory name.","docstring_tokens":["Try","to","determine","the","version","from","the","parent","directory","name","."],"function":"def versions_from_parentdir(parentdir_prefix, root, verbose):\n    \"\"\"Try to determine the version from the parent directory name.\n\n    Source tarballs conventionally unpack into a directory that includes both\n    the project name and a version string. We will also support searching up\n    two directory levels for an appropriately named parent directory\n    \"\"\"\n    rootdirs = []\n\n    for i in range(3):\n        dirname = os.path.basename(root)\n        if dirname.startswith(parentdir_prefix):\n            return {\"version\": dirname[len(parentdir_prefix):],\n                    \"full-revisionid\": None,\n                    \"dirty\": False, \"error\": None, \"date\": None}\n        else:\n            rootdirs.append(root)\n            root = os.path.dirname(root)  # up a level\n\n    if verbose:\n        print(\"Tried directories %s but none started with prefix %s\" %\n              (str(rootdirs), parentdir_prefix))\n    raise NotThisMethod(\"rootdir doesn't start with parentdir_prefix\")","function_tokens":["def","versions_from_parentdir","(","parentdir_prefix",",","root",",","verbose",")",":","rootdirs","=","[","]","for","i","in","range","(","3",")",":","dirname","=","os",".","path",".","basename","(","root",")","if","dirname",".","startswith","(","parentdir_prefix",")",":","return","{","\"version\"",":","dirname","[","len","(","parentdir_prefix",")",":","]",",","\"full-revisionid\"",":","None",",","\"dirty\"",":","False",",","\"error\"",":","None",",","\"date\"",":","None","}","else",":","rootdirs",".","append","(","root",")","root","=","os",".","path",".","dirname","(","root",")","# up a level","if","verbose",":","print","(","\"Tried directories %s but none started with prefix %s\"","%","(","str","(","rootdirs",")",",","parentdir_prefix",")",")","raise","NotThisMethod","(","\"rootdir doesn't start with parentdir_prefix\"",")"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1158-L1180"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"versions_from_file","parameters":"(filename)","argument_list":"","return_statement":"return json.loads(mo.group(1))","docstring":"Try to determine the version from _version.py if present.","docstring_summary":"Try to determine the version from _version.py if present.","docstring_tokens":["Try","to","determine","the","version","from","_version",".","py","if","present","."],"function":"def versions_from_file(filename):\n    \"\"\"Try to determine the version from _version.py if present.\"\"\"\n    try:\n        with open(filename) as f:\n            contents = f.read()\n    except EnvironmentError:\n        raise NotThisMethod(\"unable to read _version.py\")\n    mo = re.search(r\"version_json = '''\\n(.*)'''  # END VERSION_JSON\",\n                   contents, re.M | re.S)\n    if not mo:\n        mo = re.search(r\"version_json = '''\\r\\n(.*)'''  # END VERSION_JSON\",\n                       contents, re.M | re.S)\n    if not mo:\n        raise NotThisMethod(\"no version_json in _version.py\")\n    return json.loads(mo.group(1))","function_tokens":["def","versions_from_file","(","filename",")",":","try",":","with","open","(","filename",")","as","f",":","contents","=","f",".","read","(",")","except","EnvironmentError",":","raise","NotThisMethod","(","\"unable to read _version.py\"",")","mo","=","re",".","search","(","r\"version_json = '''\\n(.*)'''  # END VERSION_JSON\"",",","contents",",","re",".","M","|","re",".","S",")","if","not","mo",":","mo","=","re",".","search","(","r\"version_json = '''\\r\\n(.*)'''  # END VERSION_JSON\"",",","contents",",","re",".","M","|","re",".","S",")","if","not","mo",":","raise","NotThisMethod","(","\"no version_json in _version.py\"",")","return","json",".","loads","(","mo",".","group","(","1",")",")"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1201-L1215"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"write_to_version_file","parameters":"(filename, versions)","argument_list":"","return_statement":"","docstring":"Write the given version number to the given _version.py file.","docstring_summary":"Write the given version number to the given _version.py file.","docstring_tokens":["Write","the","given","version","number","to","the","given","_version",".","py","file","."],"function":"def write_to_version_file(filename, versions):\n    \"\"\"Write the given version number to the given _version.py file.\"\"\"\n    os.unlink(filename)\n    contents = json.dumps(versions, sort_keys=True,\n                          indent=1, separators=(\",\", \": \"))\n    with open(filename, \"w\") as f:\n        f.write(SHORT_VERSION_PY % contents)\n\n    print(\"set %s to '%s'\" % (filename, versions[\"version\"]))","function_tokens":["def","write_to_version_file","(","filename",",","versions",")",":","os",".","unlink","(","filename",")","contents","=","json",".","dumps","(","versions",",","sort_keys","=","True",",","indent","=","1",",","separators","=","(","\",\"",",","\": \"",")",")","with","open","(","filename",",","\"w\"",")","as","f",":","f",".","write","(","SHORT_VERSION_PY","%","contents",")","print","(","\"set %s to '%s'\"","%","(","filename",",","versions","[","\"version\"","]",")",")"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1218-L1226"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"plus_or_dot","parameters":"(pieces)","argument_list":"","return_statement":"return \"+\"","docstring":"Return a + if we don't already have one, else return a .","docstring_summary":"Return a + if we don't already have one, else return a .","docstring_tokens":["Return","a","+","if","we","don","t","already","have","one","else","return","a","."],"function":"def plus_or_dot(pieces):\n    \"\"\"Return a + if we don't already have one, else return a .\"\"\"\n    if \"+\" in pieces.get(\"closest-tag\", \"\"):\n        return \".\"\n    return \"+\"","function_tokens":["def","plus_or_dot","(","pieces",")",":","if","\"+\"","in","pieces",".","get","(","\"closest-tag\"",",","\"\"",")",":","return","\".\"","return","\"+\""],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1229-L1233"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"render_pep440","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"Build up version string, with post-release \"local version identifier\".\n\n    Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you\n    get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty\n\n    Exceptions:\n    1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]","docstring_summary":"Build up version string, with post-release \"local version identifier\".","docstring_tokens":["Build","up","version","string","with","post","-","release","local","version","identifier","."],"function":"def render_pep440(pieces):\n    \"\"\"Build up version string, with post-release \"local version identifier\".\n\n    Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you\n    get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty\n\n    Exceptions:\n    1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"] or pieces[\"dirty\"]:\n            rendered += plus_or_dot(pieces)\n            rendered += \"%d.g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n            if pieces[\"dirty\"]:\n                rendered += \".dirty\"\n    else:\n        # exception #1\n        rendered = \"0+untagged.%d.g%s\" % (pieces[\"distance\"],\n                                          pieces[\"short\"])\n        if pieces[\"dirty\"]:\n            rendered += \".dirty\"\n    return rendered","function_tokens":["def","render_pep440","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]","or","pieces","[","\"dirty\"","]",":","rendered","+=","plus_or_dot","(","pieces",")","rendered","+=","\"%d.g%s\"","%","(","pieces","[","\"distance\"","]",",","pieces","[","\"short\"","]",")","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dirty\"","else",":","# exception #1","rendered","=","\"0+untagged.%d.g%s\"","%","(","pieces","[","\"distance\"","]",",","pieces","[","\"short\"","]",")","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dirty\"","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1236-L1258"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"render_pep440_pre","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG[.post.devDISTANCE] -- No -dirty.\n\n    Exceptions:\n    1: no tags. 0.post.devDISTANCE","docstring_summary":"TAG[.post.devDISTANCE] -- No -dirty.","docstring_tokens":["TAG","[",".","post",".","devDISTANCE","]","--","No","-","dirty","."],"function":"def render_pep440_pre(pieces):\n    \"\"\"TAG[.post.devDISTANCE] -- No -dirty.\n\n    Exceptions:\n    1: no tags. 0.post.devDISTANCE\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"]:\n            rendered += \".post.dev%d\" % pieces[\"distance\"]\n    else:\n        # exception #1\n        rendered = \"0.post.dev%d\" % pieces[\"distance\"]\n    return rendered","function_tokens":["def","render_pep440_pre","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]",":","rendered","+=","\".post.dev%d\"","%","pieces","[","\"distance\"","]","else",":","# exception #1","rendered","=","\"0.post.dev%d\"","%","pieces","[","\"distance\"","]","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1261-L1274"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"render_pep440_post","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG[.postDISTANCE[.dev0]+gHEX] .\n\n    The \".dev0\" means dirty. Note that .dev0 sorts backwards\n    (a dirty tree will appear \"older\" than the corresponding clean one),\n    but you shouldn't be releasing software with -dirty anyways.\n\n    Exceptions:\n    1: no tags. 0.postDISTANCE[.dev0]","docstring_summary":"TAG[.postDISTANCE[.dev0]+gHEX] .","docstring_tokens":["TAG","[",".","postDISTANCE","[",".","dev0","]","+","gHEX","]","."],"function":"def render_pep440_post(pieces):\n    \"\"\"TAG[.postDISTANCE[.dev0]+gHEX] .\n\n    The \".dev0\" means dirty. Note that .dev0 sorts backwards\n    (a dirty tree will appear \"older\" than the corresponding clean one),\n    but you shouldn't be releasing software with -dirty anyways.\n\n    Exceptions:\n    1: no tags. 0.postDISTANCE[.dev0]\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"] or pieces[\"dirty\"]:\n            rendered += \".post%d\" % pieces[\"distance\"]\n            if pieces[\"dirty\"]:\n                rendered += \".dev0\"\n            rendered += plus_or_dot(pieces)\n            rendered += \"g%s\" % pieces[\"short\"]\n    else:\n        # exception #1\n        rendered = \"0.post%d\" % pieces[\"distance\"]\n        if pieces[\"dirty\"]:\n            rendered += \".dev0\"\n        rendered += \"+g%s\" % pieces[\"short\"]\n    return rendered","function_tokens":["def","render_pep440_post","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]","or","pieces","[","\"dirty\"","]",":","rendered","+=","\".post%d\"","%","pieces","[","\"distance\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dev0\"","rendered","+=","plus_or_dot","(","pieces",")","rendered","+=","\"g%s\"","%","pieces","[","\"short\"","]","else",":","# exception #1","rendered","=","\"0.post%d\"","%","pieces","[","\"distance\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dev0\"","rendered","+=","\"+g%s\"","%","pieces","[","\"short\"","]","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1277-L1301"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"render_pep440_old","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG[.postDISTANCE[.dev0]] .\n\n    The \".dev0\" means dirty.\n\n    Eexceptions:\n    1: no tags. 0.postDISTANCE[.dev0]","docstring_summary":"TAG[.postDISTANCE[.dev0]] .","docstring_tokens":["TAG","[",".","postDISTANCE","[",".","dev0","]]","."],"function":"def render_pep440_old(pieces):\n    \"\"\"TAG[.postDISTANCE[.dev0]] .\n\n    The \".dev0\" means dirty.\n\n    Eexceptions:\n    1: no tags. 0.postDISTANCE[.dev0]\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"] or pieces[\"dirty\"]:\n            rendered += \".post%d\" % pieces[\"distance\"]\n            if pieces[\"dirty\"]:\n                rendered += \".dev0\"\n    else:\n        # exception #1\n        rendered = \"0.post%d\" % pieces[\"distance\"]\n        if pieces[\"dirty\"]:\n            rendered += \".dev0\"\n    return rendered","function_tokens":["def","render_pep440_old","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]","or","pieces","[","\"dirty\"","]",":","rendered","+=","\".post%d\"","%","pieces","[","\"distance\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dev0\"","else",":","# exception #1","rendered","=","\"0.post%d\"","%","pieces","[","\"distance\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dev0\"","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1304-L1323"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"render_git_describe","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG[-DISTANCE-gHEX][-dirty].\n\n    Like 'git describe --tags --dirty --always'.\n\n    Exceptions:\n    1: no tags. HEX[-dirty]  (note: no 'g' prefix)","docstring_summary":"TAG[-DISTANCE-gHEX][-dirty].","docstring_tokens":["TAG","[","-","DISTANCE","-","gHEX","]","[","-","dirty","]","."],"function":"def render_git_describe(pieces):\n    \"\"\"TAG[-DISTANCE-gHEX][-dirty].\n\n    Like 'git describe --tags --dirty --always'.\n\n    Exceptions:\n    1: no tags. HEX[-dirty]  (note: no 'g' prefix)\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"]:\n            rendered += \"-%d-g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n    else:\n        # exception #1\n        rendered = pieces[\"short\"]\n    if pieces[\"dirty\"]:\n        rendered += \"-dirty\"\n    return rendered","function_tokens":["def","render_git_describe","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]",":","rendered","+=","\"-%d-g%s\"","%","(","pieces","[","\"distance\"","]",",","pieces","[","\"short\"","]",")","else",":","# exception #1","rendered","=","pieces","[","\"short\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\"-dirty\"","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1326-L1343"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"render_git_describe_long","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG-DISTANCE-gHEX[-dirty].\n\n    Like 'git describe --tags --dirty --always -long'.\n    The distance\/hash is unconditional.\n\n    Exceptions:\n    1: no tags. HEX[-dirty]  (note: no 'g' prefix)","docstring_summary":"TAG-DISTANCE-gHEX[-dirty].","docstring_tokens":["TAG","-","DISTANCE","-","gHEX","[","-","dirty","]","."],"function":"def render_git_describe_long(pieces):\n    \"\"\"TAG-DISTANCE-gHEX[-dirty].\n\n    Like 'git describe --tags --dirty --always -long'.\n    The distance\/hash is unconditional.\n\n    Exceptions:\n    1: no tags. HEX[-dirty]  (note: no 'g' prefix)\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        rendered += \"-%d-g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n    else:\n        # exception #1\n        rendered = pieces[\"short\"]\n    if pieces[\"dirty\"]:\n        rendered += \"-dirty\"\n    return rendered","function_tokens":["def","render_git_describe_long","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","rendered","+=","\"-%d-g%s\"","%","(","pieces","[","\"distance\"","]",",","pieces","[","\"short\"","]",")","else",":","# exception #1","rendered","=","pieces","[","\"short\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\"-dirty\"","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1346-L1363"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"render","parameters":"(pieces, style)","argument_list":"","return_statement":"return {\"version\": rendered, \"full-revisionid\": pieces[\"long\"],\n            \"dirty\": pieces[\"dirty\"], \"error\": None,\n            \"date\": pieces.get(\"date\")}","docstring":"Render the given version pieces into the requested style.","docstring_summary":"Render the given version pieces into the requested style.","docstring_tokens":["Render","the","given","version","pieces","into","the","requested","style","."],"function":"def render(pieces, style):\n    \"\"\"Render the given version pieces into the requested style.\"\"\"\n    if pieces[\"error\"]:\n        return {\"version\": \"unknown\",\n                \"full-revisionid\": pieces.get(\"long\"),\n                \"dirty\": None,\n                \"error\": pieces[\"error\"],\n                \"date\": None}\n\n    if not style or style == \"default\":\n        style = \"pep440\"  # the default\n\n    if style == \"pep440\":\n        rendered = render_pep440(pieces)\n    elif style == \"pep440-pre\":\n        rendered = render_pep440_pre(pieces)\n    elif style == \"pep440-post\":\n        rendered = render_pep440_post(pieces)\n    elif style == \"pep440-old\":\n        rendered = render_pep440_old(pieces)\n    elif style == \"git-describe\":\n        rendered = render_git_describe(pieces)\n    elif style == \"git-describe-long\":\n        rendered = render_git_describe_long(pieces)\n    else:\n        raise ValueError(\"unknown style '%s'\" % style)\n\n    return {\"version\": rendered, \"full-revisionid\": pieces[\"long\"],\n            \"dirty\": pieces[\"dirty\"], \"error\": None,\n            \"date\": pieces.get(\"date\")}","function_tokens":["def","render","(","pieces",",","style",")",":","if","pieces","[","\"error\"","]",":","return","{","\"version\"",":","\"unknown\"",",","\"full-revisionid\"",":","pieces",".","get","(","\"long\"",")",",","\"dirty\"",":","None",",","\"error\"",":","pieces","[","\"error\"","]",",","\"date\"",":","None","}","if","not","style","or","style","==","\"default\"",":","style","=","\"pep440\"","# the default","if","style","==","\"pep440\"",":","rendered","=","render_pep440","(","pieces",")","elif","style","==","\"pep440-pre\"",":","rendered","=","render_pep440_pre","(","pieces",")","elif","style","==","\"pep440-post\"",":","rendered","=","render_pep440_post","(","pieces",")","elif","style","==","\"pep440-old\"",":","rendered","=","render_pep440_old","(","pieces",")","elif","style","==","\"git-describe\"",":","rendered","=","render_git_describe","(","pieces",")","elif","style","==","\"git-describe-long\"",":","rendered","=","render_git_describe_long","(","pieces",")","else",":","raise","ValueError","(","\"unknown style '%s'\"","%","style",")","return","{","\"version\"",":","rendered",",","\"full-revisionid\"",":","pieces","[","\"long\"","]",",","\"dirty\"",":","pieces","[","\"dirty\"","]",",","\"error\"",":","None",",","\"date\"",":","pieces",".","get","(","\"date\"",")","}"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1366-L1395"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"get_versions","parameters":"(verbose=False)","argument_list":"","return_statement":"return {\"version\": \"0+unknown\", \"full-revisionid\": None,\n            \"dirty\": None, \"error\": \"unable to compute version\",\n            \"date\": None}","docstring":"Get the project version from whatever source is available.\n\n    Returns dict with two keys: 'version' and 'full'.","docstring_summary":"Get the project version from whatever source is available.","docstring_tokens":["Get","the","project","version","from","whatever","source","is","available","."],"function":"def get_versions(verbose=False):\n    \"\"\"Get the project version from whatever source is available.\n\n    Returns dict with two keys: 'version' and 'full'.\n    \"\"\"\n    if \"versioneer\" in sys.modules:\n        # see the discussion in cmdclass.py:get_cmdclass()\n        del sys.modules[\"versioneer\"]\n\n    root = get_root()\n    cfg = get_config_from_root(root)\n\n    assert cfg.VCS is not None, \"please set [versioneer]VCS= in setup.cfg\"\n    handlers = HANDLERS.get(cfg.VCS)\n    assert handlers, \"unrecognized VCS '%s'\" % cfg.VCS\n    verbose = verbose or cfg.verbose\n    assert cfg.versionfile_source is not None, \\\n        \"please set versioneer.versionfile_source\"\n    assert cfg.tag_prefix is not None, \"please set versioneer.tag_prefix\"\n\n    versionfile_abs = os.path.join(root, cfg.versionfile_source)\n\n    # extract version from first of: _version.py, VCS command (e.g. 'git\n    # describe'), parentdir. This is meant to work for developers using a\n    # source checkout, for users of a tarball created by 'setup.py sdist',\n    # and for users of a tarball\/zipball created by 'git archive' or github's\n    # download-from-tag feature or the equivalent in other VCSes.\n\n    get_keywords_f = handlers.get(\"get_keywords\")\n    from_keywords_f = handlers.get(\"keywords\")\n    if get_keywords_f and from_keywords_f:\n        try:\n            keywords = get_keywords_f(versionfile_abs)\n            ver = from_keywords_f(keywords, cfg.tag_prefix, verbose)\n            if verbose:\n                print(\"got version from expanded keyword %s\" % ver)\n            return ver\n        except NotThisMethod:\n            pass\n\n    try:\n        ver = versions_from_file(versionfile_abs)\n        if verbose:\n            print(\"got version from file %s %s\" % (versionfile_abs, ver))\n        return ver\n    except NotThisMethod:\n        pass\n\n    from_vcs_f = handlers.get(\"pieces_from_vcs\")\n    if from_vcs_f:\n        try:\n            pieces = from_vcs_f(cfg.tag_prefix, root, verbose)\n            ver = render(pieces, cfg.style)\n            if verbose:\n                print(\"got version from VCS %s\" % ver)\n            return ver\n        except NotThisMethod:\n            pass\n\n    try:\n        if cfg.parentdir_prefix:\n            ver = versions_from_parentdir(cfg.parentdir_prefix, root, verbose)\n            if verbose:\n                print(\"got version from parentdir %s\" % ver)\n            return ver\n    except NotThisMethod:\n        pass\n\n    if verbose:\n        print(\"unable to compute version\")\n\n    return {\"version\": \"0+unknown\", \"full-revisionid\": None,\n            \"dirty\": None, \"error\": \"unable to compute version\",\n            \"date\": None}","function_tokens":["def","get_versions","(","verbose","=","False",")",":","if","\"versioneer\"","in","sys",".","modules",":","# see the discussion in cmdclass.py:get_cmdclass()","del","sys",".","modules","[","\"versioneer\"","]","root","=","get_root","(",")","cfg","=","get_config_from_root","(","root",")","assert","cfg",".","VCS","is","not","None",",","\"please set [versioneer]VCS= in setup.cfg\"","handlers","=","HANDLERS",".","get","(","cfg",".","VCS",")","assert","handlers",",","\"unrecognized VCS '%s'\"","%","cfg",".","VCS","verbose","=","verbose","or","cfg",".","verbose","assert","cfg",".","versionfile_source","is","not","None",",","\"please set versioneer.versionfile_source\"","assert","cfg",".","tag_prefix","is","not","None",",","\"please set versioneer.tag_prefix\"","versionfile_abs","=","os",".","path",".","join","(","root",",","cfg",".","versionfile_source",")","# extract version from first of: _version.py, VCS command (e.g. 'git","# describe'), parentdir. This is meant to work for developers using a","# source checkout, for users of a tarball created by 'setup.py sdist',","# and for users of a tarball\/zipball created by 'git archive' or github's","# download-from-tag feature or the equivalent in other VCSes.","get_keywords_f","=","handlers",".","get","(","\"get_keywords\"",")","from_keywords_f","=","handlers",".","get","(","\"keywords\"",")","if","get_keywords_f","and","from_keywords_f",":","try",":","keywords","=","get_keywords_f","(","versionfile_abs",")","ver","=","from_keywords_f","(","keywords",",","cfg",".","tag_prefix",",","verbose",")","if","verbose",":","print","(","\"got version from expanded keyword %s\"","%","ver",")","return","ver","except","NotThisMethod",":","pass","try",":","ver","=","versions_from_file","(","versionfile_abs",")","if","verbose",":","print","(","\"got version from file %s %s\"","%","(","versionfile_abs",",","ver",")",")","return","ver","except","NotThisMethod",":","pass","from_vcs_f","=","handlers",".","get","(","\"pieces_from_vcs\"",")","if","from_vcs_f",":","try",":","pieces","=","from_vcs_f","(","cfg",".","tag_prefix",",","root",",","verbose",")","ver","=","render","(","pieces",",","cfg",".","style",")","if","verbose",":","print","(","\"got version from VCS %s\"","%","ver",")","return","ver","except","NotThisMethod",":","pass","try",":","if","cfg",".","parentdir_prefix",":","ver","=","versions_from_parentdir","(","cfg",".","parentdir_prefix",",","root",",","verbose",")","if","verbose",":","print","(","\"got version from parentdir %s\"","%","ver",")","return","ver","except","NotThisMethod",":","pass","if","verbose",":","print","(","\"unable to compute version\"",")","return","{","\"version\"",":","\"0+unknown\"",",","\"full-revisionid\"",":","None",",","\"dirty\"",":","None",",","\"error\"",":","\"unable to compute version\"",",","\"date\"",":","None","}"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1402-L1475"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"get_version","parameters":"()","argument_list":"","return_statement":"return get_versions()[\"version\"]","docstring":"Get the short version string for this project.","docstring_summary":"Get the short version string for this project.","docstring_tokens":["Get","the","short","version","string","for","this","project","."],"function":"def get_version():\n    \"\"\"Get the short version string for this project.\"\"\"\n    return get_versions()[\"version\"]","function_tokens":["def","get_version","(",")",":","return","get_versions","(",")","[","\"version\"","]"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1478-L1480"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"get_cmdclass","parameters":"()","argument_list":"","return_statement":"return cmds","docstring":"Get the custom setuptools\/distutils subclasses used by Versioneer.","docstring_summary":"Get the custom setuptools\/distutils subclasses used by Versioneer.","docstring_tokens":["Get","the","custom","setuptools","\/","distutils","subclasses","used","by","Versioneer","."],"function":"def get_cmdclass():\n    \"\"\"Get the custom setuptools\/distutils subclasses used by Versioneer.\"\"\"\n    if \"versioneer\" in sys.modules:\n        del sys.modules[\"versioneer\"]\n        # this fixes the \"python setup.py develop\" case (also 'install' and\n        # 'easy_install .'), in which subdependencies of the main project are\n        # built (using setup.py bdist_egg) in the same python process. Assume\n        # a main project A and a dependency B, which use different versions\n        # of Versioneer. A's setup.py imports A's Versioneer, leaving it in\n        # sys.modules by the time B's setup.py is executed, causing B to run\n        # with the wrong versioneer. Setuptools wraps the sub-dep builds in a\n        # sandbox that restores sys.modules to it's pre-build state, so the\n        # parent is protected against the child's \"import versioneer\". By\n        # removing ourselves from sys.modules here, before the child build\n        # happens, we protect the child from the parent's versioneer too.\n        # Also see https:\/\/github.com\/warner\/python-versioneer\/issues\/52\n\n    cmds = {}\n\n    # we add \"version\" to both distutils and setuptools\n    from distutils.core import Command\n\n    class cmd_version(Command):\n        description = \"report generated version string\"\n        user_options = []\n        boolean_options = []\n\n        def initialize_options(self):\n            pass\n\n        def finalize_options(self):\n            pass\n\n        def run(self):\n            vers = get_versions(verbose=True)\n            print(\"Version: %s\" % vers[\"version\"])\n            print(\" full-revisionid: %s\" % vers.get(\"full-revisionid\"))\n            print(\" dirty: %s\" % vers.get(\"dirty\"))\n            print(\" date: %s\" % vers.get(\"date\"))\n            if vers[\"error\"]:\n                print(\" error: %s\" % vers[\"error\"])\n    cmds[\"version\"] = cmd_version\n\n    # we override \"build_py\" in both distutils and setuptools\n    #\n    # most invocation pathways end up running build_py:\n    #  distutils\/build -> build_py\n    #  distutils\/install -> distutils\/build ->..\n    #  setuptools\/bdist_wheel -> distutils\/install ->..\n    #  setuptools\/bdist_egg -> distutils\/install_lib -> build_py\n    #  setuptools\/install -> bdist_egg ->..\n    #  setuptools\/develop -> ?\n    #  pip install:\n    #   copies source tree to a tempdir before running egg_info\/etc\n    #   if .git isn't copied too, 'git describe' will fail\n    #   then does setup.py bdist_wheel, or sometimes setup.py install\n    #  setup.py egg_info -> ?\n\n    # we override different \"build_py\" commands for both environments\n    if \"setuptools\" in sys.modules:\n        from setuptools.command.build_py import build_py as _build_py\n    else:\n        from distutils.command.build_py import build_py as _build_py\n\n    class cmd_build_py(_build_py):\n        def run(self):\n            root = get_root()\n            cfg = get_config_from_root(root)\n            versions = get_versions()\n            _build_py.run(self)\n            # now locate _version.py in the new build\/ directory and replace\n            # it with an updated value\n            if cfg.versionfile_build:\n                target_versionfile = os.path.join(self.build_lib,\n                                                  cfg.versionfile_build)\n                print(\"UPDATING %s\" % target_versionfile)\n                write_to_version_file(target_versionfile, versions)\n    cmds[\"build_py\"] = cmd_build_py\n\n    if \"cx_Freeze\" in sys.modules:  # cx_freeze enabled?\n        from cx_Freeze.dist import build_exe as _build_exe\n        # nczeczulin reports that py2exe won't like the pep440-style string\n        # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g.\n        # setup(console=[{\n        #   \"version\": versioneer.get_version().split(\"+\", 1)[0], # FILEVERSION\n        #   \"product_version\": versioneer.get_version(),\n        #   ...\n\n        class cmd_build_exe(_build_exe):\n            def run(self):\n                root = get_root()\n                cfg = get_config_from_root(root)\n                versions = get_versions()\n                target_versionfile = cfg.versionfile_source\n                print(\"UPDATING %s\" % target_versionfile)\n                write_to_version_file(target_versionfile, versions)\n\n                _build_exe.run(self)\n                os.unlink(target_versionfile)\n                with open(cfg.versionfile_source, \"w\") as f:\n                    LONG = LONG_VERSION_PY[cfg.VCS]\n                    f.write(LONG %\n                            {\"DOLLAR\": \"$\",\n                             \"STYLE\": cfg.style,\n                             \"TAG_PREFIX\": cfg.tag_prefix,\n                             \"PARENTDIR_PREFIX\": cfg.parentdir_prefix,\n                             \"VERSIONFILE_SOURCE\": cfg.versionfile_source,\n                             })\n        cmds[\"build_exe\"] = cmd_build_exe\n        del cmds[\"build_py\"]\n\n    if 'py2exe' in sys.modules:  # py2exe enabled?\n        try:\n            from py2exe.distutils_buildexe import py2exe as _py2exe  # py3\n        except ImportError:\n            from py2exe.build_exe import py2exe as _py2exe  # py2\n\n        class cmd_py2exe(_py2exe):\n            def run(self):\n                root = get_root()\n                cfg = get_config_from_root(root)\n                versions = get_versions()\n                target_versionfile = cfg.versionfile_source\n                print(\"UPDATING %s\" % target_versionfile)\n                write_to_version_file(target_versionfile, versions)\n\n                _py2exe.run(self)\n                os.unlink(target_versionfile)\n                with open(cfg.versionfile_source, \"w\") as f:\n                    LONG = LONG_VERSION_PY[cfg.VCS]\n                    f.write(LONG %\n                            {\"DOLLAR\": \"$\",\n                             \"STYLE\": cfg.style,\n                             \"TAG_PREFIX\": cfg.tag_prefix,\n                             \"PARENTDIR_PREFIX\": cfg.parentdir_prefix,\n                             \"VERSIONFILE_SOURCE\": cfg.versionfile_source,\n                             })\n        cmds[\"py2exe\"] = cmd_py2exe\n\n    # we override different \"sdist\" commands for both environments\n    if \"setuptools\" in sys.modules:\n        from setuptools.command.sdist import sdist as _sdist\n    else:\n        from distutils.command.sdist import sdist as _sdist\n\n    class cmd_sdist(_sdist):\n        def run(self):\n            versions = get_versions()\n            self._versioneer_generated_versions = versions\n            # unless we update this, the command will keep using the old\n            # version\n            self.distribution.metadata.version = versions[\"version\"]\n            return _sdist.run(self)\n\n        def make_release_tree(self, base_dir, files):\n            root = get_root()\n            cfg = get_config_from_root(root)\n            _sdist.make_release_tree(self, base_dir, files)\n            # now locate _version.py in the new base_dir directory\n            # (remembering that it may be a hardlink) and replace it with an\n            # updated value\n            target_versionfile = os.path.join(base_dir, cfg.versionfile_source)\n            print(\"UPDATING %s\" % target_versionfile)\n            write_to_version_file(target_versionfile,\n                                  self._versioneer_generated_versions)\n    cmds[\"sdist\"] = cmd_sdist\n\n    return cmds","function_tokens":["def","get_cmdclass","(",")",":","if","\"versioneer\"","in","sys",".","modules",":","del","sys",".","modules","[","\"versioneer\"","]","# this fixes the \"python setup.py develop\" case (also 'install' and","# 'easy_install .'), in which subdependencies of the main project are","# built (using setup.py bdist_egg) in the same python process. Assume","# a main project A and a dependency B, which use different versions","# of Versioneer. A's setup.py imports A's Versioneer, leaving it in","# sys.modules by the time B's setup.py is executed, causing B to run","# with the wrong versioneer. Setuptools wraps the sub-dep builds in a","# sandbox that restores sys.modules to it's pre-build state, so the","# parent is protected against the child's \"import versioneer\". By","# removing ourselves from sys.modules here, before the child build","# happens, we protect the child from the parent's versioneer too.","# Also see https:\/\/github.com\/warner\/python-versioneer\/issues\/52","cmds","=","{","}","# we add \"version\" to both distutils and setuptools","from","distutils",".","core","import","Command","class","cmd_version","(","Command",")",":","description","=","\"report generated version string\"","user_options","=","[","]","boolean_options","=","[","]","def","initialize_options","(","self",")",":","pass","def","finalize_options","(","self",")",":","pass","def","run","(","self",")",":","vers","=","get_versions","(","verbose","=","True",")","print","(","\"Version: %s\"","%","vers","[","\"version\"","]",")","print","(","\" full-revisionid: %s\"","%","vers",".","get","(","\"full-revisionid\"",")",")","print","(","\" dirty: %s\"","%","vers",".","get","(","\"dirty\"",")",")","print","(","\" date: %s\"","%","vers",".","get","(","\"date\"",")",")","if","vers","[","\"error\"","]",":","print","(","\" error: %s\"","%","vers","[","\"error\"","]",")","cmds","[","\"version\"","]","=","cmd_version","# we override \"build_py\" in both distutils and setuptools","#","# most invocation pathways end up running build_py:","#  distutils\/build -> build_py","#  distutils\/install -> distutils\/build ->..","#  setuptools\/bdist_wheel -> distutils\/install ->..","#  setuptools\/bdist_egg -> distutils\/install_lib -> build_py","#  setuptools\/install -> bdist_egg ->..","#  setuptools\/develop -> ?","#  pip install:","#   copies source tree to a tempdir before running egg_info\/etc","#   if .git isn't copied too, 'git describe' will fail","#   then does setup.py bdist_wheel, or sometimes setup.py install","#  setup.py egg_info -> ?","# we override different \"build_py\" commands for both environments","if","\"setuptools\"","in","sys",".","modules",":","from","setuptools",".","command",".","build_py","import","build_py","as","_build_py","else",":","from","distutils",".","command",".","build_py","import","build_py","as","_build_py","class","cmd_build_py","(","_build_py",")",":","def","run","(","self",")",":","root","=","get_root","(",")","cfg","=","get_config_from_root","(","root",")","versions","=","get_versions","(",")","_build_py",".","run","(","self",")","# now locate _version.py in the new build\/ directory and replace","# it with an updated value","if","cfg",".","versionfile_build",":","target_versionfile","=","os",".","path",".","join","(","self",".","build_lib",",","cfg",".","versionfile_build",")","print","(","\"UPDATING %s\"","%","target_versionfile",")","write_to_version_file","(","target_versionfile",",","versions",")","cmds","[","\"build_py\"","]","=","cmd_build_py","if","\"cx_Freeze\"","in","sys",".","modules",":","# cx_freeze enabled?","from","cx_Freeze",".","dist","import","build_exe","as","_build_exe","# nczeczulin reports that py2exe won't like the pep440-style string","# as FILEVERSION, but it can be used for PRODUCTVERSION, e.g.","# setup(console=[{","#   \"version\": versioneer.get_version().split(\"+\", 1)[0], # FILEVERSION","#   \"product_version\": versioneer.get_version(),","#   ...","class","cmd_build_exe","(","_build_exe",")",":","def","run","(","self",")",":","root","=","get_root","(",")","cfg","=","get_config_from_root","(","root",")","versions","=","get_versions","(",")","target_versionfile","=","cfg",".","versionfile_source","print","(","\"UPDATING %s\"","%","target_versionfile",")","write_to_version_file","(","target_versionfile",",","versions",")","_build_exe",".","run","(","self",")","os",".","unlink","(","target_versionfile",")","with","open","(","cfg",".","versionfile_source",",","\"w\"",")","as","f",":","LONG","=","LONG_VERSION_PY","[","cfg",".","VCS","]","f",".","write","(","LONG","%","{","\"DOLLAR\"",":","\"$\"",",","\"STYLE\"",":","cfg",".","style",",","\"TAG_PREFIX\"",":","cfg",".","tag_prefix",",","\"PARENTDIR_PREFIX\"",":","cfg",".","parentdir_prefix",",","\"VERSIONFILE_SOURCE\"",":","cfg",".","versionfile_source",",","}",")","cmds","[","\"build_exe\"","]","=","cmd_build_exe","del","cmds","[","\"build_py\"","]","if","'py2exe'","in","sys",".","modules",":","# py2exe enabled?","try",":","from","py2exe",".","distutils_buildexe","import","py2exe","as","_py2exe","# py3","except","ImportError",":","from","py2exe",".","build_exe","import","py2exe","as","_py2exe","# py2","class","cmd_py2exe","(","_py2exe",")",":","def","run","(","self",")",":","root","=","get_root","(",")","cfg","=","get_config_from_root","(","root",")","versions","=","get_versions","(",")","target_versionfile","=","cfg",".","versionfile_source","print","(","\"UPDATING %s\"","%","target_versionfile",")","write_to_version_file","(","target_versionfile",",","versions",")","_py2exe",".","run","(","self",")","os",".","unlink","(","target_versionfile",")","with","open","(","cfg",".","versionfile_source",",","\"w\"",")","as","f",":","LONG","=","LONG_VERSION_PY","[","cfg",".","VCS","]","f",".","write","(","LONG","%","{","\"DOLLAR\"",":","\"$\"",",","\"STYLE\"",":","cfg",".","style",",","\"TAG_PREFIX\"",":","cfg",".","tag_prefix",",","\"PARENTDIR_PREFIX\"",":","cfg",".","parentdir_prefix",",","\"VERSIONFILE_SOURCE\"",":","cfg",".","versionfile_source",",","}",")","cmds","[","\"py2exe\"","]","=","cmd_py2exe","# we override different \"sdist\" commands for both environments","if","\"setuptools\"","in","sys",".","modules",":","from","setuptools",".","command",".","sdist","import","sdist","as","_sdist","else",":","from","distutils",".","command",".","sdist","import","sdist","as","_sdist","class","cmd_sdist","(","_sdist",")",":","def","run","(","self",")",":","versions","=","get_versions","(",")","self",".","_versioneer_generated_versions","=","versions","# unless we update this, the command will keep using the old","# version","self",".","distribution",".","metadata",".","version","=","versions","[","\"version\"","]","return","_sdist",".","run","(","self",")","def","make_release_tree","(","self",",","base_dir",",","files",")",":","root","=","get_root","(",")","cfg","=","get_config_from_root","(","root",")","_sdist",".","make_release_tree","(","self",",","base_dir",",","files",")","# now locate _version.py in the new base_dir directory","# (remembering that it may be a hardlink) and replace it with an","# updated value","target_versionfile","=","os",".","path",".","join","(","base_dir",",","cfg",".","versionfile_source",")","print","(","\"UPDATING %s\"","%","target_versionfile",")","write_to_version_file","(","target_versionfile",",","self",".","_versioneer_generated_versions",")","cmds","[","\"sdist\"","]","=","cmd_sdist","return","cmds"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1483-L1650"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"do_setup","parameters":"()","argument_list":"","return_statement":"return 0","docstring":"Main VCS-independent setup function for installing Versioneer.","docstring_summary":"Main VCS-independent setup function for installing Versioneer.","docstring_tokens":["Main","VCS","-","independent","setup","function","for","installing","Versioneer","."],"function":"def do_setup():\n    \"\"\"Main VCS-independent setup function for installing Versioneer.\"\"\"\n    root = get_root()\n    try:\n        cfg = get_config_from_root(root)\n    except (EnvironmentError, configparser.NoSectionError,\n            configparser.NoOptionError) as e:\n        if isinstance(e, (EnvironmentError, configparser.NoSectionError)):\n            print(\"Adding sample versioneer config to setup.cfg\",\n                  file=sys.stderr)\n            with open(os.path.join(root, \"setup.cfg\"), \"a\") as f:\n                f.write(SAMPLE_CONFIG)\n        print(CONFIG_ERROR, file=sys.stderr)\n        return 1\n\n    print(\" creating %s\" % cfg.versionfile_source)\n    with open(cfg.versionfile_source, \"w\") as f:\n        LONG = LONG_VERSION_PY[cfg.VCS]\n        f.write(LONG % {\"DOLLAR\": \"$\",\n                        \"STYLE\": cfg.style,\n                        \"TAG_PREFIX\": cfg.tag_prefix,\n                        \"PARENTDIR_PREFIX\": cfg.parentdir_prefix,\n                        \"VERSIONFILE_SOURCE\": cfg.versionfile_source,\n                        })\n\n    ipy = os.path.join(os.path.dirname(cfg.versionfile_source),\n                       \"__init__.py\")\n    if os.path.exists(ipy):\n        try:\n            with open(ipy, \"r\") as f:\n                old = f.read()\n        except EnvironmentError:\n            old = \"\"\n        if INIT_PY_SNIPPET not in old:\n            print(\" appending to %s\" % ipy)\n            with open(ipy, \"a\") as f:\n                f.write(INIT_PY_SNIPPET)\n        else:\n            print(\" %s unmodified\" % ipy)\n    else:\n        print(\" %s doesn't exist, ok\" % ipy)\n        ipy = None\n\n    # Make sure both the top-level \"versioneer.py\" and versionfile_source\n    # (PKG\/_version.py, used by runtime code) are in MANIFEST.in, so\n    # they'll be copied into source distributions. Pip won't be able to\n    # install the package without this.\n    manifest_in = os.path.join(root, \"MANIFEST.in\")\n    simple_includes = set()\n    try:\n        with open(manifest_in, \"r\") as f:\n            for line in f:\n                if line.startswith(\"include \"):\n                    for include in line.split()[1:]:\n                        simple_includes.add(include)\n    except EnvironmentError:\n        pass\n    # That doesn't cover everything MANIFEST.in can do\n    # (http:\/\/docs.python.org\/2\/distutils\/sourcedist.html#commands), so\n    # it might give some false negatives. Appending redundant 'include'\n    # lines is safe, though.\n    if \"versioneer.py\" not in simple_includes:\n        print(\" appending 'versioneer.py' to MANIFEST.in\")\n        with open(manifest_in, \"a\") as f:\n            f.write(\"include versioneer.py\\n\")\n    else:\n        print(\" 'versioneer.py' already in MANIFEST.in\")\n    if cfg.versionfile_source not in simple_includes:\n        print(\" appending versionfile_source ('%s') to MANIFEST.in\" %\n              cfg.versionfile_source)\n        with open(manifest_in, \"a\") as f:\n            f.write(\"include %s\\n\" % cfg.versionfile_source)\n    else:\n        print(\" versionfile_source already in MANIFEST.in\")\n\n    # Make VCS-specific changes. For git, this means creating\/changing\n    # .gitattributes to mark _version.py for export-subst keyword\n    # substitution.\n    do_vcs_install(manifest_in, cfg.versionfile_source, ipy)\n    return 0","function_tokens":["def","do_setup","(",")",":","root","=","get_root","(",")","try",":","cfg","=","get_config_from_root","(","root",")","except","(","EnvironmentError",",","configparser",".","NoSectionError",",","configparser",".","NoOptionError",")","as","e",":","if","isinstance","(","e",",","(","EnvironmentError",",","configparser",".","NoSectionError",")",")",":","print","(","\"Adding sample versioneer config to setup.cfg\"",",","file","=","sys",".","stderr",")","with","open","(","os",".","path",".","join","(","root",",","\"setup.cfg\"",")",",","\"a\"",")","as","f",":","f",".","write","(","SAMPLE_CONFIG",")","print","(","CONFIG_ERROR",",","file","=","sys",".","stderr",")","return","1","print","(","\" creating %s\"","%","cfg",".","versionfile_source",")","with","open","(","cfg",".","versionfile_source",",","\"w\"",")","as","f",":","LONG","=","LONG_VERSION_PY","[","cfg",".","VCS","]","f",".","write","(","LONG","%","{","\"DOLLAR\"",":","\"$\"",",","\"STYLE\"",":","cfg",".","style",",","\"TAG_PREFIX\"",":","cfg",".","tag_prefix",",","\"PARENTDIR_PREFIX\"",":","cfg",".","parentdir_prefix",",","\"VERSIONFILE_SOURCE\"",":","cfg",".","versionfile_source",",","}",")","ipy","=","os",".","path",".","join","(","os",".","path",".","dirname","(","cfg",".","versionfile_source",")",",","\"__init__.py\"",")","if","os",".","path",".","exists","(","ipy",")",":","try",":","with","open","(","ipy",",","\"r\"",")","as","f",":","old","=","f",".","read","(",")","except","EnvironmentError",":","old","=","\"\"","if","INIT_PY_SNIPPET","not","in","old",":","print","(","\" appending to %s\"","%","ipy",")","with","open","(","ipy",",","\"a\"",")","as","f",":","f",".","write","(","INIT_PY_SNIPPET",")","else",":","print","(","\" %s unmodified\"","%","ipy",")","else",":","print","(","\" %s doesn't exist, ok\"","%","ipy",")","ipy","=","None","# Make sure both the top-level \"versioneer.py\" and versionfile_source","# (PKG\/_version.py, used by runtime code) are in MANIFEST.in, so","# they'll be copied into source distributions. Pip won't be able to","# install the package without this.","manifest_in","=","os",".","path",".","join","(","root",",","\"MANIFEST.in\"",")","simple_includes","=","set","(",")","try",":","with","open","(","manifest_in",",","\"r\"",")","as","f",":","for","line","in","f",":","if","line",".","startswith","(","\"include \"",")",":","for","include","in","line",".","split","(",")","[","1",":","]",":","simple_includes",".","add","(","include",")","except","EnvironmentError",":","pass","# That doesn't cover everything MANIFEST.in can do","# (http:\/\/docs.python.org\/2\/distutils\/sourcedist.html#commands), so","# it might give some false negatives. Appending redundant 'include'","# lines is safe, though.","if","\"versioneer.py\"","not","in","simple_includes",":","print","(","\" appending 'versioneer.py' to MANIFEST.in\"",")","with","open","(","manifest_in",",","\"a\"",")","as","f",":","f",".","write","(","\"include versioneer.py\\n\"",")","else",":","print","(","\" 'versioneer.py' already in MANIFEST.in\"",")","if","cfg",".","versionfile_source","not","in","simple_includes",":","print","(","\" appending versionfile_source ('%s') to MANIFEST.in\"","%","cfg",".","versionfile_source",")","with","open","(","manifest_in",",","\"a\"",")","as","f",":","f",".","write","(","\"include %s\\n\"","%","cfg",".","versionfile_source",")","else",":","print","(","\" versionfile_source already in MANIFEST.in\"",")","# Make VCS-specific changes. For git, this means creating\/changing","# .gitattributes to mark _version.py for export-subst keyword","# substitution.","do_vcs_install","(","manifest_in",",","cfg",".","versionfile_source",",","ipy",")","return","0"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1697-L1776"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"versioneer.py","language":"python","identifier":"scan_setup_py","parameters":"()","argument_list":"","return_statement":"return errors","docstring":"Validate the contents of setup.py against Versioneer's expectations.","docstring_summary":"Validate the contents of setup.py against Versioneer's expectations.","docstring_tokens":["Validate","the","contents","of","setup",".","py","against","Versioneer","s","expectations","."],"function":"def scan_setup_py():\n    \"\"\"Validate the contents of setup.py against Versioneer's expectations.\"\"\"\n    found = set()\n    setters = False\n    errors = 0\n    with open(\"setup.py\", \"r\") as f:\n        for line in f.readlines():\n            if \"import versioneer\" in line:\n                found.add(\"import\")\n            if \"versioneer.get_cmdclass()\" in line:\n                found.add(\"cmdclass\")\n            if \"versioneer.get_version()\" in line:\n                found.add(\"get_version\")\n            if \"versioneer.VCS\" in line:\n                setters = True\n            if \"versioneer.versionfile_source\" in line:\n                setters = True\n    if len(found) != 3:\n        print(\"\")\n        print(\"Your setup.py appears to be missing some important items\")\n        print(\"(but I might be wrong). Please make sure it has something\")\n        print(\"roughly like the following:\")\n        print(\"\")\n        print(\" import versioneer\")\n        print(\" setup( version=versioneer.get_version(),\")\n        print(\"        cmdclass=versioneer.get_cmdclass(),  ...)\")\n        print(\"\")\n        errors += 1\n    if setters:\n        print(\"You should remove lines like 'versioneer.VCS = ' and\")\n        print(\"'versioneer.versionfile_source = ' . This configuration\")\n        print(\"now lives in setup.cfg, and should be removed from setup.py\")\n        print(\"\")\n        errors += 1\n    return errors","function_tokens":["def","scan_setup_py","(",")",":","found","=","set","(",")","setters","=","False","errors","=","0","with","open","(","\"setup.py\"",",","\"r\"",")","as","f",":","for","line","in","f",".","readlines","(",")",":","if","\"import versioneer\"","in","line",":","found",".","add","(","\"import\"",")","if","\"versioneer.get_cmdclass()\"","in","line",":","found",".","add","(","\"cmdclass\"",")","if","\"versioneer.get_version()\"","in","line",":","found",".","add","(","\"get_version\"",")","if","\"versioneer.VCS\"","in","line",":","setters","=","True","if","\"versioneer.versionfile_source\"","in","line",":","setters","=","True","if","len","(","found",")","!=","3",":","print","(","\"\"",")","print","(","\"Your setup.py appears to be missing some important items\"",")","print","(","\"(but I might be wrong). Please make sure it has something\"",")","print","(","\"roughly like the following:\"",")","print","(","\"\"",")","print","(","\" import versioneer\"",")","print","(","\" setup( version=versioneer.get_version(),\"",")","print","(","\"        cmdclass=versioneer.get_cmdclass(),  ...)\"",")","print","(","\"\"",")","errors","+=","1","if","setters",":","print","(","\"You should remove lines like 'versioneer.VCS = ' and\"",")","print","(","\"'versioneer.versionfile_source = ' . This configuration\"",")","print","(","\"now lives in setup.cfg, and should be removed from setup.py\"",")","print","(","\"\"",")","errors","+=","1","return","errors"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/versioneer.py#L1779-L1813"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/envmanager.py","language":"python","identifier":"EnvManager.list_envs","parameters":"(self)","argument_list":"","return_statement":"return {\n            \"environments\": [root_env] + [get_info(env)\n                                          for env in info['envs']]\n        }","docstring":"List all environments that conda knows about","docstring_summary":"List all environments that conda knows about","docstring_tokens":["List","all","environments","that","conda","knows","about"],"function":"def list_envs(self):\n        \"\"\"List all environments that conda knows about\"\"\"\n        info = self.clean_conda_json(self._execute('conda info --json'))\n        default_env = info['default_prefix']\n\n        root_env = {\n                'name': 'root',\n                'dir': info['root_prefix'],\n                'is_default': info['root_prefix'] == default_env\n        }\n\n        def get_info(env):\n            return {\n                'name': os.path.basename(env),\n                'dir': env,\n                'is_default': env == default_env\n            }\n\n        return {\n            \"environments\": [root_env] + [get_info(env)\n                                          for env in info['envs']]\n        }","function_tokens":["def","list_envs","(","self",")",":","info","=","self",".","clean_conda_json","(","self",".","_execute","(","'conda info --json'",")",")","default_env","=","info","[","'default_prefix'","]","root_env","=","{","'name'",":","'root'",",","'dir'",":","info","[","'root_prefix'","]",",","'is_default'",":","info","[","'root_prefix'","]","==","default_env","}","def","get_info","(","env",")",":","return","{","'name'",":","os",".","path",".","basename","(","env",")",",","'dir'",":","env",",","'is_default'",":","env","==","default_env","}","return","{","\"environments\"",":","[","root_env","]","+","[","get_info","(","env",")","for","env","in","info","[","'envs'","]","]","}"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/envmanager.py#L65-L86"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"get_keywords","parameters":"()","argument_list":"","return_statement":"return keywords","docstring":"Get the keywords needed to look up the version information.","docstring_summary":"Get the keywords needed to look up the version information.","docstring_tokens":["Get","the","keywords","needed","to","look","up","the","version","information","."],"function":"def get_keywords():\n    \"\"\"Get the keywords needed to look up the version information.\"\"\"\n    # these strings will be replaced by git during git-archive.\n    # setup.py\/versioneer.py will grep for the variable names, so they must\n    # each be defined on a line of their own. _version.py will just call\n    # get_keywords().\n    git_refnames = \"$Format:%d$\"\n    git_full = \"$Format:%H$\"\n    git_date = \"$Format:%ci$\"\n    keywords = {\"refnames\": git_refnames, \"full\": git_full, \"date\": git_date}\n    return keywords","function_tokens":["def","get_keywords","(",")",":","# these strings will be replaced by git during git-archive.","# setup.py\/versioneer.py will grep for the variable names, so they must","# each be defined on a line of their own. _version.py will just call","# get_keywords().","git_refnames","=","\"$Format:%d$\"","git_full","=","\"$Format:%H$\"","git_date","=","\"$Format:%ci$\"","keywords","=","{","\"refnames\"",":","git_refnames",",","\"full\"",":","git_full",",","\"date\"",":","git_date","}","return","keywords"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L20-L30"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"get_config","parameters":"()","argument_list":"","return_statement":"return cfg","docstring":"Create, populate and return the VersioneerConfig() object.","docstring_summary":"Create, populate and return the VersioneerConfig() object.","docstring_tokens":["Create","populate","and","return","the","VersioneerConfig","()","object","."],"function":"def get_config():\n    \"\"\"Create, populate and return the VersioneerConfig() object.\"\"\"\n    # these strings are filled in when 'setup.py versioneer' creates\n    # _version.py\n    cfg = VersioneerConfig()\n    cfg.VCS = \"git\"\n    cfg.style = \"pep440\"\n    cfg.tag_prefix = \"\"\n    cfg.parentdir_prefix = \"nb_conda-\"\n    cfg.versionfile_source = \"nb_conda\/_version.py\"\n    cfg.verbose = False\n    return cfg","function_tokens":["def","get_config","(",")",":","# these strings are filled in when 'setup.py versioneer' creates","# _version.py","cfg","=","VersioneerConfig","(",")","cfg",".","VCS","=","\"git\"","cfg",".","style","=","\"pep440\"","cfg",".","tag_prefix","=","\"\"","cfg",".","parentdir_prefix","=","\"nb_conda-\"","cfg",".","versionfile_source","=","\"nb_conda\/_version.py\"","cfg",".","verbose","=","False","return","cfg"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L37-L48"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"register_vcs_handler","parameters":"(vcs, method)","argument_list":"","return_statement":"return decorate","docstring":"Decorator to mark a method as the handler for a particular VCS.","docstring_summary":"Decorator to mark a method as the handler for a particular VCS.","docstring_tokens":["Decorator","to","mark","a","method","as","the","handler","for","a","particular","VCS","."],"function":"def register_vcs_handler(vcs, method):  # decorator\n    \"\"\"Decorator to mark a method as the handler for a particular VCS.\"\"\"\n    def decorate(f):\n        \"\"\"Store f in HANDLERS[vcs][method].\"\"\"\n        if vcs not in HANDLERS:\n            HANDLERS[vcs] = {}\n        HANDLERS[vcs][method] = f\n        return f\n    return decorate","function_tokens":["def","register_vcs_handler","(","vcs",",","method",")",":","# decorator","def","decorate","(","f",")",":","\"\"\"Store f in HANDLERS[vcs][method].\"\"\"","if","vcs","not","in","HANDLERS",":","HANDLERS","[","vcs","]","=","{","}","HANDLERS","[","vcs","]","[","method","]","=","f","return","f","return","decorate"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L59-L67"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"run_command","parameters":"(commands, args, cwd=None, verbose=False, hide_stderr=False,\n                env=None)","argument_list":"","return_statement":"return stdout, p.returncode","docstring":"Call the given command(s).","docstring_summary":"Call the given command(s).","docstring_tokens":["Call","the","given","command","(","s",")","."],"function":"def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,\n                env=None):\n    \"\"\"Call the given command(s).\"\"\"\n    assert isinstance(commands, list)\n    p = None\n    for c in commands:\n        try:\n            dispcmd = str([c] + args)\n            # remember shell=False, so use git.cmd on windows, not just git\n            p = subprocess.Popen([c] + args, cwd=cwd, env=env,\n                                 stdout=subprocess.PIPE,\n                                 stderr=(subprocess.PIPE if hide_stderr\n                                         else None))\n            break\n        except EnvironmentError:\n            e = sys.exc_info()[1]\n            if e.errno == errno.ENOENT:\n                continue\n            if verbose:\n                print(\"unable to run %s\" % dispcmd)\n                print(e)\n            return None, None\n    else:\n        if verbose:\n            print(\"unable to find command, tried %s\" % (commands,))\n        return None, None\n    stdout = p.communicate()[0].strip()\n    if sys.version_info[0] >= 3:\n        stdout = stdout.decode()\n    if p.returncode != 0:\n        if verbose:\n            print(\"unable to run %s (error)\" % dispcmd)\n            print(\"stdout was %s\" % stdout)\n        return None, p.returncode\n    return stdout, p.returncode","function_tokens":["def","run_command","(","commands",",","args",",","cwd","=","None",",","verbose","=","False",",","hide_stderr","=","False",",","env","=","None",")",":","assert","isinstance","(","commands",",","list",")","p","=","None","for","c","in","commands",":","try",":","dispcmd","=","str","(","[","c","]","+","args",")","# remember shell=False, so use git.cmd on windows, not just git","p","=","subprocess",".","Popen","(","[","c","]","+","args",",","cwd","=","cwd",",","env","=","env",",","stdout","=","subprocess",".","PIPE",",","stderr","=","(","subprocess",".","PIPE","if","hide_stderr","else","None",")",")","break","except","EnvironmentError",":","e","=","sys",".","exc_info","(",")","[","1","]","if","e",".","errno","==","errno",".","ENOENT",":","continue","if","verbose",":","print","(","\"unable to run %s\"","%","dispcmd",")","print","(","e",")","return","None",",","None","else",":","if","verbose",":","print","(","\"unable to find command, tried %s\"","%","(","commands",",",")",")","return","None",",","None","stdout","=","p",".","communicate","(",")","[","0","]",".","strip","(",")","if","sys",".","version_info","[","0","]",">=","3",":","stdout","=","stdout",".","decode","(",")","if","p",".","returncode","!=","0",":","if","verbose",":","print","(","\"unable to run %s (error)\"","%","dispcmd",")","print","(","\"stdout was %s\"","%","stdout",")","return","None",",","p",".","returncode","return","stdout",",","p",".","returncode"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L70-L104"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"versions_from_parentdir","parameters":"(parentdir_prefix, root, verbose)","argument_list":"","return_statement":"","docstring":"Try to determine the version from the parent directory name.\n\n    Source tarballs conventionally unpack into a directory that includes both\n    the project name and a version string. We will also support searching up\n    two directory levels for an appropriately named parent directory","docstring_summary":"Try to determine the version from the parent directory name.","docstring_tokens":["Try","to","determine","the","version","from","the","parent","directory","name","."],"function":"def versions_from_parentdir(parentdir_prefix, root, verbose):\n    \"\"\"Try to determine the version from the parent directory name.\n\n    Source tarballs conventionally unpack into a directory that includes both\n    the project name and a version string. We will also support searching up\n    two directory levels for an appropriately named parent directory\n    \"\"\"\n    rootdirs = []\n\n    for i in range(3):\n        dirname = os.path.basename(root)\n        if dirname.startswith(parentdir_prefix):\n            return {\"version\": dirname[len(parentdir_prefix):],\n                    \"full-revisionid\": None,\n                    \"dirty\": False, \"error\": None, \"date\": None}\n        else:\n            rootdirs.append(root)\n            root = os.path.dirname(root)  # up a level\n\n    if verbose:\n        print(\"Tried directories %s but none started with prefix %s\" %\n              (str(rootdirs), parentdir_prefix))\n    raise NotThisMethod(\"rootdir doesn't start with parentdir_prefix\")","function_tokens":["def","versions_from_parentdir","(","parentdir_prefix",",","root",",","verbose",")",":","rootdirs","=","[","]","for","i","in","range","(","3",")",":","dirname","=","os",".","path",".","basename","(","root",")","if","dirname",".","startswith","(","parentdir_prefix",")",":","return","{","\"version\"",":","dirname","[","len","(","parentdir_prefix",")",":","]",",","\"full-revisionid\"",":","None",",","\"dirty\"",":","False",",","\"error\"",":","None",",","\"date\"",":","None","}","else",":","rootdirs",".","append","(","root",")","root","=","os",".","path",".","dirname","(","root",")","# up a level","if","verbose",":","print","(","\"Tried directories %s but none started with prefix %s\"","%","(","str","(","rootdirs",")",",","parentdir_prefix",")",")","raise","NotThisMethod","(","\"rootdir doesn't start with parentdir_prefix\"",")"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L107-L129"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"git_get_keywords","parameters":"(versionfile_abs)","argument_list":"","return_statement":"return keywords","docstring":"Extract version information from the given file.","docstring_summary":"Extract version information from the given file.","docstring_tokens":["Extract","version","information","from","the","given","file","."],"function":"def git_get_keywords(versionfile_abs):\n    \"\"\"Extract version information from the given file.\"\"\"\n    # the code embedded in _version.py can just fetch the value of these\n    # keywords. When used from setup.py, we don't want to import _version.py,\n    # so we do it with a regexp instead. This function is not used from\n    # _version.py.\n    keywords = {}\n    try:\n        f = open(versionfile_abs, \"r\")\n        for line in f.readlines():\n            if line.strip().startswith(\"git_refnames =\"):\n                mo = re.search(r'=\\s*\"(.*)\"', line)\n                if mo:\n                    keywords[\"refnames\"] = mo.group(1)\n            if line.strip().startswith(\"git_full =\"):\n                mo = re.search(r'=\\s*\"(.*)\"', line)\n                if mo:\n                    keywords[\"full\"] = mo.group(1)\n            if line.strip().startswith(\"git_date =\"):\n                mo = re.search(r'=\\s*\"(.*)\"', line)\n                if mo:\n                    keywords[\"date\"] = mo.group(1)\n        f.close()\n    except EnvironmentError:\n        pass\n    return keywords","function_tokens":["def","git_get_keywords","(","versionfile_abs",")",":","# the code embedded in _version.py can just fetch the value of these","# keywords. When used from setup.py, we don't want to import _version.py,","# so we do it with a regexp instead. This function is not used from","# _version.py.","keywords","=","{","}","try",":","f","=","open","(","versionfile_abs",",","\"r\"",")","for","line","in","f",".","readlines","(",")",":","if","line",".","strip","(",")",".","startswith","(","\"git_refnames =\"",")",":","mo","=","re",".","search","(","r'=\\s*\"(.*)\"'",",","line",")","if","mo",":","keywords","[","\"refnames\"","]","=","mo",".","group","(","1",")","if","line",".","strip","(",")",".","startswith","(","\"git_full =\"",")",":","mo","=","re",".","search","(","r'=\\s*\"(.*)\"'",",","line",")","if","mo",":","keywords","[","\"full\"","]","=","mo",".","group","(","1",")","if","line",".","strip","(",")",".","startswith","(","\"git_date =\"",")",":","mo","=","re",".","search","(","r'=\\s*\"(.*)\"'",",","line",")","if","mo",":","keywords","[","\"date\"","]","=","mo",".","group","(","1",")","f",".","close","(",")","except","EnvironmentError",":","pass","return","keywords"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L133-L158"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"git_versions_from_keywords","parameters":"(keywords, tag_prefix, verbose)","argument_list":"","return_statement":"return {\"version\": \"0+unknown\",\n            \"full-revisionid\": keywords[\"full\"].strip(),\n            \"dirty\": False, \"error\": \"no suitable tags\", \"date\": None}","docstring":"Get version information from git keywords.","docstring_summary":"Get version information from git keywords.","docstring_tokens":["Get","version","information","from","git","keywords","."],"function":"def git_versions_from_keywords(keywords, tag_prefix, verbose):\n    \"\"\"Get version information from git keywords.\"\"\"\n    if not keywords:\n        raise NotThisMethod(\"no keywords at all, weird\")\n    date = keywords.get(\"date\")\n    if date is not None:\n        # git-2.2.0 added \"%cI\", which expands to an ISO-8601 -compliant\n        # datestamp. However we prefer \"%ci\" (which expands to an \"ISO-8601\n        # -like\" string, which we must then edit to make compliant), because\n        # it's been around since git-1.5.3, and it's too difficult to\n        # discover which version we're using, or to work around using an\n        # older one.\n        date = date.strip().replace(\" \", \"T\", 1).replace(\" \", \"\", 1)\n    refnames = keywords[\"refnames\"].strip()\n    if refnames.startswith(\"$Format\"):\n        if verbose:\n            print(\"keywords are unexpanded, not using\")\n        raise NotThisMethod(\"unexpanded keywords, not a git-archive tarball\")\n    refs = set([r.strip() for r in refnames.strip(\"()\").split(\",\")])\n    # starting in git-1.8.3, tags are listed as \"tag: foo-1.0\" instead of\n    # just \"foo-1.0\". If we see a \"tag: \" prefix, prefer those.\n    TAG = \"tag: \"\n    tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])\n    if not tags:\n        # Either we're using git < 1.8.3, or there really are no tags. We use\n        # a heuristic: assume all version tags have a digit. The old git %d\n        # expansion behaves like git log --decorate=short and strips out the\n        # refs\/heads\/ and refs\/tags\/ prefixes that would let us distinguish\n        # between branches and tags. By ignoring refnames without digits, we\n        # filter out many common branch names like \"release\" and\n        # \"stabilization\", as well as \"HEAD\" and \"master\".\n        tags = set([r for r in refs if re.search(r'\\d', r)])\n        if verbose:\n            print(\"discarding '%s', no digits\" % \",\".join(refs - tags))\n    if verbose:\n        print(\"likely tags: %s\" % \",\".join(sorted(tags)))\n    for ref in sorted(tags):\n        # sorting will prefer e.g. \"2.0\" over \"2.0rc1\"\n        if ref.startswith(tag_prefix):\n            r = ref[len(tag_prefix):]\n            if verbose:\n                print(\"picking %s\" % r)\n            return {\"version\": r,\n                    \"full-revisionid\": keywords[\"full\"].strip(),\n                    \"dirty\": False, \"error\": None,\n                    \"date\": date}\n    # no suitable tags, so version is \"0+unknown\", but full hex is still there\n    if verbose:\n        print(\"no suitable tags, using unknown + full revision id\")\n    return {\"version\": \"0+unknown\",\n            \"full-revisionid\": keywords[\"full\"].strip(),\n            \"dirty\": False, \"error\": \"no suitable tags\", \"date\": None}","function_tokens":["def","git_versions_from_keywords","(","keywords",",","tag_prefix",",","verbose",")",":","if","not","keywords",":","raise","NotThisMethod","(","\"no keywords at all, weird\"",")","date","=","keywords",".","get","(","\"date\"",")","if","date","is","not","None",":","# git-2.2.0 added \"%cI\", which expands to an ISO-8601 -compliant","# datestamp. However we prefer \"%ci\" (which expands to an \"ISO-8601","# -like\" string, which we must then edit to make compliant), because","# it's been around since git-1.5.3, and it's too difficult to","# discover which version we're using, or to work around using an","# older one.","date","=","date",".","strip","(",")",".","replace","(","\" \"",",","\"T\"",",","1",")",".","replace","(","\" \"",",","\"\"",",","1",")","refnames","=","keywords","[","\"refnames\"","]",".","strip","(",")","if","refnames",".","startswith","(","\"$Format\"",")",":","if","verbose",":","print","(","\"keywords are unexpanded, not using\"",")","raise","NotThisMethod","(","\"unexpanded keywords, not a git-archive tarball\"",")","refs","=","set","(","[","r",".","strip","(",")","for","r","in","refnames",".","strip","(","\"()\"",")",".","split","(","\",\"",")","]",")","# starting in git-1.8.3, tags are listed as \"tag: foo-1.0\" instead of","# just \"foo-1.0\". If we see a \"tag: \" prefix, prefer those.","TAG","=","\"tag: \"","tags","=","set","(","[","r","[","len","(","TAG",")",":","]","for","r","in","refs","if","r",".","startswith","(","TAG",")","]",")","if","not","tags",":","# Either we're using git < 1.8.3, or there really are no tags. We use","# a heuristic: assume all version tags have a digit. The old git %d","# expansion behaves like git log --decorate=short and strips out the","# refs\/heads\/ and refs\/tags\/ prefixes that would let us distinguish","# between branches and tags. By ignoring refnames without digits, we","# filter out many common branch names like \"release\" and","# \"stabilization\", as well as \"HEAD\" and \"master\".","tags","=","set","(","[","r","for","r","in","refs","if","re",".","search","(","r'\\d'",",","r",")","]",")","if","verbose",":","print","(","\"discarding '%s', no digits\"","%","\",\"",".","join","(","refs","-","tags",")",")","if","verbose",":","print","(","\"likely tags: %s\"","%","\",\"",".","join","(","sorted","(","tags",")",")",")","for","ref","in","sorted","(","tags",")",":","# sorting will prefer e.g. \"2.0\" over \"2.0rc1\"","if","ref",".","startswith","(","tag_prefix",")",":","r","=","ref","[","len","(","tag_prefix",")",":","]","if","verbose",":","print","(","\"picking %s\"","%","r",")","return","{","\"version\"",":","r",",","\"full-revisionid\"",":","keywords","[","\"full\"","]",".","strip","(",")",",","\"dirty\"",":","False",",","\"error\"",":","None",",","\"date\"",":","date","}","# no suitable tags, so version is \"0+unknown\", but full hex is still there","if","verbose",":","print","(","\"no suitable tags, using unknown + full revision id\"",")","return","{","\"version\"",":","\"0+unknown\"",",","\"full-revisionid\"",":","keywords","[","\"full\"","]",".","strip","(",")",",","\"dirty\"",":","False",",","\"error\"",":","\"no suitable tags\"",",","\"date\"",":","None","}"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L162-L213"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"git_pieces_from_vcs","parameters":"(tag_prefix, root, verbose, run_command=run_command)","argument_list":"","return_statement":"return pieces","docstring":"Get version from 'git describe' in the root of the source tree.\n\n    This only gets called if the git-archive 'subst' keywords were *not*\n    expanded, and _version.py hasn't already been rewritten with a short\n    version string, meaning we're inside a checked out source tree.","docstring_summary":"Get version from 'git describe' in the root of the source tree.","docstring_tokens":["Get","version","from","git","describe","in","the","root","of","the","source","tree","."],"function":"def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):\n    \"\"\"Get version from 'git describe' in the root of the source tree.\n\n    This only gets called if the git-archive 'subst' keywords were *not*\n    expanded, and _version.py hasn't already been rewritten with a short\n    version string, meaning we're inside a checked out source tree.\n    \"\"\"\n    GITS = [\"git\"]\n    if sys.platform == \"win32\":\n        GITS = [\"git.cmd\", \"git.exe\"]\n\n    out, rc = run_command(GITS, [\"rev-parse\", \"--git-dir\"], cwd=root,\n                          hide_stderr=True)\n    if rc != 0:\n        if verbose:\n            print(\"Directory %s not under git control\" % root)\n        raise NotThisMethod(\"'git rev-parse --git-dir' returned error\")\n\n    # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]\n    # if there isn't one, this yields HEX[-dirty] (no NUM)\n    describe_out, rc = run_command(GITS, [\"describe\", \"--tags\", \"--dirty\",\n                                          \"--always\", \"--long\",\n                                          \"--match\", \"%s*\" % tag_prefix],\n                                   cwd=root)\n    # --long was added in git-1.5.5\n    if describe_out is None:\n        raise NotThisMethod(\"'git describe' failed\")\n    describe_out = describe_out.strip()\n    full_out, rc = run_command(GITS, [\"rev-parse\", \"HEAD\"], cwd=root)\n    if full_out is None:\n        raise NotThisMethod(\"'git rev-parse' failed\")\n    full_out = full_out.strip()\n\n    pieces = {}\n    pieces[\"long\"] = full_out\n    pieces[\"short\"] = full_out[:7]  # maybe improved later\n    pieces[\"error\"] = None\n\n    # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]\n    # TAG might have hyphens.\n    git_describe = describe_out\n\n    # look for -dirty suffix\n    dirty = git_describe.endswith(\"-dirty\")\n    pieces[\"dirty\"] = dirty\n    if dirty:\n        git_describe = git_describe[:git_describe.rindex(\"-dirty\")]\n\n    # now we have TAG-NUM-gHEX or HEX\n\n    if \"-\" in git_describe:\n        # TAG-NUM-gHEX\n        mo = re.search(r'^(.+)-(\\d+)-g([0-9a-f]+)$', git_describe)\n        if not mo:\n            # unparseable. Maybe git-describe is misbehaving?\n            pieces[\"error\"] = (\"unable to parse git-describe output: '%s'\"\n                               % describe_out)\n            return pieces\n\n        # tag\n        full_tag = mo.group(1)\n        if not full_tag.startswith(tag_prefix):\n            if verbose:\n                fmt = \"tag '%s' doesn't start with prefix '%s'\"\n                print(fmt % (full_tag, tag_prefix))\n            pieces[\"error\"] = (\"tag '%s' doesn't start with prefix '%s'\"\n                               % (full_tag, tag_prefix))\n            return pieces\n        pieces[\"closest-tag\"] = full_tag[len(tag_prefix):]\n\n        # distance: number of commits since tag\n        pieces[\"distance\"] = int(mo.group(2))\n\n        # commit: short hex revision ID\n        pieces[\"short\"] = mo.group(3)\n\n    else:\n        # HEX: no tags\n        pieces[\"closest-tag\"] = None\n        count_out, rc = run_command(GITS, [\"rev-list\", \"HEAD\", \"--count\"],\n                                    cwd=root)\n        pieces[\"distance\"] = int(count_out)  # total number of commits\n\n    # commit date: see ISO-8601 comment in git_versions_from_keywords()\n    date = run_command(GITS, [\"show\", \"-s\", \"--format=%ci\", \"HEAD\"],\n                       cwd=root)[0].strip()\n    pieces[\"date\"] = date.strip().replace(\" \", \"T\", 1).replace(\" \", \"\", 1)\n\n    return pieces","function_tokens":["def","git_pieces_from_vcs","(","tag_prefix",",","root",",","verbose",",","run_command","=","run_command",")",":","GITS","=","[","\"git\"","]","if","sys",".","platform","==","\"win32\"",":","GITS","=","[","\"git.cmd\"",",","\"git.exe\"","]","out",",","rc","=","run_command","(","GITS",",","[","\"rev-parse\"",",","\"--git-dir\"","]",",","cwd","=","root",",","hide_stderr","=","True",")","if","rc","!=","0",":","if","verbose",":","print","(","\"Directory %s not under git control\"","%","root",")","raise","NotThisMethod","(","\"'git rev-parse --git-dir' returned error\"",")","# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]","# if there isn't one, this yields HEX[-dirty] (no NUM)","describe_out",",","rc","=","run_command","(","GITS",",","[","\"describe\"",",","\"--tags\"",",","\"--dirty\"",",","\"--always\"",",","\"--long\"",",","\"--match\"",",","\"%s*\"","%","tag_prefix","]",",","cwd","=","root",")","# --long was added in git-1.5.5","if","describe_out","is","None",":","raise","NotThisMethod","(","\"'git describe' failed\"",")","describe_out","=","describe_out",".","strip","(",")","full_out",",","rc","=","run_command","(","GITS",",","[","\"rev-parse\"",",","\"HEAD\"","]",",","cwd","=","root",")","if","full_out","is","None",":","raise","NotThisMethod","(","\"'git rev-parse' failed\"",")","full_out","=","full_out",".","strip","(",")","pieces","=","{","}","pieces","[","\"long\"","]","=","full_out","pieces","[","\"short\"","]","=","full_out","[",":","7","]","# maybe improved later","pieces","[","\"error\"","]","=","None","# parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]","# TAG might have hyphens.","git_describe","=","describe_out","# look for -dirty suffix","dirty","=","git_describe",".","endswith","(","\"-dirty\"",")","pieces","[","\"dirty\"","]","=","dirty","if","dirty",":","git_describe","=","git_describe","[",":","git_describe",".","rindex","(","\"-dirty\"",")","]","# now we have TAG-NUM-gHEX or HEX","if","\"-\"","in","git_describe",":","# TAG-NUM-gHEX","mo","=","re",".","search","(","r'^(.+)-(\\d+)-g([0-9a-f]+)$'",",","git_describe",")","if","not","mo",":","# unparseable. Maybe git-describe is misbehaving?","pieces","[","\"error\"","]","=","(","\"unable to parse git-describe output: '%s'\"","%","describe_out",")","return","pieces","# tag","full_tag","=","mo",".","group","(","1",")","if","not","full_tag",".","startswith","(","tag_prefix",")",":","if","verbose",":","fmt","=","\"tag '%s' doesn't start with prefix '%s'\"","print","(","fmt","%","(","full_tag",",","tag_prefix",")",")","pieces","[","\"error\"","]","=","(","\"tag '%s' doesn't start with prefix '%s'\"","%","(","full_tag",",","tag_prefix",")",")","return","pieces","pieces","[","\"closest-tag\"","]","=","full_tag","[","len","(","tag_prefix",")",":","]","# distance: number of commits since tag","pieces","[","\"distance\"","]","=","int","(","mo",".","group","(","2",")",")","# commit: short hex revision ID","pieces","[","\"short\"","]","=","mo",".","group","(","3",")","else",":","# HEX: no tags","pieces","[","\"closest-tag\"","]","=","None","count_out",",","rc","=","run_command","(","GITS",",","[","\"rev-list\"",",","\"HEAD\"",",","\"--count\"","]",",","cwd","=","root",")","pieces","[","\"distance\"","]","=","int","(","count_out",")","# total number of commits","# commit date: see ISO-8601 comment in git_versions_from_keywords()","date","=","run_command","(","GITS",",","[","\"show\"",",","\"-s\"",",","\"--format=%ci\"",",","\"HEAD\"","]",",","cwd","=","root",")","[","0","]",".","strip","(",")","pieces","[","\"date\"","]","=","date",".","strip","(",")",".","replace","(","\" \"",",","\"T\"",",","1",")",".","replace","(","\" \"",",","\"\"",",","1",")","return","pieces"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L217-L305"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"plus_or_dot","parameters":"(pieces)","argument_list":"","return_statement":"return \"+\"","docstring":"Return a + if we don't already have one, else return a .","docstring_summary":"Return a + if we don't already have one, else return a .","docstring_tokens":["Return","a","+","if","we","don","t","already","have","one","else","return","a","."],"function":"def plus_or_dot(pieces):\n    \"\"\"Return a + if we don't already have one, else return a .\"\"\"\n    if \"+\" in pieces.get(\"closest-tag\", \"\"):\n        return \".\"\n    return \"+\"","function_tokens":["def","plus_or_dot","(","pieces",")",":","if","\"+\"","in","pieces",".","get","(","\"closest-tag\"",",","\"\"",")",":","return","\".\"","return","\"+\""],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L308-L312"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"render_pep440","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"Build up version string, with post-release \"local version identifier\".\n\n    Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you\n    get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty\n\n    Exceptions:\n    1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]","docstring_summary":"Build up version string, with post-release \"local version identifier\".","docstring_tokens":["Build","up","version","string","with","post","-","release","local","version","identifier","."],"function":"def render_pep440(pieces):\n    \"\"\"Build up version string, with post-release \"local version identifier\".\n\n    Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you\n    get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty\n\n    Exceptions:\n    1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"] or pieces[\"dirty\"]:\n            rendered += plus_or_dot(pieces)\n            rendered += \"%d.g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n            if pieces[\"dirty\"]:\n                rendered += \".dirty\"\n    else:\n        # exception #1\n        rendered = \"0+untagged.%d.g%s\" % (pieces[\"distance\"],\n                                          pieces[\"short\"])\n        if pieces[\"dirty\"]:\n            rendered += \".dirty\"\n    return rendered","function_tokens":["def","render_pep440","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]","or","pieces","[","\"dirty\"","]",":","rendered","+=","plus_or_dot","(","pieces",")","rendered","+=","\"%d.g%s\"","%","(","pieces","[","\"distance\"","]",",","pieces","[","\"short\"","]",")","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dirty\"","else",":","# exception #1","rendered","=","\"0+untagged.%d.g%s\"","%","(","pieces","[","\"distance\"","]",",","pieces","[","\"short\"","]",")","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dirty\"","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L315-L337"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"render_pep440_pre","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG[.post.devDISTANCE] -- No -dirty.\n\n    Exceptions:\n    1: no tags. 0.post.devDISTANCE","docstring_summary":"TAG[.post.devDISTANCE] -- No -dirty.","docstring_tokens":["TAG","[",".","post",".","devDISTANCE","]","--","No","-","dirty","."],"function":"def render_pep440_pre(pieces):\n    \"\"\"TAG[.post.devDISTANCE] -- No -dirty.\n\n    Exceptions:\n    1: no tags. 0.post.devDISTANCE\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"]:\n            rendered += \".post.dev%d\" % pieces[\"distance\"]\n    else:\n        # exception #1\n        rendered = \"0.post.dev%d\" % pieces[\"distance\"]\n    return rendered","function_tokens":["def","render_pep440_pre","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]",":","rendered","+=","\".post.dev%d\"","%","pieces","[","\"distance\"","]","else",":","# exception #1","rendered","=","\"0.post.dev%d\"","%","pieces","[","\"distance\"","]","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L340-L353"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"render_pep440_post","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG[.postDISTANCE[.dev0]+gHEX] .\n\n    The \".dev0\" means dirty. Note that .dev0 sorts backwards\n    (a dirty tree will appear \"older\" than the corresponding clean one),\n    but you shouldn't be releasing software with -dirty anyways.\n\n    Exceptions:\n    1: no tags. 0.postDISTANCE[.dev0]","docstring_summary":"TAG[.postDISTANCE[.dev0]+gHEX] .","docstring_tokens":["TAG","[",".","postDISTANCE","[",".","dev0","]","+","gHEX","]","."],"function":"def render_pep440_post(pieces):\n    \"\"\"TAG[.postDISTANCE[.dev0]+gHEX] .\n\n    The \".dev0\" means dirty. Note that .dev0 sorts backwards\n    (a dirty tree will appear \"older\" than the corresponding clean one),\n    but you shouldn't be releasing software with -dirty anyways.\n\n    Exceptions:\n    1: no tags. 0.postDISTANCE[.dev0]\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"] or pieces[\"dirty\"]:\n            rendered += \".post%d\" % pieces[\"distance\"]\n            if pieces[\"dirty\"]:\n                rendered += \".dev0\"\n            rendered += plus_or_dot(pieces)\n            rendered += \"g%s\" % pieces[\"short\"]\n    else:\n        # exception #1\n        rendered = \"0.post%d\" % pieces[\"distance\"]\n        if pieces[\"dirty\"]:\n            rendered += \".dev0\"\n        rendered += \"+g%s\" % pieces[\"short\"]\n    return rendered","function_tokens":["def","render_pep440_post","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]","or","pieces","[","\"dirty\"","]",":","rendered","+=","\".post%d\"","%","pieces","[","\"distance\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dev0\"","rendered","+=","plus_or_dot","(","pieces",")","rendered","+=","\"g%s\"","%","pieces","[","\"short\"","]","else",":","# exception #1","rendered","=","\"0.post%d\"","%","pieces","[","\"distance\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dev0\"","rendered","+=","\"+g%s\"","%","pieces","[","\"short\"","]","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L356-L380"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"render_pep440_old","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG[.postDISTANCE[.dev0]] .\n\n    The \".dev0\" means dirty.\n\n    Eexceptions:\n    1: no tags. 0.postDISTANCE[.dev0]","docstring_summary":"TAG[.postDISTANCE[.dev0]] .","docstring_tokens":["TAG","[",".","postDISTANCE","[",".","dev0","]]","."],"function":"def render_pep440_old(pieces):\n    \"\"\"TAG[.postDISTANCE[.dev0]] .\n\n    The \".dev0\" means dirty.\n\n    Eexceptions:\n    1: no tags. 0.postDISTANCE[.dev0]\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"] or pieces[\"dirty\"]:\n            rendered += \".post%d\" % pieces[\"distance\"]\n            if pieces[\"dirty\"]:\n                rendered += \".dev0\"\n    else:\n        # exception #1\n        rendered = \"0.post%d\" % pieces[\"distance\"]\n        if pieces[\"dirty\"]:\n            rendered += \".dev0\"\n    return rendered","function_tokens":["def","render_pep440_old","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]","or","pieces","[","\"dirty\"","]",":","rendered","+=","\".post%d\"","%","pieces","[","\"distance\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dev0\"","else",":","# exception #1","rendered","=","\"0.post%d\"","%","pieces","[","\"distance\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\".dev0\"","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L383-L402"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"render_git_describe","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG[-DISTANCE-gHEX][-dirty].\n\n    Like 'git describe --tags --dirty --always'.\n\n    Exceptions:\n    1: no tags. HEX[-dirty]  (note: no 'g' prefix)","docstring_summary":"TAG[-DISTANCE-gHEX][-dirty].","docstring_tokens":["TAG","[","-","DISTANCE","-","gHEX","]","[","-","dirty","]","."],"function":"def render_git_describe(pieces):\n    \"\"\"TAG[-DISTANCE-gHEX][-dirty].\n\n    Like 'git describe --tags --dirty --always'.\n\n    Exceptions:\n    1: no tags. HEX[-dirty]  (note: no 'g' prefix)\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        if pieces[\"distance\"]:\n            rendered += \"-%d-g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n    else:\n        # exception #1\n        rendered = pieces[\"short\"]\n    if pieces[\"dirty\"]:\n        rendered += \"-dirty\"\n    return rendered","function_tokens":["def","render_git_describe","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","if","pieces","[","\"distance\"","]",":","rendered","+=","\"-%d-g%s\"","%","(","pieces","[","\"distance\"","]",",","pieces","[","\"short\"","]",")","else",":","# exception #1","rendered","=","pieces","[","\"short\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\"-dirty\"","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L405-L422"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"render_git_describe_long","parameters":"(pieces)","argument_list":"","return_statement":"return rendered","docstring":"TAG-DISTANCE-gHEX[-dirty].\n\n    Like 'git describe --tags --dirty --always -long'.\n    The distance\/hash is unconditional.\n\n    Exceptions:\n    1: no tags. HEX[-dirty]  (note: no 'g' prefix)","docstring_summary":"TAG-DISTANCE-gHEX[-dirty].","docstring_tokens":["TAG","-","DISTANCE","-","gHEX","[","-","dirty","]","."],"function":"def render_git_describe_long(pieces):\n    \"\"\"TAG-DISTANCE-gHEX[-dirty].\n\n    Like 'git describe --tags --dirty --always -long'.\n    The distance\/hash is unconditional.\n\n    Exceptions:\n    1: no tags. HEX[-dirty]  (note: no 'g' prefix)\n    \"\"\"\n    if pieces[\"closest-tag\"]:\n        rendered = pieces[\"closest-tag\"]\n        rendered += \"-%d-g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n    else:\n        # exception #1\n        rendered = pieces[\"short\"]\n    if pieces[\"dirty\"]:\n        rendered += \"-dirty\"\n    return rendered","function_tokens":["def","render_git_describe_long","(","pieces",")",":","if","pieces","[","\"closest-tag\"","]",":","rendered","=","pieces","[","\"closest-tag\"","]","rendered","+=","\"-%d-g%s\"","%","(","pieces","[","\"distance\"","]",",","pieces","[","\"short\"","]",")","else",":","# exception #1","rendered","=","pieces","[","\"short\"","]","if","pieces","[","\"dirty\"","]",":","rendered","+=","\"-dirty\"","return","rendered"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L425-L442"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"render","parameters":"(pieces, style)","argument_list":"","return_statement":"return {\"version\": rendered, \"full-revisionid\": pieces[\"long\"],\n            \"dirty\": pieces[\"dirty\"], \"error\": None,\n            \"date\": pieces.get(\"date\")}","docstring":"Render the given version pieces into the requested style.","docstring_summary":"Render the given version pieces into the requested style.","docstring_tokens":["Render","the","given","version","pieces","into","the","requested","style","."],"function":"def render(pieces, style):\n    \"\"\"Render the given version pieces into the requested style.\"\"\"\n    if pieces[\"error\"]:\n        return {\"version\": \"unknown\",\n                \"full-revisionid\": pieces.get(\"long\"),\n                \"dirty\": None,\n                \"error\": pieces[\"error\"],\n                \"date\": None}\n\n    if not style or style == \"default\":\n        style = \"pep440\"  # the default\n\n    if style == \"pep440\":\n        rendered = render_pep440(pieces)\n    elif style == \"pep440-pre\":\n        rendered = render_pep440_pre(pieces)\n    elif style == \"pep440-post\":\n        rendered = render_pep440_post(pieces)\n    elif style == \"pep440-old\":\n        rendered = render_pep440_old(pieces)\n    elif style == \"git-describe\":\n        rendered = render_git_describe(pieces)\n    elif style == \"git-describe-long\":\n        rendered = render_git_describe_long(pieces)\n    else:\n        raise ValueError(\"unknown style '%s'\" % style)\n\n    return {\"version\": rendered, \"full-revisionid\": pieces[\"long\"],\n            \"dirty\": pieces[\"dirty\"], \"error\": None,\n            \"date\": pieces.get(\"date\")}","function_tokens":["def","render","(","pieces",",","style",")",":","if","pieces","[","\"error\"","]",":","return","{","\"version\"",":","\"unknown\"",",","\"full-revisionid\"",":","pieces",".","get","(","\"long\"",")",",","\"dirty\"",":","None",",","\"error\"",":","pieces","[","\"error\"","]",",","\"date\"",":","None","}","if","not","style","or","style","==","\"default\"",":","style","=","\"pep440\"","# the default","if","style","==","\"pep440\"",":","rendered","=","render_pep440","(","pieces",")","elif","style","==","\"pep440-pre\"",":","rendered","=","render_pep440_pre","(","pieces",")","elif","style","==","\"pep440-post\"",":","rendered","=","render_pep440_post","(","pieces",")","elif","style","==","\"pep440-old\"",":","rendered","=","render_pep440_old","(","pieces",")","elif","style","==","\"git-describe\"",":","rendered","=","render_git_describe","(","pieces",")","elif","style","==","\"git-describe-long\"",":","rendered","=","render_git_describe_long","(","pieces",")","else",":","raise","ValueError","(","\"unknown style '%s'\"","%","style",")","return","{","\"version\"",":","rendered",",","\"full-revisionid\"",":","pieces","[","\"long\"","]",",","\"dirty\"",":","pieces","[","\"dirty\"","]",",","\"error\"",":","None",",","\"date\"",":","pieces",".","get","(","\"date\"",")","}"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L445-L474"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/_version.py","language":"python","identifier":"get_versions","parameters":"()","argument_list":"","return_statement":"return {\"version\": \"0+unknown\", \"full-revisionid\": None,\n            \"dirty\": None,\n            \"error\": \"unable to compute version\", \"date\": None}","docstring":"Get version information or return default if unable to do so.","docstring_summary":"Get version information or return default if unable to do so.","docstring_tokens":["Get","version","information","or","return","default","if","unable","to","do","so","."],"function":"def get_versions():\n    \"\"\"Get version information or return default if unable to do so.\"\"\"\n    # I am in _version.py, which lives at ROOT\/VERSIONFILE_SOURCE. If we have\n    # __file__, we can work backwards from there to the root. Some\n    # py2exe\/bbfreeze\/non-CPython implementations don't do __file__, in which\n    # case we can only use expanded keywords.\n\n    cfg = get_config()\n    verbose = cfg.verbose\n\n    try:\n        return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,\n                                          verbose)\n    except NotThisMethod:\n        pass\n\n    try:\n        root = os.path.realpath(__file__)\n        # versionfile_source is the relative path from the top of the source\n        # tree (where the .git directory might live) to this file. Invert\n        # this to find the root from __file__.\n        for i in cfg.versionfile_source.split('\/'):\n            root = os.path.dirname(root)\n    except NameError:\n        return {\"version\": \"0+unknown\", \"full-revisionid\": None,\n                \"dirty\": None,\n                \"error\": \"unable to find root of source tree\",\n                \"date\": None}\n\n    try:\n        pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)\n        return render(pieces, cfg.style)\n    except NotThisMethod:\n        pass\n\n    try:\n        if cfg.parentdir_prefix:\n            return versions_from_parentdir(cfg.parentdir_prefix, root, verbose)\n    except NotThisMethod:\n        pass\n\n    return {\"version\": \"0+unknown\", \"full-revisionid\": None,\n            \"dirty\": None,\n            \"error\": \"unable to compute version\", \"date\": None}","function_tokens":["def","get_versions","(",")",":","# I am in _version.py, which lives at ROOT\/VERSIONFILE_SOURCE. If we have","# __file__, we can work backwards from there to the root. Some","# py2exe\/bbfreeze\/non-CPython implementations don't do __file__, in which","# case we can only use expanded keywords.","cfg","=","get_config","(",")","verbose","=","cfg",".","verbose","try",":","return","git_versions_from_keywords","(","get_keywords","(",")",",","cfg",".","tag_prefix",",","verbose",")","except","NotThisMethod",":","pass","try",":","root","=","os",".","path",".","realpath","(","__file__",")","# versionfile_source is the relative path from the top of the source","# tree (where the .git directory might live) to this file. Invert","# this to find the root from __file__.","for","i","in","cfg",".","versionfile_source",".","split","(","'\/'",")",":","root","=","os",".","path",".","dirname","(","root",")","except","NameError",":","return","{","\"version\"",":","\"0+unknown\"",",","\"full-revisionid\"",":","None",",","\"dirty\"",":","None",",","\"error\"",":","\"unable to find root of source tree\"",",","\"date\"",":","None","}","try",":","pieces","=","git_pieces_from_vcs","(","cfg",".","tag_prefix",",","root",",","verbose",")","return","render","(","pieces",",","cfg",".","style",")","except","NotThisMethod",":","pass","try",":","if","cfg",".","parentdir_prefix",":","return","versions_from_parentdir","(","cfg",".","parentdir_prefix",",","root",",","verbose",")","except","NotThisMethod",":","pass","return","{","\"version\"",":","\"0+unknown\"",",","\"full-revisionid\"",":","None",",","\"dirty\"",":","None",",","\"error\"",":","\"unable to compute version\"",",","\"date\"",":","None","}"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/_version.py#L477-L520"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/handlers.py","language":"python","identifier":"load_jupyter_server_extension","parameters":"(nbapp)","argument_list":"","return_statement":"","docstring":"Load the nbserver extension","docstring_summary":"Load the nbserver extension","docstring_tokens":["Load","the","nbserver","extension"],"function":"def load_jupyter_server_extension(nbapp):\n    \"\"\"Load the nbserver extension\"\"\"\n    webapp = nbapp.web_app\n    webapp.settings['env_manager'] = EnvManager(parent=nbapp)\n\n    base_url = webapp.settings['base_url']\n    webapp.add_handlers(\".*$\", [\n        (ujoin(base_url, NS, pat), handler)\n        for pat, handler in default_handlers\n    ])\n    nbapp.log.info(\"[nb_conda] enabled\")","function_tokens":["def","load_jupyter_server_extension","(","nbapp",")",":","webapp","=","nbapp",".","web_app","webapp",".","settings","[","'env_manager'","]","=","EnvManager","(","parent","=","nbapp",")","base_url","=","webapp",".","settings","[","'base_url'","]","webapp",".","add_handlers","(","\".*$\"",",","[","(","ujoin","(","base_url",",","NS",",","pat",")",",","handler",")","for","pat",",","handler","in","default_handlers","]",")","nbapp",".","log",".","info","(","\"[nb_conda] enabled\"",")"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/handlers.py#L282-L292"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/handlers.py","language":"python","identifier":"EnvBaseHandler.env_manager","parameters":"(self)","argument_list":"","return_statement":"return self.settings['env_manager']","docstring":"Return our env_manager instance","docstring_summary":"Return our env_manager instance","docstring_tokens":["Return","our","env_manager","instance"],"function":"def env_manager(self):\n        \"\"\"Return our env_manager instance\"\"\"\n        return self.settings['env_manager']","function_tokens":["def","env_manager","(","self",")",":","return","self",".","settings","[","'env_manager'","]"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/handlers.py#L39-L41"}
{"nwo":"Anaconda-Platform\/nb_conda","sha":"af63a71d8d8ce299bfcb1c1ffef3320de17228fe","path":"nb_conda\/handlers.py","language":"python","identifier":"CondaSearcher.list_available","parameters":"(self, handler=None)","argument_list":"","return_statement":"return None","docstring":"List the available conda packages by kicking off a background\n        conda process. Will return None. Call again to poll the process\n        status. When the process completes, a list of packages will be\n        returned upon success. On failure, the results of `conda search --json`\n        will be returned (this will be a dict containing error information).\n        TODO - break up this method.","docstring_summary":"List the available conda packages by kicking off a background\n        conda process. Will return None. Call again to poll the process\n        status. When the process completes, a list of packages will be\n        returned upon success. On failure, the results of `conda search --json`\n        will be returned (this will be a dict containing error information).\n        TODO - break up this method.","docstring_tokens":["List","the","available","conda","packages","by","kicking","off","a","background","conda","process",".","Will","return","None",".","Call","again","to","poll","the","process","status",".","When","the","process","completes","a","list","of","packages","will","be","returned","upon","success",".","On","failure","the","results","of","conda","search","--","json","will","be","returned","(","this","will","be","a","dict","containing","error","information",")",".","TODO","-","break","up","this","method","."],"function":"def list_available(self, handler=None):\n        \"\"\"\n        List the available conda packages by kicking off a background\n        conda process. Will return None. Call again to poll the process\n        status. When the process completes, a list of packages will be\n        returned upon success. On failure, the results of `conda search --json`\n        will be returned (this will be a dict containing error information).\n        TODO - break up this method.\n        \"\"\"\n        self.log = handler.log\n\n        if self.conda_process is not None:\n            # already running, check for completion\n            self.log.debug('Already running: pid %s', self.conda_process.pid)\n\n            status = self.conda_process.poll()\n            self.log.debug('Status %s', status)\n\n            if status is not None:\n                # completed, return the data\n                self.log.debug('Done, reading output')\n                self.conda_process = None\n\n                self.conda_temp.seek(0)\n                data = json.loads(self.conda_temp.read())\n                self.conda_temp = None\n\n                if 'error' in data:\n                    # we didn't get back a list of packages, we got a\n                    # dictionary with error info\n                    return data\n\n                packages = []\n\n                for entries in data.values():\n                    max_version = None\n                    max_version_entry = None\n\n                    for entry in entries:\n                        version = parse_version(entry.get('version', ''))\n\n                        if max_version is None or version > max_version:\n                            max_version = version\n                            max_version_entry = entry\n\n                    packages.append(max_version_entry)\n\n                return sorted(packages, key=lambda entry: entry.get('name'))\n\n        else:\n            # Spawn subprocess to get the data\n            self.log.debug('Starting conda process')\n            self.conda_temp = TemporaryFile(mode='w+')\n            cmdline = 'conda search --json'.split()\n            self.conda_process = Popen(cmdline, stdout=self.conda_temp,\n                                       bufsize=4096)\n            self.log.debug('Started: pid %s', self.conda_process.pid)\n\n        return None","function_tokens":["def","list_available","(","self",",","handler","=","None",")",":","self",".","log","=","handler",".","log","if","self",".","conda_process","is","not","None",":","# already running, check for completion","self",".","log",".","debug","(","'Already running: pid %s'",",","self",".","conda_process",".","pid",")","status","=","self",".","conda_process",".","poll","(",")","self",".","log",".","debug","(","'Status %s'",",","status",")","if","status","is","not","None",":","# completed, return the data","self",".","log",".","debug","(","'Done, reading output'",")","self",".","conda_process","=","None","self",".","conda_temp",".","seek","(","0",")","data","=","json",".","loads","(","self",".","conda_temp",".","read","(",")",")","self",".","conda_temp","=","None","if","'error'","in","data",":","# we didn't get back a list of packages, we got a","# dictionary with error info","return","data","packages","=","[","]","for","entries","in","data",".","values","(",")",":","max_version","=","None","max_version_entry","=","None","for","entry","in","entries",":","version","=","parse_version","(","entry",".","get","(","'version'",",","''",")",")","if","max_version","is","None","or","version",">","max_version",":","max_version","=","version","max_version_entry","=","entry","packages",".","append","(","max_version_entry",")","return","sorted","(","packages",",","key","=","lambda","entry",":","entry",".","get","(","'name'",")",")","else",":","# Spawn subprocess to get the data","self",".","log",".","debug","(","'Starting conda process'",")","self",".","conda_temp","=","TemporaryFile","(","mode","=","'w+'",")","cmdline","=","'conda search --json'",".","split","(",")","self",".","conda_process","=","Popen","(","cmdline",",","stdout","=","self",".","conda_temp",",","bufsize","=","4096",")","self",".","log",".","debug","(","'Started: pid %s'",",","self",".","conda_process",".","pid",")","return","None"],"url":"https:\/\/github.com\/Anaconda-Platform\/nb_conda\/blob\/af63a71d8d8ce299bfcb1c1ffef3320de17228fe\/nb_conda\/handlers.py#L158-L216"}