{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"abort","parameters":"(code=500, text='Unknown Error: Application stopped.')","argument_list":"","return_statement":"","docstring":"Aborts execution and causes a HTTP error.","docstring_summary":"Aborts execution and causes a HTTP error.","docstring_tokens":["Aborts","execution","and","causes","a","HTTP","error","."],"function":"def abort(code=500, text='Unknown Error: Application stopped.'):\n \"\"\" Aborts execution and causes a HTTP error. \"\"\"\n raise HTTPError(code, text)","function_tokens":["def","abort","(","code","=","500",",","text","=","'Unknown Error: Application stopped.'",")",":","raise","HTTPError","(","code",",","text",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2036-L2038"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"redirect","parameters":"(url, code=None)","argument_list":"","return_statement":"","docstring":"Aborts execution and causes a 303 or 302 redirect, depending on\n the HTTP protocol version.","docstring_summary":"Aborts execution and causes a 303 or 302 redirect, depending on\n the HTTP protocol version.","docstring_tokens":["Aborts","execution","and","causes","a","303","or","302","redirect","depending","on","the","HTTP","protocol","version","."],"function":"def redirect(url, code=None):\n \"\"\" Aborts execution and causes a 303 or 302 redirect, depending on\n the HTTP protocol version. \"\"\"\n if code is None:\n code = 303 if request.get('SERVER_PROTOCOL') == \"HTTP\/1.1\" else 302\n location = urljoin(request.url, url)\n res = HTTPResponse(\"\", status=code, Location=location)\n if response._cookies:\n res._cookies = response._cookies\n raise res","function_tokens":["def","redirect","(","url",",","code","=","None",")",":","if","code","is","None",":","code","=","303","if","request",".","get","(","'SERVER_PROTOCOL'",")","==","\"HTTP\/1.1\"","else","302","location","=","urljoin","(","request",".","url",",","url",")","res","=","HTTPResponse","(","\"\"",",","status","=","code",",","Location","=","location",")","if","response",".","_cookies",":","res",".","_cookies","=","response",".","_cookies","raise","res"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2041-L2050"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"_file_iter_range","parameters":"(fp, offset, bytes, maxread=1024*1024)","argument_list":"","return_statement":"","docstring":"Yield chunks from a range in a file. No chunk is bigger than maxread.","docstring_summary":"Yield chunks from a range in a file. No chunk is bigger than maxread.","docstring_tokens":["Yield","chunks","from","a","range","in","a","file",".","No","chunk","is","bigger","than","maxread","."],"function":"def _file_iter_range(fp, offset, bytes, maxread=1024*1024):\n ''' Yield chunks from a range in a file. No chunk is bigger than maxread.'''\n fp.seek(offset)\n while bytes > 0:\n part = fp.read(min(bytes, maxread))\n if not part: break\n bytes -= len(part)\n yield part","function_tokens":["def","_file_iter_range","(","fp",",","offset",",","bytes",",","maxread","=","1024","*","1024",")",":","fp",".","seek","(","offset",")","while","bytes",">","0",":","part","=","fp",".","read","(","min","(","bytes",",","maxread",")",")","if","not","part",":","break","bytes","-=","len","(","part",")","yield","part"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2053-L2060"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"static_file","parameters":"(filename, root, mimetype='auto', download=False)","argument_list":"","return_statement":"return HTTPResponse(body, **headers)","docstring":"Open a file in a safe way and return :exc:`HTTPResponse` with status\n code 200, 305, 401 or 404. Set Content-Type, Content-Encoding,\n Content-Length and Last-Modified header. Obey If-Modified-Since header\n and HEAD requests.","docstring_summary":"Open a file in a safe way and return :exc:`HTTPResponse` with status\n code 200, 305, 401 or 404. Set Content-Type, Content-Encoding,\n Content-Length and Last-Modified header. Obey If-Modified-Since header\n and HEAD requests.","docstring_tokens":["Open","a","file","in","a","safe","way","and","return",":","exc",":","HTTPResponse","with","status","code","200","305","401","or","404",".","Set","Content","-","Type","Content","-","Encoding","Content","-","Length","and","Last","-","Modified","header",".","Obey","If","-","Modified","-","Since","header","and","HEAD","requests","."],"function":"def static_file(filename, root, mimetype='auto', download=False):\n \"\"\" Open a file in a safe way and return :exc:`HTTPResponse` with status\n code 200, 305, 401 or 404. Set Content-Type, Content-Encoding,\n Content-Length and Last-Modified header. Obey If-Modified-Since header\n and HEAD requests.\n \"\"\"\n root = os.path.abspath(root) + os.sep\n filename = os.path.abspath(os.path.join(root, filename.strip('\/\\\\')))\n headers = dict()\n\n if not filename.startswith(root):\n return HTTPError(403, \"Access denied.\")\n if not os.path.exists(filename) or not os.path.isfile(filename):\n return HTTPError(404, \"File does not exist.\")\n if not os.access(filename, os.R_OK):\n return HTTPError(403, \"You do not have permission to access this file.\")\n\n if mimetype == 'auto':\n mimetype, encoding = mimetypes.guess_type(filename)\n if mimetype: headers['Content-Type'] = mimetype\n if encoding: headers['Content-Encoding'] = encoding\n elif mimetype:\n headers['Content-Type'] = mimetype\n\n if download:\n download = os.path.basename(filename if download == True else download)\n headers['Content-Disposition'] = 'attachment; filename=\"%s\"' % download\n\n stats = os.stat(filename)\n headers['Content-Length'] = clen = stats.st_size\n lm = time.strftime(\"%a, %d %b %Y %H:%M:%S GMT\", time.gmtime(stats.st_mtime))\n headers['Last-Modified'] = lm\n\n ims = request.environ.get('HTTP_IF_MODIFIED_SINCE')\n if ims:\n ims = parse_date(ims.split(\";\")[0].strip())\n if ims is not None and ims >= int(stats.st_mtime):\n headers['Date'] = time.strftime(\"%a, %d %b %Y %H:%M:%S GMT\", time.gmtime())\n return HTTPResponse(status=304, **headers)\n\n body = '' if request.method == 'HEAD' else open(filename, 'rb')\n\n headers[\"Accept-Ranges\"] = \"bytes\"\n ranges = request.environ.get('HTTP_RANGE')\n if 'HTTP_RANGE' in request.environ:\n ranges = list(parse_range_header(request.environ['HTTP_RANGE'], clen))\n if not ranges:\n return HTTPError(416, \"Requested Range Not Satisfiable\")\n offset, end = ranges[0]\n headers[\"Content-Range\"] = \"bytes %d-%d\/%d\" % (offset, end-1, clen)\n headers[\"Content-Length\"] = str(end-offset)\n if body: body = _file_iter_range(body, offset, end-offset)\n return HTTPResponse(body, status=206, **headers)\n return HTTPResponse(body, **headers)","function_tokens":["def","static_file","(","filename",",","root",",","mimetype","=","'auto'",",","download","=","False",")",":","root","=","os",".","path",".","abspath","(","root",")","+","os",".","sep","filename","=","os",".","path",".","abspath","(","os",".","path",".","join","(","root",",","filename",".","strip","(","'\/\\\\'",")",")",")","headers","=","dict","(",")","if","not","filename",".","startswith","(","root",")",":","return","HTTPError","(","403",",","\"Access denied.\"",")","if","not","os",".","path",".","exists","(","filename",")","or","not","os",".","path",".","isfile","(","filename",")",":","return","HTTPError","(","404",",","\"File does not exist.\"",")","if","not","os",".","access","(","filename",",","os",".","R_OK",")",":","return","HTTPError","(","403",",","\"You do not have permission to access this file.\"",")","if","mimetype","==","'auto'",":","mimetype",",","encoding","=","mimetypes",".","guess_type","(","filename",")","if","mimetype",":","headers","[","'Content-Type'","]","=","mimetype","if","encoding",":","headers","[","'Content-Encoding'","]","=","encoding","elif","mimetype",":","headers","[","'Content-Type'","]","=","mimetype","if","download",":","download","=","os",".","path",".","basename","(","filename","if","download","==","True","else","download",")","headers","[","'Content-Disposition'","]","=","'attachment; filename=\"%s\"'","%","download","stats","=","os",".","stat","(","filename",")","headers","[","'Content-Length'","]","=","clen","=","stats",".","st_size","lm","=","time",".","strftime","(","\"%a, %d %b %Y %H:%M:%S GMT\"",",","time",".","gmtime","(","stats",".","st_mtime",")",")","headers","[","'Last-Modified'","]","=","lm","ims","=","request",".","environ",".","get","(","'HTTP_IF_MODIFIED_SINCE'",")","if","ims",":","ims","=","parse_date","(","ims",".","split","(","\";\"",")","[","0","]",".","strip","(",")",")","if","ims","is","not","None","and","ims",">=","int","(","stats",".","st_mtime",")",":","headers","[","'Date'","]","=","time",".","strftime","(","\"%a, %d %b %Y %H:%M:%S GMT\"",",","time",".","gmtime","(",")",")","return","HTTPResponse","(","status","=","304",",","*","*","headers",")","body","=","''","if","request",".","method","==","'HEAD'","else","open","(","filename",",","'rb'",")","headers","[","\"Accept-Ranges\"","]","=","\"bytes\"","ranges","=","request",".","environ",".","get","(","'HTTP_RANGE'",")","if","'HTTP_RANGE'","in","request",".","environ",":","ranges","=","list","(","parse_range_header","(","request",".","environ","[","'HTTP_RANGE'","]",",","clen",")",")","if","not","ranges",":","return","HTTPError","(","416",",","\"Requested Range Not Satisfiable\"",")","offset",",","end","=","ranges","[","0","]","headers","[","\"Content-Range\"","]","=","\"bytes %d-%d\/%d\"","%","(","offset",",","end","-","1",",","clen",")","headers","[","\"Content-Length\"","]","=","str","(","end","-","offset",")","if","body",":","body","=","_file_iter_range","(","body",",","offset",",","end","-","offset",")","return","HTTPResponse","(","body",",","status","=","206",",","*","*","headers",")","return","HTTPResponse","(","body",",","*","*","headers",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2063-L2116"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"debug","parameters":"(mode=True)","argument_list":"","return_statement":"","docstring":"Change the debug level.\n There is only one debug level supported at the moment.","docstring_summary":"Change the debug level.\n There is only one debug level supported at the moment.","docstring_tokens":["Change","the","debug","level",".","There","is","only","one","debug","level","supported","at","the","moment","."],"function":"def debug(mode=True):\n \"\"\" Change the debug level.\n There is only one debug level supported at the moment.\"\"\"\n global DEBUG\n DEBUG = bool(mode)","function_tokens":["def","debug","(","mode","=","True",")",":","global","DEBUG","DEBUG","=","bool","(","mode",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2128-L2132"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"parse_date","parameters":"(ims)","argument_list":"","return_statement":"","docstring":"Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch.","docstring_summary":"Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch.","docstring_tokens":["Parse","rfc1123","rfc850","and","asctime","timestamps","and","return","UTC","epoch","."],"function":"def parse_date(ims):\n \"\"\" Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch. \"\"\"\n try:\n ts = email.utils.parsedate_tz(ims)\n return time.mktime(ts[:8] + (0,)) - (ts[9] or 0) - time.timezone\n except (TypeError, ValueError, IndexError, OverflowError):\n return None","function_tokens":["def","parse_date","(","ims",")",":","try",":","ts","=","email",".","utils",".","parsedate_tz","(","ims",")","return","time",".","mktime","(","ts","[",":","8","]","+","(","0",",",")",")","-","(","ts","[","9","]","or","0",")","-","time",".","timezone","except","(","TypeError",",","ValueError",",","IndexError",",","OverflowError",")",":","return","None"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2135-L2141"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"parse_auth","parameters":"(header)","argument_list":"","return_statement":"","docstring":"Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None","docstring_summary":"Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None","docstring_tokens":["Parse","rfc2617","HTTP","authentication","header","string","(","basic",")","and","return","(","user","pass",")","tuple","or","None"],"function":"def parse_auth(header):\n \"\"\" Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None\"\"\"\n try:\n method, data = header.split(None, 1)\n if method.lower() == 'basic':\n user, pwd = touni(base64.b64decode(tob(data))).split(':',1)\n return user, pwd\n except (KeyError, ValueError):\n return None","function_tokens":["def","parse_auth","(","header",")",":","try",":","method",",","data","=","header",".","split","(","None",",","1",")","if","method",".","lower","(",")","==","'basic'",":","user",",","pwd","=","touni","(","base64",".","b64decode","(","tob","(","data",")",")",")",".","split","(","':'",",","1",")","return","user",",","pwd","except","(","KeyError",",","ValueError",")",":","return","None"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2144-L2152"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"parse_range_header","parameters":"(header, maxlen=0)","argument_list":"","return_statement":"","docstring":"Yield (start, end) ranges parsed from a HTTP Range header. Skip\n unsatisfiable ranges. The end index is non-inclusive.","docstring_summary":"Yield (start, end) ranges parsed from a HTTP Range header. Skip\n unsatisfiable ranges. The end index is non-inclusive.","docstring_tokens":["Yield","(","start","end",")","ranges","parsed","from","a","HTTP","Range","header",".","Skip","unsatisfiable","ranges",".","The","end","index","is","non","-","inclusive","."],"function":"def parse_range_header(header, maxlen=0):\n ''' Yield (start, end) ranges parsed from a HTTP Range header. Skip\n unsatisfiable ranges. The end index is non-inclusive.'''\n if not header or header[:6] != 'bytes=': return\n ranges = [r.split('-', 1) for r in header[6:].split(',') if '-' in r]\n for start, end in ranges:\n try:\n if not start: # bytes=-100 -> last 100 bytes\n start, end = max(0, maxlen-int(end)), maxlen\n elif not end: # bytes=100- -> all but the first 99 bytes\n start, end = int(start), maxlen\n else: # bytes=100-200 -> bytes 100-200 (inclusive)\n start, end = int(start), min(int(end)+1, maxlen)\n if 0 <= start < end <= maxlen:\n yield start, end\n except ValueError:\n pass","function_tokens":["def","parse_range_header","(","header",",","maxlen","=","0",")",":","if","not","header","or","header","[",":","6","]","!=","'bytes='",":","return","ranges","=","[","r",".","split","(","'-'",",","1",")","for","r","in","header","[","6",":","]",".","split","(","','",")","if","'-'","in","r","]","for","start",",","end","in","ranges",":","try",":","if","not","start",":","# bytes=-100 -> last 100 bytes","start",",","end","=","max","(","0",",","maxlen","-","int","(","end",")",")",",","maxlen","elif","not","end",":","# bytes=100- -> all but the first 99 bytes","start",",","end","=","int","(","start",")",",","maxlen","else",":","# bytes=100-200 -> bytes 100-200 (inclusive)","start",",","end","=","int","(","start",")",",","min","(","int","(","end",")","+","1",",","maxlen",")","if","0","<=","start","<","end","<=","maxlen",":","yield","start",",","end","except","ValueError",":","pass"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2154-L2170"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"_lscmp","parameters":"(a, b)","argument_list":"","return_statement":"return not sum(0 if x==y else 1 for x, y in zip(a, b)) and len(a) == len(b)","docstring":"Compares two strings in a cryptographically safe way:\n Runtime is not affected by length of common prefix.","docstring_summary":"Compares two strings in a cryptographically safe way:\n Runtime is not affected by length of common prefix.","docstring_tokens":["Compares","two","strings","in","a","cryptographically","safe","way",":","Runtime","is","not","affected","by","length","of","common","prefix","."],"function":"def _lscmp(a, b):\n ''' Compares two strings in a cryptographically safe way:\n Runtime is not affected by length of common prefix. '''\n return not sum(0 if x==y else 1 for x, y in zip(a, b)) and len(a) == len(b)","function_tokens":["def","_lscmp","(","a",",","b",")",":","return","not","sum","(","0","if","x","==","y","else","1","for","x",",","y","in","zip","(","a",",","b",")",")","and","len","(","a",")","==","len","(","b",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2183-L2186"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"cookie_encode","parameters":"(data, key)","argument_list":"","return_statement":"return tob('!') + sig + tob('?') + msg","docstring":"Encode and sign a pickle-able object. Return a (byte) string","docstring_summary":"Encode and sign a pickle-able object. Return a (byte) string","docstring_tokens":["Encode","and","sign","a","pickle","-","able","object",".","Return","a","(","byte",")","string"],"function":"def cookie_encode(data, key):\n ''' Encode and sign a pickle-able object. Return a (byte) string '''\n msg = base64.b64encode(pickle.dumps(data, -1))\n sig = base64.b64encode(hmac.new(tob(key), msg).digest())\n return tob('!') + sig + tob('?') + msg","function_tokens":["def","cookie_encode","(","data",",","key",")",":","msg","=","base64",".","b64encode","(","pickle",".","dumps","(","data",",","-","1",")",")","sig","=","base64",".","b64encode","(","hmac",".","new","(","tob","(","key",")",",","msg",")",".","digest","(",")",")","return","tob","(","'!'",")","+","sig","+","tob","(","'?'",")","+","msg"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2189-L2193"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"cookie_decode","parameters":"(data, key)","argument_list":"","return_statement":"return None","docstring":"Verify and decode an encoded string. Return an object or None.","docstring_summary":"Verify and decode an encoded string. Return an object or None.","docstring_tokens":["Verify","and","decode","an","encoded","string",".","Return","an","object","or","None","."],"function":"def cookie_decode(data, key):\n ''' Verify and decode an encoded string. Return an object or None.'''\n data = tob(data)\n if cookie_is_encoded(data):\n sig, msg = data.split(tob('?'), 1)\n if _lscmp(sig[1:], base64.b64encode(hmac.new(tob(key), msg).digest())):\n return pickle.loads(base64.b64decode(msg))\n return None","function_tokens":["def","cookie_decode","(","data",",","key",")",":","data","=","tob","(","data",")","if","cookie_is_encoded","(","data",")",":","sig",",","msg","=","data",".","split","(","tob","(","'?'",")",",","1",")","if","_lscmp","(","sig","[","1",":","]",",","base64",".","b64encode","(","hmac",".","new","(","tob","(","key",")",",","msg",")",".","digest","(",")",")",")",":","return","pickle",".","loads","(","base64",".","b64decode","(","msg",")",")","return","None"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2196-L2203"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"cookie_is_encoded","parameters":"(data)","argument_list":"","return_statement":"return bool(data.startswith(tob('!')) and tob('?') in data)","docstring":"Return True if the argument looks like a encoded cookie.","docstring_summary":"Return True if the argument looks like a encoded cookie.","docstring_tokens":["Return","True","if","the","argument","looks","like","a","encoded","cookie","."],"function":"def cookie_is_encoded(data):\n ''' Return True if the argument looks like a encoded cookie.'''\n return bool(data.startswith(tob('!')) and tob('?') in data)","function_tokens":["def","cookie_is_encoded","(","data",")",":","return","bool","(","data",".","startswith","(","tob","(","'!'",")",")","and","tob","(","'?'",")","in","data",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2206-L2208"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"html_escape","parameters":"(string)","argument_list":"","return_statement":"return string.replace('&','&').replace('<','<').replace('>','>')\\\n .replace('\"','"').replace(\"'\",''')","docstring":"Escape HTML special characters ``&<>`` and quotes ``'\"``.","docstring_summary":"Escape HTML special characters ``&<>`` and quotes ``'\"``.","docstring_tokens":["Escape","HTML","special","characters","&<",">","and","quotes","."],"function":"def html_escape(string):\n ''' Escape HTML special characters ``&<>`` and quotes ``'\"``. '''\n return string.replace('&','&').replace('<','<').replace('>','>')\\\n .replace('\"','"').replace(\"'\",''')","function_tokens":["def","html_escape","(","string",")",":","return","string",".","replace","(","'&'",",","'&'",")",".","replace","(","'<'",",","'<'",")",".","replace","(","'>'",",","'>'",")",".","replace","(","'\"'",",","'"'",")",".","replace","(","\"'\"",",","'''",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2211-L2214"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"html_quote","parameters":"(string)","argument_list":"","return_statement":"return '\"%s\"' % html_escape(string).replace('\\n','%#10;')\\\n .replace('\\r',' ').replace('\\t',' ')","docstring":"Escape and quote a string to be used as an HTTP attribute.","docstring_summary":"Escape and quote a string to be used as an HTTP attribute.","docstring_tokens":["Escape","and","quote","a","string","to","be","used","as","an","HTTP","attribute","."],"function":"def html_quote(string):\n ''' Escape and quote a string to be used as an HTTP attribute.'''\n return '\"%s\"' % html_escape(string).replace('\\n','%#10;')\\\n .replace('\\r',' ').replace('\\t',' ')","function_tokens":["def","html_quote","(","string",")",":","return","'\"%s\"'","%","html_escape","(","string",")",".","replace","(","'\\n'",",","'%#10;'",")",".","replace","(","'\\r'",",","' '",")",".","replace","(","'\\t'",",","' '",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2217-L2220"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"yieldroutes","parameters":"(func)","argument_list":"","return_statement":"","docstring":"Return a generator for routes that match the signature (name, args)\n of the func parameter. This may yield more than one route if the function\n takes optional keyword arguments. The output is best described by example::\n\n a() -> '\/a'\n b(x, y) -> '\/b\/:x\/:y'\n c(x, y=5) -> '\/c\/:x' and '\/c\/:x\/:y'\n d(x=5, y=6) -> '\/d' and '\/d\/:x' and '\/d\/:x\/:y'","docstring_summary":"Return a generator for routes that match the signature (name, args)\n of the func parameter. This may yield more than one route if the function\n takes optional keyword arguments. The output is best described by example::","docstring_tokens":["Return","a","generator","for","routes","that","match","the","signature","(","name","args",")","of","the","func","parameter",".","This","may","yield","more","than","one","route","if","the","function","takes","optional","keyword","arguments",".","The","output","is","best","described","by","example","::"],"function":"def yieldroutes(func):\n \"\"\" Return a generator for routes that match the signature (name, args)\n of the func parameter. This may yield more than one route if the function\n takes optional keyword arguments. The output is best described by example::\n\n a() -> '\/a'\n b(x, y) -> '\/b\/:x\/:y'\n c(x, y=5) -> '\/c\/:x' and '\/c\/:x\/:y'\n d(x=5, y=6) -> '\/d' and '\/d\/:x' and '\/d\/:x\/:y'\n \"\"\"\n import inspect # Expensive module. Only import if necessary.\n path = '\/' + func.__name__.replace('__','\/').lstrip('\/')\n spec = inspect.getargspec(func)\n argc = len(spec[0]) - len(spec[3] or [])\n path += ('\/:%s' * argc) % tuple(spec[0][:argc])\n yield path\n for arg in spec[0][argc:]:\n path += '\/:%s' % arg\n yield path","function_tokens":["def","yieldroutes","(","func",")",":","import","inspect","# Expensive module. Only import if necessary.","path","=","'\/'","+","func",".","__name__",".","replace","(","'__'",",","'\/'",")",".","lstrip","(","'\/'",")","spec","=","inspect",".","getargspec","(","func",")","argc","=","len","(","spec","[","0","]",")","-","len","(","spec","[","3","]","or","[","]",")","path","+=","(","'\/:%s'","*","argc",")","%","tuple","(","spec","[","0","]","[",":","argc","]",")","yield","path","for","arg","in","spec","[","0","]","[","argc",":","]",":","path","+=","'\/:%s'","%","arg","yield","path"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2223-L2241"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"path_shift","parameters":"(script_name, path_info, shift=1)","argument_list":"","return_statement":"return new_script_name, new_path_info","docstring":"Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa.\n\n :return: The modified paths.\n :param script_name: The SCRIPT_NAME path.\n :param script_name: The PATH_INFO path.\n :param shift: The number of path fragments to shift. May be negative to\n change the shift direction. (default: 1)","docstring_summary":"Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa.","docstring_tokens":["Shift","path","fragments","from","PATH_INFO","to","SCRIPT_NAME","and","vice","versa","."],"function":"def path_shift(script_name, path_info, shift=1):\n ''' Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa.\n\n :return: The modified paths.\n :param script_name: The SCRIPT_NAME path.\n :param script_name: The PATH_INFO path.\n :param shift: The number of path fragments to shift. May be negative to\n change the shift direction. (default: 1)\n '''\n if shift == 0: return script_name, path_info\n pathlist = path_info.strip('\/').split('\/')\n scriptlist = script_name.strip('\/').split('\/')\n if pathlist and pathlist[0] == '': pathlist = []\n if scriptlist and scriptlist[0] == '': scriptlist = []\n if shift > 0 and shift <= len(pathlist):\n moved = pathlist[:shift]\n scriptlist = scriptlist + moved\n pathlist = pathlist[shift:]\n elif shift < 0 and shift >= -len(scriptlist):\n moved = scriptlist[shift:]\n pathlist = moved + pathlist\n scriptlist = scriptlist[:shift]\n else:\n empty = 'SCRIPT_NAME' if shift < 0 else 'PATH_INFO'\n raise AssertionError(\"Cannot shift. Nothing left from %s\" % empty)\n new_script_name = '\/' + '\/'.join(scriptlist)\n new_path_info = '\/' + '\/'.join(pathlist)\n if path_info.endswith('\/') and pathlist: new_path_info += '\/'\n return new_script_name, new_path_info","function_tokens":["def","path_shift","(","script_name",",","path_info",",","shift","=","1",")",":","if","shift","==","0",":","return","script_name",",","path_info","pathlist","=","path_info",".","strip","(","'\/'",")",".","split","(","'\/'",")","scriptlist","=","script_name",".","strip","(","'\/'",")",".","split","(","'\/'",")","if","pathlist","and","pathlist","[","0","]","==","''",":","pathlist","=","[","]","if","scriptlist","and","scriptlist","[","0","]","==","''",":","scriptlist","=","[","]","if","shift",">","0","and","shift","<=","len","(","pathlist",")",":","moved","=","pathlist","[",":","shift","]","scriptlist","=","scriptlist","+","moved","pathlist","=","pathlist","[","shift",":","]","elif","shift","<","0","and","shift",">=","-","len","(","scriptlist",")",":","moved","=","scriptlist","[","shift",":","]","pathlist","=","moved","+","pathlist","scriptlist","=","scriptlist","[",":","shift","]","else",":","empty","=","'SCRIPT_NAME'","if","shift","<","0","else","'PATH_INFO'","raise","AssertionError","(","\"Cannot shift. Nothing left from %s\"","%","empty",")","new_script_name","=","'\/'","+","'\/'",".","join","(","scriptlist",")","new_path_info","=","'\/'","+","'\/'",".","join","(","pathlist",")","if","path_info",".","endswith","(","'\/'",")","and","pathlist",":","new_path_info","+=","'\/'","return","new_script_name",",","new_path_info"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2244-L2272"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"validate","parameters":"(**vkargs)","argument_list":"","return_statement":"return decorator","docstring":"Validates and manipulates keyword arguments by user defined callables.\n Handles ValueError and missing arguments by raising HTTPError(403).","docstring_summary":"Validates and manipulates keyword arguments by user defined callables.\n Handles ValueError and missing arguments by raising HTTPError(403).","docstring_tokens":["Validates","and","manipulates","keyword","arguments","by","user","defined","callables",".","Handles","ValueError","and","missing","arguments","by","raising","HTTPError","(","403",")","."],"function":"def validate(**vkargs):\n \"\"\"\n Validates and manipulates keyword arguments by user defined callables.\n Handles ValueError and missing arguments by raising HTTPError(403).\n \"\"\"\n depr('Use route wildcard filters instead.')\n def decorator(func):\n @functools.wraps(func)\n def wrapper(*args, **kargs):\n for key, value in vkargs.items():\n if key not in kargs:\n abort(403, 'Missing parameter: %s' % key)\n try:\n kargs[key] = value(kargs[key])\n except ValueError:\n abort(403, 'Wrong parameter format for: %s' % key)\n return func(*args, **kargs)\n return wrapper\n return decorator","function_tokens":["def","validate","(","*","*","vkargs",")",":","depr","(","'Use route wildcard filters instead.'",")","def","decorator","(","func",")",":","@","functools",".","wraps","(","func",")","def","wrapper","(","*","args",",","*","*","kargs",")",":","for","key",",","value","in","vkargs",".","items","(",")",":","if","key","not","in","kargs",":","abort","(","403",",","'Missing parameter: %s'","%","key",")","try",":","kargs","[","key","]","=","value","(","kargs","[","key","]",")","except","ValueError",":","abort","(","403",",","'Wrong parameter format for: %s'","%","key",")","return","func","(","*","args",",","*","*","kargs",")","return","wrapper","return","decorator"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2275-L2293"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"auth_basic","parameters":"(check, realm=\"private\", text=\"Access denied\")","argument_list":"","return_statement":"return decorator","docstring":"Callback decorator to require HTTP auth (basic).\n TODO: Add route(check_auth=...) parameter.","docstring_summary":"Callback decorator to require HTTP auth (basic).\n TODO: Add route(check_auth=...) parameter.","docstring_tokens":["Callback","decorator","to","require","HTTP","auth","(","basic",")",".","TODO",":","Add","route","(","check_auth","=","...",")","parameter","."],"function":"def auth_basic(check, realm=\"private\", text=\"Access denied\"):\n ''' Callback decorator to require HTTP auth (basic).\n TODO: Add route(check_auth=...) parameter. '''\n def decorator(func):\n def wrapper(*a, **ka):\n user, password = request.auth or (None, None)\n if user is None or not check(user, password):\n response.headers['WWW-Authenticate'] = 'Basic realm=\"%s\"' % realm\n return HTTPError(401, text)\n return func(*a, **ka)\n return wrapper\n return decorator","function_tokens":["def","auth_basic","(","check",",","realm","=","\"private\"",",","text","=","\"Access denied\"",")",":","def","decorator","(","func",")",":","def","wrapper","(","*","a",",","*","*","ka",")",":","user",",","password","=","request",".","auth","or","(","None",",","None",")","if","user","is","None","or","not","check","(","user",",","password",")",":","response",".","headers","[","'WWW-Authenticate'","]","=","'Basic realm=\"%s\"'","%","realm","return","HTTPError","(","401",",","text",")","return","func","(","*","a",",","*","*","ka",")","return","wrapper","return","decorator"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2296-L2307"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"make_default_app_wrapper","parameters":"(name)","argument_list":"","return_statement":"return wrapper","docstring":"Return a callable that relays calls to the current default app.","docstring_summary":"Return a callable that relays calls to the current default app.","docstring_tokens":["Return","a","callable","that","relays","calls","to","the","current","default","app","."],"function":"def make_default_app_wrapper(name):\n ''' Return a callable that relays calls to the current default app. '''\n @functools.wraps(getattr(Bottle, name))\n def wrapper(*a, **ka):\n return getattr(app(), name)(*a, **ka)\n return wrapper","function_tokens":["def","make_default_app_wrapper","(","name",")",":","@","functools",".","wraps","(","getattr","(","Bottle",",","name",")",")","def","wrapper","(","*","a",",","*","*","ka",")",":","return","getattr","(","app","(",")",",","name",")","(","*","a",",","*","*","ka",")","return","wrapper"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2313-L2318"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"load","parameters":"(target, **namespace)","argument_list":"","return_statement":"return eval('%s.%s' % (module, target), namespace)","docstring":"Import a module or fetch an object from a module.\n\n * ``package.module`` returns `module` as a module object.\n * ``pack.mod:name`` returns the module variable `name` from `pack.mod`.\n * ``pack.mod:func()`` calls `pack.mod.func()` and returns the result.\n\n The last form accepts not only function calls, but any type of\n expression. Keyword arguments passed to this function are available as\n local variables. Example: ``import_string('re:compile(x)', x='[a-z]')``","docstring_summary":"Import a module or fetch an object from a module.","docstring_tokens":["Import","a","module","or","fetch","an","object","from","a","module","."],"function":"def load(target, **namespace):\n \"\"\" Import a module or fetch an object from a module.\n\n * ``package.module`` returns `module` as a module object.\n * ``pack.mod:name`` returns the module variable `name` from `pack.mod`.\n * ``pack.mod:func()`` calls `pack.mod.func()` and returns the result.\n\n The last form accepts not only function calls, but any type of\n expression. Keyword arguments passed to this function are available as\n local variables. Example: ``import_string('re:compile(x)', x='[a-z]')``\n \"\"\"\n module, target = target.split(\":\", 1) if ':' in target else (target, None)\n if module not in sys.modules: __import__(module)\n if not target: return sys.modules[module]\n if target.isalnum(): return getattr(sys.modules[module], target)\n package_name = module.split('.')[0]\n namespace[package_name] = sys.modules[package_name]\n return eval('%s.%s' % (module, target), namespace)","function_tokens":["def","load","(","target",",","*","*","namespace",")",":","module",",","target","=","target",".","split","(","\":\"",",","1",")","if","':'","in","target","else","(","target",",","None",")","if","module","not","in","sys",".","modules",":","__import__","(","module",")","if","not","target",":","return","sys",".","modules","[","module","]","if","target",".","isalnum","(",")",":","return","getattr","(","sys",".","modules","[","module","]",",","target",")","package_name","=","module",".","split","(","'.'",")","[","0","]","namespace","[","package_name","]","=","sys",".","modules","[","package_name","]","return","eval","(","'%s.%s'","%","(","module",",","target",")",",","namespace",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2588-L2605"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"load_app","parameters":"(target)","argument_list":"","return_statement":"","docstring":"Load a bottle application from a module and make sure that the import\n does not affect the current default application, but returns a separate\n application object. See :func:`load` for the target parameter.","docstring_summary":"Load a bottle application from a module and make sure that the import\n does not affect the current default application, but returns a separate\n application object. See :func:`load` for the target parameter.","docstring_tokens":["Load","a","bottle","application","from","a","module","and","make","sure","that","the","import","does","not","affect","the","current","default","application","but","returns","a","separate","application","object",".","See",":","func",":","load","for","the","target","parameter","."],"function":"def load_app(target):\n \"\"\" Load a bottle application from a module and make sure that the import\n does not affect the current default application, but returns a separate\n application object. See :func:`load` for the target parameter. \"\"\"\n global NORUN; NORUN, nr_old = True, NORUN\n try:\n tmp = default_app.push() # Create a new \"default application\"\n rv = load(target) # Import the target module\n return rv if callable(rv) else tmp\n finally:\n default_app.remove(tmp) # Remove the temporary added default application\n NORUN = nr_old","function_tokens":["def","load_app","(","target",")",":","global","NORUN","NORUN",",","nr_old","=","True",",","NORUN","try",":","tmp","=","default_app",".","push","(",")","# Create a new \"default application\"","rv","=","load","(","target",")","# Import the target module","return","rv","if","callable","(","rv",")","else","tmp","finally",":","default_app",".","remove","(","tmp",")","# Remove the temporary added default application","NORUN","=","nr_old"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2608-L2619"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"run","parameters":"(app=None, server='wsgiref', host='127.0.0.1', port=8080,\n interval=1, reloader=False, quiet=False, plugins=None,\n debug=False, **kargs)","argument_list":"","return_statement":"","docstring":"Start a server instance. This method blocks until the server terminates.\n\n :param app: WSGI application or target string supported by\n :func:`load_app`. (default: :func:`default_app`)\n :param server: Server adapter to use. See :data:`server_names` keys\n for valid names or pass a :class:`ServerAdapter` subclass.\n (default: `wsgiref`)\n :param host: Server address to bind to. Pass ``0.0.0.0`` to listens on\n all interfaces including the external one. (default: 127.0.0.1)\n :param port: Server port to bind to. Values below 1024 require root\n privileges. (default: 8080)\n :param reloader: Start auto-reloading server? (default: False)\n :param interval: Auto-reloader interval in seconds (default: 1)\n :param quiet: Suppress output to stdout and stderr? (default: False)\n :param options: Options passed to the server adapter.","docstring_summary":"Start a server instance. This method blocks until the server terminates.","docstring_tokens":["Start","a","server","instance",".","This","method","blocks","until","the","server","terminates","."],"function":"def run(app=None, server='wsgiref', host='127.0.0.1', port=8080,\n interval=1, reloader=False, quiet=False, plugins=None,\n debug=False, **kargs):\n \"\"\" Start a server instance. This method blocks until the server terminates.\n\n :param app: WSGI application or target string supported by\n :func:`load_app`. (default: :func:`default_app`)\n :param server: Server adapter to use. See :data:`server_names` keys\n for valid names or pass a :class:`ServerAdapter` subclass.\n (default: `wsgiref`)\n :param host: Server address to bind to. Pass ``0.0.0.0`` to listens on\n all interfaces including the external one. (default: 127.0.0.1)\n :param port: Server port to bind to. Values below 1024 require root\n privileges. (default: 8080)\n :param reloader: Start auto-reloading server? (default: False)\n :param interval: Auto-reloader interval in seconds (default: 1)\n :param quiet: Suppress output to stdout and stderr? (default: False)\n :param options: Options passed to the server adapter.\n \"\"\"\n if NORUN: return\n if reloader and not os.environ.get('BOTTLE_CHILD'):\n try:\n lockfile = None\n fd, lockfile = tempfile.mkstemp(prefix='bottle.', suffix='.lock')\n os.close(fd) # We only need this file to exist. We never write to it\n while os.path.exists(lockfile):\n args = [sys.executable] + sys.argv\n environ = os.environ.copy()\n environ['BOTTLE_CHILD'] = 'true'\n environ['BOTTLE_LOCKFILE'] = lockfile\n p = subprocess.Popen(args, env=environ)\n while p.poll() is None: # Busy wait...\n os.utime(lockfile, None) # I am alive!\n time.sleep(interval)\n if p.poll() != 3:\n if os.path.exists(lockfile): os.unlink(lockfile)\n sys.exit(p.poll())\n except KeyboardInterrupt:\n pass\n finally:\n if os.path.exists(lockfile):\n os.unlink(lockfile)\n return\n\n try:\n _debug(debug)\n app = app or default_app()\n if isinstance(app, basestring):\n app = load_app(app)\n if not callable(app):\n raise ValueError(\"Application is not callable: %r\" % app)\n\n for plugin in plugins or []:\n app.install(plugin)\n\n if server in server_names:\n server = server_names.get(server)\n if isinstance(server, basestring):\n server = load(server)\n if isinstance(server, type):\n server = server(host=host, port=port, **kargs)\n if not isinstance(server, ServerAdapter):\n raise ValueError(\"Unknown or unsupported server: %r\" % server)\n\n server.quiet = server.quiet or quiet\n if not server.quiet:\n _stderr(\"Bottle v%s server starting up (using %s)...\\n\" % (__version__, repr(server)))\n _stderr(\"Listening on http:\/\/%s:%d\/\\n\" % (server.host, server.port))\n _stderr(\"Hit Ctrl-C to quit.\\n\\n\")\n\n if reloader:\n lockfile = os.environ.get('BOTTLE_LOCKFILE')\n bgcheck = FileCheckerThread(lockfile, interval)\n with bgcheck:\n server.run(app)\n if bgcheck.status == 'reload':\n sys.exit(3)\n else:\n server.run(app)\n except KeyboardInterrupt:\n pass\n except (SystemExit, MemoryError):\n raise\n except:\n if not reloader: raise\n if not getattr(server, 'quiet', quiet):\n print_exc()\n time.sleep(interval)\n sys.exit(3)","function_tokens":["def","run","(","app","=","None",",","server","=","'wsgiref'",",","host","=","'127.0.0.1'",",","port","=","8080",",","interval","=","1",",","reloader","=","False",",","quiet","=","False",",","plugins","=","None",",","debug","=","False",",","*","*","kargs",")",":","if","NORUN",":","return","if","reloader","and","not","os",".","environ",".","get","(","'BOTTLE_CHILD'",")",":","try",":","lockfile","=","None","fd",",","lockfile","=","tempfile",".","mkstemp","(","prefix","=","'bottle.'",",","suffix","=","'.lock'",")","os",".","close","(","fd",")","# We only need this file to exist. We never write to it","while","os",".","path",".","exists","(","lockfile",")",":","args","=","[","sys",".","executable","]","+","sys",".","argv","environ","=","os",".","environ",".","copy","(",")","environ","[","'BOTTLE_CHILD'","]","=","'true'","environ","[","'BOTTLE_LOCKFILE'","]","=","lockfile","p","=","subprocess",".","Popen","(","args",",","env","=","environ",")","while","p",".","poll","(",")","is","None",":","# Busy wait...","os",".","utime","(","lockfile",",","None",")","# I am alive!","time",".","sleep","(","interval",")","if","p",".","poll","(",")","!=","3",":","if","os",".","path",".","exists","(","lockfile",")",":","os",".","unlink","(","lockfile",")","sys",".","exit","(","p",".","poll","(",")",")","except","KeyboardInterrupt",":","pass","finally",":","if","os",".","path",".","exists","(","lockfile",")",":","os",".","unlink","(","lockfile",")","return","try",":","_debug","(","debug",")","app","=","app","or","default_app","(",")","if","isinstance","(","app",",","basestring",")",":","app","=","load_app","(","app",")","if","not","callable","(","app",")",":","raise","ValueError","(","\"Application is not callable: %r\"","%","app",")","for","plugin","in","plugins","or","[","]",":","app",".","install","(","plugin",")","if","server","in","server_names",":","server","=","server_names",".","get","(","server",")","if","isinstance","(","server",",","basestring",")",":","server","=","load","(","server",")","if","isinstance","(","server",",","type",")",":","server","=","server","(","host","=","host",",","port","=","port",",","*","*","kargs",")","if","not","isinstance","(","server",",","ServerAdapter",")",":","raise","ValueError","(","\"Unknown or unsupported server: %r\"","%","server",")","server",".","quiet","=","server",".","quiet","or","quiet","if","not","server",".","quiet",":","_stderr","(","\"Bottle v%s server starting up (using %s)...\\n\"","%","(","__version__",",","repr","(","server",")",")",")","_stderr","(","\"Listening on http:\/\/%s:%d\/\\n\"","%","(","server",".","host",",","server",".","port",")",")","_stderr","(","\"Hit Ctrl-C to quit.\\n\\n\"",")","if","reloader",":","lockfile","=","os",".","environ",".","get","(","'BOTTLE_LOCKFILE'",")","bgcheck","=","FileCheckerThread","(","lockfile",",","interval",")","with","bgcheck",":","server",".","run","(","app",")","if","bgcheck",".","status","==","'reload'",":","sys",".","exit","(","3",")","else",":","server",".","run","(","app",")","except","KeyboardInterrupt",":","pass","except","(","SystemExit",",","MemoryError",")",":","raise","except",":","if","not","reloader",":","raise","if","not","getattr","(","server",",","'quiet'",",","quiet",")",":","print_exc","(",")","time",".","sleep","(","interval",")","sys",".","exit","(","3",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2622-L2710"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"template","parameters":"(*args, **kwargs)","argument_list":"","return_statement":"return TEMPLATES[tplid].render(kwargs)","docstring":"Get a rendered template as a string iterator.\n You can use a name, a filename or a template string as first parameter.\n Template rendering arguments can be passed as dictionaries\n or directly (as keyword arguments).","docstring_summary":"Get a rendered template as a string iterator.\n You can use a name, a filename or a template string as first parameter.\n Template rendering arguments can be passed as dictionaries\n or directly (as keyword arguments).","docstring_tokens":["Get","a","rendered","template","as","a","string","iterator",".","You","can","use","a","name","a","filename","or","a","template","string","as","first","parameter",".","Template","rendering","arguments","can","be","passed","as","dictionaries","or","directly","(","as","keyword","arguments",")","."],"function":"def template(*args, **kwargs):\n '''\n Get a rendered template as a string iterator.\n You can use a name, a filename or a template string as first parameter.\n Template rendering arguments can be passed as dictionaries\n or directly (as keyword arguments).\n '''\n tpl = args[0] if args else None\n adapter = kwargs.pop('template_adapter', SimpleTemplate)\n lookup = kwargs.pop('template_lookup', TEMPLATE_PATH)\n tplid = (id(lookup), tpl)\n if tpl not in TEMPLATES or DEBUG:\n settings = kwargs.pop('template_settings', {})\n if isinstance(tpl, adapter):\n TEMPLATES[tplid] = tpl\n if settings: TEMPLATES[tplid].prepare(**settings)\n elif \"\\n\" in tpl or \"{\" in tpl or \"%\" in tpl or '$' in tpl:\n TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings)\n else:\n TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings)\n if not TEMPLATES[tplid]:\n abort(500, 'Template (%s) not found' % tpl)\n for dictarg in args[1:]: kwargs.update(dictarg)\n return TEMPLATES[tplid].render(kwargs)","function_tokens":["def","template","(","*","args",",","*","*","kwargs",")",":","tpl","=","args","[","0","]","if","args","else","None","adapter","=","kwargs",".","pop","(","'template_adapter'",",","SimpleTemplate",")","lookup","=","kwargs",".","pop","(","'template_lookup'",",","TEMPLATE_PATH",")","tplid","=","(","id","(","lookup",")",",","tpl",")","if","tpl","not","in","TEMPLATES","or","DEBUG",":","settings","=","kwargs",".","pop","(","'template_settings'",",","{","}",")","if","isinstance","(","tpl",",","adapter",")",":","TEMPLATES","[","tplid","]","=","tpl","if","settings",":","TEMPLATES","[","tplid","]",".","prepare","(","*","*","settings",")","elif","\"\\n\"","in","tpl","or","\"{\"","in","tpl","or","\"%\"","in","tpl","or","'$'","in","tpl",":","TEMPLATES","[","tplid","]","=","adapter","(","source","=","tpl",",","lookup","=","lookup",",","*","*","settings",")","else",":","TEMPLATES","[","tplid","]","=","adapter","(","name","=","tpl",",","lookup","=","lookup",",","*","*","settings",")","if","not","TEMPLATES","[","tplid","]",":","abort","(","500",",","'Template (%s) not found'","%","tpl",")","for","dictarg","in","args","[","1",":","]",":","kwargs",".","update","(","dictarg",")","return","TEMPLATES","[","tplid","]",".","render","(","kwargs",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L3091-L3114"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"view","parameters":"(tpl_name, **defaults)","argument_list":"","return_statement":"return decorator","docstring":"Decorator: renders a template for a handler.\n The handler can control its behavior like that:\n\n - return a dict of template vars to fill out the template\n - return something other than a dict and the view decorator will not\n process the template, but return the handler result as is.\n This includes returning a HTTPResponse(dict) to get,\n for instance, JSON with autojson or other castfilters.","docstring_summary":"Decorator: renders a template for a handler.\n The handler can control its behavior like that:","docstring_tokens":["Decorator",":","renders","a","template","for","a","handler",".","The","handler","can","control","its","behavior","like","that",":"],"function":"def view(tpl_name, **defaults):\n ''' Decorator: renders a template for a handler.\n The handler can control its behavior like that:\n\n - return a dict of template vars to fill out the template\n - return something other than a dict and the view decorator will not\n process the template, but return the handler result as is.\n This includes returning a HTTPResponse(dict) to get,\n for instance, JSON with autojson or other castfilters.\n '''\n def decorator(func):\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n result = func(*args, **kwargs)\n if isinstance(result, (dict, DictMixin)):\n tplvars = defaults.copy()\n tplvars.update(result)\n return template(tpl_name, **tplvars)\n return result\n return wrapper\n return decorator","function_tokens":["def","view","(","tpl_name",",","*","*","defaults",")",":","def","decorator","(","func",")",":","@","functools",".","wraps","(","func",")","def","wrapper","(","*","args",",","*","*","kwargs",")",":","result","=","func","(","*","args",",","*","*","kwargs",")","if","isinstance","(","result",",","(","dict",",","DictMixin",")",")",":","tplvars","=","defaults",".","copy","(",")","tplvars",".","update","(","result",")","return","template","(","tpl_name",",","*","*","tplvars",")","return","result","return","wrapper","return","decorator"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L3122-L3142"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Router.add_filter","parameters":"(self, name, func)","argument_list":"","return_statement":"","docstring":"Add a filter. The provided function is called with the configuration\n string as parameter and must return a (regexp, to_python, to_url) tuple.\n The first element is a string, the last two are callables or None.","docstring_summary":"Add a filter. The provided function is called with the configuration\n string as parameter and must return a (regexp, to_python, to_url) tuple.\n The first element is a string, the last two are callables or None.","docstring_tokens":["Add","a","filter",".","The","provided","function","is","called","with","the","configuration","string","as","parameter","and","must","return","a","(","regexp","to_python","to_url",")","tuple",".","The","first","element","is","a","string","the","last","two","are","callables","or","None","."],"function":"def add_filter(self, name, func):\n ''' Add a filter. The provided function is called with the configuration\n string as parameter and must return a (regexp, to_python, to_url) tuple.\n The first element is a string, the last two are callables or None. '''\n self.filters[name] = func","function_tokens":["def","add_filter","(","self",",","name",",","func",")",":","self",".","filters","[","name","]","=","func"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L285-L289"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Router.parse_rule","parameters":"(self, rule)","argument_list":"","return_statement":"","docstring":"Parses a rule into a (name, filter, conf) token stream. If mode is\n None, name contains a static rule part.","docstring_summary":"Parses a rule into a (name, filter, conf) token stream. If mode is\n None, name contains a static rule part.","docstring_tokens":["Parses","a","rule","into","a","(","name","filter","conf",")","token","stream",".","If","mode","is","None","name","contains","a","static","rule","part","."],"function":"def parse_rule(self, rule):\n ''' Parses a rule into a (name, filter, conf) token stream. If mode is\n None, name contains a static rule part. '''\n offset, prefix = 0, ''\n for match in self.rule_syntax.finditer(rule):\n prefix += rule[offset:match.start()]\n g = match.groups()\n if len(g[0])%2: # Escaped wildcard\n prefix += match.group(0)[len(g[0]):]\n offset = match.end()\n continue\n if prefix: yield prefix, None, None\n name, filtr, conf = g[1:4] if not g[2] is None else g[4:7]\n if not filtr: filtr = self.default_filter\n yield name, filtr, conf or None\n offset, prefix = match.end(), ''\n if offset <= len(rule) or prefix:\n yield prefix+rule[offset:], None, None","function_tokens":["def","parse_rule","(","self",",","rule",")",":","offset",",","prefix","=","0",",","''","for","match","in","self",".","rule_syntax",".","finditer","(","rule",")",":","prefix","+=","rule","[","offset",":","match",".","start","(",")","]","g","=","match",".","groups","(",")","if","len","(","g","[","0","]",")","%","2",":","# Escaped wildcard","prefix","+=","match",".","group","(","0",")","[","len","(","g","[","0","]",")",":","]","offset","=","match",".","end","(",")","continue","if","prefix",":","yield","prefix",",","None",",","None","name",",","filtr",",","conf","=","g","[","1",":","4","]","if","not","g","[","2","]","is","None","else","g","[","4",":","7","]","if","not","filtr",":","filtr","=","self",".","default_filter","yield","name",",","filtr",",","conf","or","None","offset",",","prefix","=","match",".","end","(",")",",","''","if","offset","<=","len","(","rule",")","or","prefix",":","yield","prefix","+","rule","[","offset",":","]",",","None",",","None"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L291-L308"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Router.add","parameters":"(self, rule, method, target, name=None)","argument_list":"","return_statement":"return match","docstring":"Add a new route or replace the target for an existing route.","docstring_summary":"Add a new route or replace the target for an existing route.","docstring_tokens":["Add","a","new","route","or","replace","the","target","for","an","existing","route","."],"function":"def add(self, rule, method, target, name=None):\n ''' Add a new route or replace the target for an existing route. '''\n if rule in self.rules:\n self.rules[rule][method] = target\n if name: self.builder[name] = self.builder[rule]\n return\n\n target = self.rules[rule] = {method: target}\n\n # Build pattern and other structures for dynamic routes\n anons = 0 # Number of anonymous wildcards\n pattern = '' # Regular expression pattern\n filters = [] # Lists of wildcard input filters\n builder = [] # Data structure for the URL builder\n is_static = True\n for key, mode, conf in self.parse_rule(rule):\n if mode:\n is_static = False\n mask, in_filter, out_filter = self.filters[mode](conf)\n if key:\n pattern += '(?P<%s>%s)' % (key, mask)\n else:\n pattern += '(?:%s)' % mask\n key = 'anon%d' % anons; anons += 1\n if in_filter: filters.append((key, in_filter))\n builder.append((key, out_filter or str))\n elif key:\n pattern += re.escape(key)\n builder.append((None, key))\n self.builder[rule] = builder\n if name: self.builder[name] = builder\n\n if is_static and not self.strict_order:\n self.static[self.build(rule)] = target\n return\n\n def fpat_sub(m):\n return m.group(0) if len(m.group(1)) % 2 else m.group(1) + '(?:'\n flat_pattern = re.sub(r'(\\\\*)(\\(\\?P<[^>]*>|\\((?!\\?))', fpat_sub, pattern)\n\n try:\n re_match = re.compile('^(%s)$' % pattern).match\n except re.error:\n raise RouteSyntaxError(\"Could not add Route: %s (%s)\" % (rule, _e()))\n\n def match(path):\n \"\"\" Return an url-argument dictionary. \"\"\"\n url_args = re_match(path).groupdict()\n for name, wildcard_filter in filters:\n try:\n url_args[name] = wildcard_filter(url_args[name])\n except ValueError:\n raise HTTPError(400, 'Path has wrong format.')\n return url_args\n\n try:\n combined = '%s|(^%s$)' % (self.dynamic[-1][0].pattern, flat_pattern)\n self.dynamic[-1] = (re.compile(combined), self.dynamic[-1][1])\n self.dynamic[-1][1].append((match, target))\n except (AssertionError, IndexError): # AssertionError: Too many groups\n self.dynamic.append((re.compile('(^%s$)' % flat_pattern),\n [(match, target)]))\n return match","function_tokens":["def","add","(","self",",","rule",",","method",",","target",",","name","=","None",")",":","if","rule","in","self",".","rules",":","self",".","rules","[","rule","]","[","method","]","=","target","if","name",":","self",".","builder","[","name","]","=","self",".","builder","[","rule","]","return","target","=","self",".","rules","[","rule","]","=","{","method",":","target","}","# Build pattern and other structures for dynamic routes","anons","=","0","# Number of anonymous wildcards","pattern","=","''","# Regular expression pattern","filters","=","[","]","# Lists of wildcard input filters","builder","=","[","]","# Data structure for the URL builder","is_static","=","True","for","key",",","mode",",","conf","in","self",".","parse_rule","(","rule",")",":","if","mode",":","is_static","=","False","mask",",","in_filter",",","out_filter","=","self",".","filters","[","mode","]","(","conf",")","if","key",":","pattern","+=","'(?P<%s>%s)'","%","(","key",",","mask",")","else",":","pattern","+=","'(?:%s)'","%","mask","key","=","'anon%d'","%","anons","anons","+=","1","if","in_filter",":","filters",".","append","(","(","key",",","in_filter",")",")","builder",".","append","(","(","key",",","out_filter","or","str",")",")","elif","key",":","pattern","+=","re",".","escape","(","key",")","builder",".","append","(","(","None",",","key",")",")","self",".","builder","[","rule","]","=","builder","if","name",":","self",".","builder","[","name","]","=","builder","if","is_static","and","not","self",".","strict_order",":","self",".","static","[","self",".","build","(","rule",")","]","=","target","return","def","fpat_sub","(","m",")",":","return","m",".","group","(","0",")","if","len","(","m",".","group","(","1",")",")","%","2","else","m",".","group","(","1",")","+","'(?:'","flat_pattern","=","re",".","sub","(","r'(\\\\*)(\\(\\?P<[^>]*>|\\((?!\\?))'",",","fpat_sub",",","pattern",")","try",":","re_match","=","re",".","compile","(","'^(%s)$'","%","pattern",")",".","match","except","re",".","error",":","raise","RouteSyntaxError","(","\"Could not add Route: %s (%s)\"","%","(","rule",",","_e","(",")",")",")","def","match","(","path",")",":","\"\"\" Return an url-argument dictionary. \"\"\"","url_args","=","re_match","(","path",")",".","groupdict","(",")","for","name",",","wildcard_filter","in","filters",":","try",":","url_args","[","name","]","=","wildcard_filter","(","url_args","[","name","]",")","except","ValueError",":","raise","HTTPError","(","400",",","'Path has wrong format.'",")","return","url_args","try",":","combined","=","'%s|(^%s$)'","%","(","self",".","dynamic","[","-","1","]","[","0","]",".","pattern",",","flat_pattern",")","self",".","dynamic","[","-","1","]","=","(","re",".","compile","(","combined",")",",","self",".","dynamic","[","-","1","]","[","1","]",")","self",".","dynamic","[","-","1","]","[","1","]",".","append","(","(","match",",","target",")",")","except","(","AssertionError",",","IndexError",")",":","# AssertionError: Too many groups","self",".","dynamic",".","append","(","(","re",".","compile","(","'(^%s$)'","%","flat_pattern",")",",","[","(","match",",","target",")","]",")",")","return","match"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L310-L372"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Router.build","parameters":"(self, _name, *anons, **query)","argument_list":"","return_statement":"","docstring":"Build an URL by filling the wildcards in a rule.","docstring_summary":"Build an URL by filling the wildcards in a rule.","docstring_tokens":["Build","an","URL","by","filling","the","wildcards","in","a","rule","."],"function":"def build(self, _name, *anons, **query):\n ''' Build an URL by filling the wildcards in a rule. '''\n builder = self.builder.get(_name)\n if not builder: raise RouteBuildError(\"No route with that name.\", _name)\n try:\n for i, value in enumerate(anons): query['anon%d'%i] = value\n url = ''.join([f(query.pop(n)) if n else f for (n,f) in builder])\n return url if not query else url+'?'+urlencode(query)\n except KeyError:\n raise RouteBuildError('Missing URL argument: %r' % _e().args[0])","function_tokens":["def","build","(","self",",","_name",",","*","anons",",","*","*","query",")",":","builder","=","self",".","builder",".","get","(","_name",")","if","not","builder",":","raise","RouteBuildError","(","\"No route with that name.\"",",","_name",")","try",":","for","i",",","value","in","enumerate","(","anons",")",":","query","[","'anon%d'","%","i","]","=","value","url","=","''",".","join","(","[","f","(","query",".","pop","(","n",")",")","if","n","else","f","for","(","n",",","f",")","in","builder","]",")","return","url","if","not","query","else","url","+","'?'","+","urlencode","(","query",")","except","KeyError",":","raise","RouteBuildError","(","'Missing URL argument: %r'","%","_e","(",")",".","args","[","0","]",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L374-L383"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Router.match","parameters":"(self, environ)","argument_list":"","return_statement":"","docstring":"Return a (target, url_agrs) tuple or raise HTTPError(400\/404\/405).","docstring_summary":"Return a (target, url_agrs) tuple or raise HTTPError(400\/404\/405).","docstring_tokens":["Return","a","(","target","url_agrs",")","tuple","or","raise","HTTPError","(","400","\/","404","\/","405",")","."],"function":"def match(self, environ):\n ''' Return a (target, url_agrs) tuple or raise HTTPError(400\/404\/405). '''\n path, targets, urlargs = environ['PATH_INFO'] or '\/', None, {}\n if path in self.static:\n targets = self.static[path]\n else:\n for combined, rules in self.dynamic:\n match = combined.match(path)\n if not match: continue\n getargs, targets = rules[match.lastindex - 1]\n urlargs = getargs(path) if getargs else {}\n break\n\n if not targets:\n raise HTTPError(404, \"Not found: \" + repr(environ['PATH_INFO']))\n method = environ['REQUEST_METHOD'].upper()\n if method in targets:\n return targets[method], urlargs\n if method == 'HEAD' and 'GET' in targets:\n return targets['GET'], urlargs\n if 'ANY' in targets:\n return targets['ANY'], urlargs\n allowed = [verb for verb in targets if verb != 'ANY']\n if 'GET' in allowed and 'HEAD' not in allowed:\n allowed.append('HEAD')\n raise HTTPError(405, \"Method not allowed.\", Allow=\",\".join(allowed))","function_tokens":["def","match","(","self",",","environ",")",":","path",",","targets",",","urlargs","=","environ","[","'PATH_INFO'","]","or","'\/'",",","None",",","{","}","if","path","in","self",".","static",":","targets","=","self",".","static","[","path","]","else",":","for","combined",",","rules","in","self",".","dynamic",":","match","=","combined",".","match","(","path",")","if","not","match",":","continue","getargs",",","targets","=","rules","[","match",".","lastindex","-","1","]","urlargs","=","getargs","(","path",")","if","getargs","else","{","}","break","if","not","targets",":","raise","HTTPError","(","404",",","\"Not found: \"","+","repr","(","environ","[","'PATH_INFO'","]",")",")","method","=","environ","[","'REQUEST_METHOD'","]",".","upper","(",")","if","method","in","targets",":","return","targets","[","method","]",",","urlargs","if","method","==","'HEAD'","and","'GET'","in","targets",":","return","targets","[","'GET'","]",",","urlargs","if","'ANY'","in","targets",":","return","targets","[","'ANY'","]",",","urlargs","allowed","=","[","verb","for","verb","in","targets","if","verb","!=","'ANY'","]","if","'GET'","in","allowed","and","'HEAD'","not","in","allowed",":","allowed",".","append","(","'HEAD'",")","raise","HTTPError","(","405",",","\"Method not allowed.\"",",","Allow","=","\",\"",".","join","(","allowed",")",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L385-L410"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Route.call","parameters":"(self)","argument_list":"","return_statement":"return self._make_callback()","docstring":"The route callback with all plugins applied. This property is\n created on demand and then cached to speed up subsequent requests.","docstring_summary":"The route callback with all plugins applied. This property is\n created on demand and then cached to speed up subsequent requests.","docstring_tokens":["The","route","callback","with","all","plugins","applied",".","This","property","is","created","on","demand","and","then","cached","to","speed","up","subsequent","requests","."],"function":"def call(self):\n ''' The route callback with all plugins applied. This property is\n created on demand and then cached to speed up subsequent requests.'''\n return self._make_callback()","function_tokens":["def","call","(","self",")",":","return","self",".","_make_callback","(",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L447-L450"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Route.reset","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Forget any cached values. The next time :attr:`call` is accessed,\n all plugins are re-applied.","docstring_summary":"Forget any cached values. The next time :attr:`call` is accessed,\n all plugins are re-applied.","docstring_tokens":["Forget","any","cached","values",".","The","next","time",":","attr",":","call","is","accessed","all","plugins","are","re","-","applied","."],"function":"def reset(self):\n ''' Forget any cached values. The next time :attr:`call` is accessed,\n all plugins are re-applied. '''\n self.__dict__.pop('call', None)","function_tokens":["def","reset","(","self",")",":","self",".","__dict__",".","pop","(","'call'",",","None",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L452-L455"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Route.prepare","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Do all on-demand work immediately (useful for debugging).","docstring_summary":"Do all on-demand work immediately (useful for debugging).","docstring_tokens":["Do","all","on","-","demand","work","immediately","(","useful","for","debugging",")","."],"function":"def prepare(self):\n ''' Do all on-demand work immediately (useful for debugging).'''\n self.call","function_tokens":["def","prepare","(","self",")",":","self",".","call"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L457-L459"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Route.all_plugins","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Yield all Plugins affecting this route.","docstring_summary":"Yield all Plugins affecting this route.","docstring_tokens":["Yield","all","Plugins","affecting","this","route","."],"function":"def all_plugins(self):\n ''' Yield all Plugins affecting this route. '''\n unique = set()\n for p in reversed(self.app.plugins + self.plugins):\n if True in self.skiplist: break\n name = getattr(p, 'name', False)\n if name and (name in self.skiplist or name in unique): continue\n if p in self.skiplist or type(p) in self.skiplist: continue\n if name: unique.add(name)\n yield p","function_tokens":["def","all_plugins","(","self",")",":","unique","=","set","(",")","for","p","in","reversed","(","self",".","app",".","plugins","+","self",".","plugins",")",":","if","True","in","self",".","skiplist",":","break","name","=","getattr","(","p",",","'name'",",","False",")","if","name","and","(","name","in","self",".","skiplist","or","name","in","unique",")",":","continue","if","p","in","self",".","skiplist","or","type","(","p",")","in","self",".","skiplist",":","continue","if","name",":","unique",".","add","(","name",")","yield","p"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L468-L477"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.mount","parameters":"(self, prefix, app, **options)","argument_list":"","return_statement":"","docstring":"Mount an application (:class:`Bottle` or plain WSGI) to a specific\n URL prefix. Example::\n\n root_app.mount('\/admin\/', admin_app)\n\n :param prefix: path prefix or `mount-point`. If it ends in a slash,\n that slash is mandatory.\n :param app: an instance of :class:`Bottle` or a WSGI application.\n\n All other parameters are passed to the underlying :meth:`route` call.","docstring_summary":"Mount an application (:class:`Bottle` or plain WSGI) to a specific\n URL prefix. Example::","docstring_tokens":["Mount","an","application","(",":","class",":","Bottle","or","plain","WSGI",")","to","a","specific","URL","prefix",".","Example","::"],"function":"def mount(self, prefix, app, **options):\n ''' Mount an application (:class:`Bottle` or plain WSGI) to a specific\n URL prefix. Example::\n\n root_app.mount('\/admin\/', admin_app)\n\n :param prefix: path prefix or `mount-point`. If it ends in a slash,\n that slash is mandatory.\n :param app: an instance of :class:`Bottle` or a WSGI application.\n\n All other parameters are passed to the underlying :meth:`route` call.\n '''\n if isinstance(app, basestring):\n prefix, app = app, prefix\n depr('Parameter order of Bottle.mount() changed.') # 0.10\n\n segments = [p for p in prefix.split('\/') if p]\n if not segments: raise ValueError('Empty path prefix.')\n path_depth = len(segments)\n\n def mountpoint_wrapper():\n try:\n request.path_shift(path_depth)\n rs = BaseResponse([], 200)\n def start_response(status, header):\n rs.status = status\n for name, value in header: rs.add_header(name, value)\n return rs.body.append\n body = app(request.environ, start_response)\n body = itertools.chain(rs.body, body)\n return HTTPResponse(body, rs.status_code, rs.headers)\n finally:\n request.path_shift(-path_depth)\n\n options.setdefault('skip', True)\n options.setdefault('method', 'ANY')\n options.setdefault('mountpoint', {'prefix': prefix, 'target': app})\n options['callback'] = mountpoint_wrapper\n\n self.route('\/%s\/<:re:.*>' % '\/'.join(segments), **options)\n if not prefix.endswith('\/'):\n self.route('\/' + '\/'.join(segments), **options)","function_tokens":["def","mount","(","self",",","prefix",",","app",",","*","*","options",")",":","if","isinstance","(","app",",","basestring",")",":","prefix",",","app","=","app",",","prefix","depr","(","'Parameter order of Bottle.mount() changed.'",")","# 0.10","segments","=","[","p","for","p","in","prefix",".","split","(","'\/'",")","if","p","]","if","not","segments",":","raise","ValueError","(","'Empty path prefix.'",")","path_depth","=","len","(","segments",")","def","mountpoint_wrapper","(",")",":","try",":","request",".","path_shift","(","path_depth",")","rs","=","BaseResponse","(","[","]",",","200",")","def","start_response","(","status",",","header",")",":","rs",".","status","=","status","for","name",",","value","in","header",":","rs",".","add_header","(","name",",","value",")","return","rs",".","body",".","append","body","=","app","(","request",".","environ",",","start_response",")","body","=","itertools",".","chain","(","rs",".","body",",","body",")","return","HTTPResponse","(","body",",","rs",".","status_code",",","rs",".","headers",")","finally",":","request",".","path_shift","(","-","path_depth",")","options",".","setdefault","(","'skip'",",","True",")","options",".","setdefault","(","'method'",",","'ANY'",")","options",".","setdefault","(","'mountpoint'",",","{","'prefix'",":","prefix",",","'target'",":","app","}",")","options","[","'callback'","]","=","mountpoint_wrapper","self",".","route","(","'\/%s\/<:re:.*>'","%","'\/'",".","join","(","segments",")",",","*","*","options",")","if","not","prefix",".","endswith","(","'\/'",")",":","self",".","route","(","'\/'","+","'\/'",".","join","(","segments",")",",","*","*","options",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L541-L582"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.merge","parameters":"(self, routes)","argument_list":"","return_statement":"","docstring":"Merge the routes of another :class:`Bottle` application or a list of\n :class:`Route` objects into this application. The routes keep their\n 'owner', meaning that the :data:`Route.app` attribute is not\n changed.","docstring_summary":"Merge the routes of another :class:`Bottle` application or a list of\n :class:`Route` objects into this application. The routes keep their\n 'owner', meaning that the :data:`Route.app` attribute is not\n changed.","docstring_tokens":["Merge","the","routes","of","another",":","class",":","Bottle","application","or","a","list","of",":","class",":","Route","objects","into","this","application",".","The","routes","keep","their","owner","meaning","that","the",":","data",":","Route",".","app","attribute","is","not","changed","."],"function":"def merge(self, routes):\n ''' Merge the routes of another :class:`Bottle` application or a list of\n :class:`Route` objects into this application. The routes keep their\n 'owner', meaning that the :data:`Route.app` attribute is not\n changed. '''\n if isinstance(routes, Bottle):\n routes = routes.routes\n for route in routes:\n self.add_route(route)","function_tokens":["def","merge","(","self",",","routes",")",":","if","isinstance","(","routes",",","Bottle",")",":","routes","=","routes",".","routes","for","route","in","routes",":","self",".","add_route","(","route",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L584-L592"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.install","parameters":"(self, plugin)","argument_list":"","return_statement":"return plugin","docstring":"Add a plugin to the list of plugins and prepare it for being\n applied to all routes of this application. A plugin may be a simple\n decorator or an object that implements the :class:`Plugin` API.","docstring_summary":"Add a plugin to the list of plugins and prepare it for being\n applied to all routes of this application. A plugin may be a simple\n decorator or an object that implements the :class:`Plugin` API.","docstring_tokens":["Add","a","plugin","to","the","list","of","plugins","and","prepare","it","for","being","applied","to","all","routes","of","this","application",".","A","plugin","may","be","a","simple","decorator","or","an","object","that","implements","the",":","class",":","Plugin","API","."],"function":"def install(self, plugin):\n ''' Add a plugin to the list of plugins and prepare it for being\n applied to all routes of this application. A plugin may be a simple\n decorator or an object that implements the :class:`Plugin` API.\n '''\n if hasattr(plugin, 'setup'): plugin.setup(self)\n if not callable(plugin) and not hasattr(plugin, 'apply'):\n raise TypeError(\"Plugins must be callable or implement .apply()\")\n self.plugins.append(plugin)\n self.reset()\n return plugin","function_tokens":["def","install","(","self",",","plugin",")",":","if","hasattr","(","plugin",",","'setup'",")",":","plugin",".","setup","(","self",")","if","not","callable","(","plugin",")","and","not","hasattr","(","plugin",",","'apply'",")",":","raise","TypeError","(","\"Plugins must be callable or implement .apply()\"",")","self",".","plugins",".","append","(","plugin",")","self",".","reset","(",")","return","plugin"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L594-L604"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.uninstall","parameters":"(self, plugin)","argument_list":"","return_statement":"return removed","docstring":"Uninstall plugins. Pass an instance to remove a specific plugin, a type\n object to remove all plugins that match that type, a string to remove\n all plugins with a matching ``name`` attribute or ``True`` to remove all\n plugins. Return the list of removed plugins.","docstring_summary":"Uninstall plugins. Pass an instance to remove a specific plugin, a type\n object to remove all plugins that match that type, a string to remove\n all plugins with a matching ``name`` attribute or ``True`` to remove all\n plugins. Return the list of removed plugins.","docstring_tokens":["Uninstall","plugins",".","Pass","an","instance","to","remove","a","specific","plugin","a","type","object","to","remove","all","plugins","that","match","that","type","a","string","to","remove","all","plugins","with","a","matching","name","attribute","or","True","to","remove","all","plugins",".","Return","the","list","of","removed","plugins","."],"function":"def uninstall(self, plugin):\n ''' Uninstall plugins. Pass an instance to remove a specific plugin, a type\n object to remove all plugins that match that type, a string to remove\n all plugins with a matching ``name`` attribute or ``True`` to remove all\n plugins. Return the list of removed plugins. '''\n removed, remove = [], plugin\n for i, plugin in list(enumerate(self.plugins))[::-1]:\n if remove is True or remove is plugin or remove is type(plugin) \\\n or getattr(plugin, 'name', True) == remove:\n removed.append(plugin)\n del self.plugins[i]\n if hasattr(plugin, 'close'): plugin.close()\n if removed: self.reset()\n return removed","function_tokens":["def","uninstall","(","self",",","plugin",")",":","removed",",","remove","=","[","]",",","plugin","for","i",",","plugin","in","list","(","enumerate","(","self",".","plugins",")",")","[",":",":","-","1","]",":","if","remove","is","True","or","remove","is","plugin","or","remove","is","type","(","plugin",")","or","getattr","(","plugin",",","'name'",",","True",")","==","remove",":","removed",".","append","(","plugin",")","del","self",".","plugins","[","i","]","if","hasattr","(","plugin",",","'close'",")",":","plugin",".","close","(",")","if","removed",":","self",".","reset","(",")","return","removed"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L606-L619"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.run","parameters":"(self, **kwargs)","argument_list":"","return_statement":"","docstring":"Calls :func:`run` with the same parameters.","docstring_summary":"Calls :func:`run` with the same parameters.","docstring_tokens":["Calls",":","func",":","run","with","the","same","parameters","."],"function":"def run(self, **kwargs):\n ''' Calls :func:`run` with the same parameters. '''\n run(self, **kwargs)","function_tokens":["def","run","(","self",",","*","*","kwargs",")",":","run","(","self",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L621-L623"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.reset","parameters":"(self, route=None)","argument_list":"","return_statement":"","docstring":"Reset all routes (force plugins to be re-applied) and clear all\n caches. If an ID or route object is given, only that specific route\n is affected.","docstring_summary":"Reset all routes (force plugins to be re-applied) and clear all\n caches. If an ID or route object is given, only that specific route\n is affected.","docstring_tokens":["Reset","all","routes","(","force","plugins","to","be","re","-","applied",")","and","clear","all","caches",".","If","an","ID","or","route","object","is","given","only","that","specific","route","is","affected","."],"function":"def reset(self, route=None):\n ''' Reset all routes (force plugins to be re-applied) and clear all\n caches. If an ID or route object is given, only that specific route\n is affected. '''\n if route is None: routes = self.routes\n elif isinstance(route, Route): routes = [route]\n else: routes = [self.routes[route]]\n for route in routes: route.reset()\n if DEBUG:\n for route in routes: route.prepare()\n self.hooks.trigger('app_reset')","function_tokens":["def","reset","(","self",",","route","=","None",")",":","if","route","is","None",":","routes","=","self",".","routes","elif","isinstance","(","route",",","Route",")",":","routes","=","[","route","]","else",":","routes","=","[","self",".","routes","[","route","]","]","for","route","in","routes",":","route",".","reset","(",")","if","DEBUG",":","for","route","in","routes",":","route",".","prepare","(",")","self",".","hooks",".","trigger","(","'app_reset'",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L625-L635"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.close","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Close the application and all installed plugins.","docstring_summary":"Close the application and all installed plugins.","docstring_tokens":["Close","the","application","and","all","installed","plugins","."],"function":"def close(self):\n ''' Close the application and all installed plugins. '''\n for plugin in self.plugins:\n if hasattr(plugin, 'close'): plugin.close()\n self.stopped = True","function_tokens":["def","close","(","self",")",":","for","plugin","in","self",".","plugins",":","if","hasattr","(","plugin",",","'close'",")",":","plugin",".","close","(",")","self",".","stopped","=","True"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L637-L641"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.match","parameters":"(self, environ)","argument_list":"","return_statement":"return self.router.match(environ)","docstring":"Search for a matching route and return a (:class:`Route` , urlargs)\n tuple. The second value is a dictionary with parameters extracted\n from the URL. Raise :exc:`HTTPError` (404\/405) on a non-match.","docstring_summary":"Search for a matching route and return a (:class:`Route` , urlargs)\n tuple. The second value is a dictionary with parameters extracted\n from the URL. Raise :exc:`HTTPError` (404\/405) on a non-match.","docstring_tokens":["Search","for","a","matching","route","and","return","a","(",":","class",":","Route","urlargs",")","tuple",".","The","second","value","is","a","dictionary","with","parameters","extracted","from","the","URL",".","Raise",":","exc",":","HTTPError","(","404","\/","405",")","on","a","non","-","match","."],"function":"def match(self, environ):\n \"\"\" Search for a matching route and return a (:class:`Route` , urlargs)\n tuple. The second value is a dictionary with parameters extracted\n from the URL. Raise :exc:`HTTPError` (404\/405) on a non-match.\"\"\"\n return self.router.match(environ)","function_tokens":["def","match","(","self",",","environ",")",":","return","self",".","router",".","match","(","environ",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L643-L647"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.get_url","parameters":"(self, routename, **kargs)","argument_list":"","return_statement":"return urljoin(urljoin('\/', scriptname), location)","docstring":"Return a string that matches a named route","docstring_summary":"Return a string that matches a named route","docstring_tokens":["Return","a","string","that","matches","a","named","route"],"function":"def get_url(self, routename, **kargs):\n \"\"\" Return a string that matches a named route \"\"\"\n scriptname = request.environ.get('SCRIPT_NAME', '').strip('\/') + '\/'\n location = self.router.build(routename, **kargs).lstrip('\/')\n return urljoin(urljoin('\/', scriptname), location)","function_tokens":["def","get_url","(","self",",","routename",",","*","*","kargs",")",":","scriptname","=","request",".","environ",".","get","(","'SCRIPT_NAME'",",","''",")",".","strip","(","'\/'",")","+","'\/'","location","=","self",".","router",".","build","(","routename",",","*","*","kargs",")",".","lstrip","(","'\/'",")","return","urljoin","(","urljoin","(","'\/'",",","scriptname",")",",","location",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L649-L653"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.add_route","parameters":"(self, route)","argument_list":"","return_statement":"","docstring":"Add a route object, but do not change the :data:`Route.app`\n attribute.","docstring_summary":"Add a route object, but do not change the :data:`Route.app`\n attribute.","docstring_tokens":["Add","a","route","object","but","do","not","change","the",":","data",":","Route",".","app","attribute","."],"function":"def add_route(self, route):\n ''' Add a route object, but do not change the :data:`Route.app`\n attribute.'''\n self.routes.append(route)\n self.router.add(route.rule, route.method, route, name=route.name)\n if DEBUG: route.prepare()","function_tokens":["def","add_route","(","self",",","route",")",":","self",".","routes",".","append","(","route",")","self",".","router",".","add","(","route",".","rule",",","route",".","method",",","route",",","name","=","route",".","name",")","if","DEBUG",":","route",".","prepare","(",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L655-L660"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.route","parameters":"(self, path=None, method='GET', callback=None, name=None,\n apply=None, skip=None, **config)","argument_list":"","return_statement":"return decorator(callback) if callback else decorator","docstring":"A decorator to bind a function to a request URL. Example::\n\n @app.route('\/hello\/:name')\n def hello(name):\n return 'Hello %s' % name\n\n The ``:name`` part is a wildcard. See :class:`Router` for syntax\n details.\n\n :param path: Request path or a list of paths to listen to. If no\n path is specified, it is automatically generated from the\n signature of the function.\n :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of\n methods to listen to. (default: `GET`)\n :param callback: An optional shortcut to avoid the decorator\n syntax. ``route(..., callback=func)`` equals ``route(...)(func)``\n :param name: The name for this route. (default: None)\n :param apply: A decorator or plugin or a list of plugins. These are\n applied to the route callback in addition to installed plugins.\n :param skip: A list of plugins, plugin classes or names. Matching\n plugins are not installed to this route. ``True`` skips all.\n\n Any additional keyword arguments are stored as route-specific\n configuration and passed to plugins (see :meth:`Plugin.apply`).","docstring_summary":"A decorator to bind a function to a request URL. Example::","docstring_tokens":["A","decorator","to","bind","a","function","to","a","request","URL",".","Example","::"],"function":"def route(self, path=None, method='GET', callback=None, name=None,\n apply=None, skip=None, **config):\n \"\"\" A decorator to bind a function to a request URL. Example::\n\n @app.route('\/hello\/:name')\n def hello(name):\n return 'Hello %s' % name\n\n The ``:name`` part is a wildcard. See :class:`Router` for syntax\n details.\n\n :param path: Request path or a list of paths to listen to. If no\n path is specified, it is automatically generated from the\n signature of the function.\n :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of\n methods to listen to. (default: `GET`)\n :param callback: An optional shortcut to avoid the decorator\n syntax. ``route(..., callback=func)`` equals ``route(...)(func)``\n :param name: The name for this route. (default: None)\n :param apply: A decorator or plugin or a list of plugins. These are\n applied to the route callback in addition to installed plugins.\n :param skip: A list of plugins, plugin classes or names. Matching\n plugins are not installed to this route. ``True`` skips all.\n\n Any additional keyword arguments are stored as route-specific\n configuration and passed to plugins (see :meth:`Plugin.apply`).\n \"\"\"\n if callable(path): path, callback = None, path\n plugins = makelist(apply)\n skiplist = makelist(skip)\n def decorator(callback):\n # TODO: Documentation and tests\n if isinstance(callback, basestring): callback = load(callback)\n for rule in makelist(path) or yieldroutes(callback):\n for verb in makelist(method):\n verb = verb.upper()\n route = Route(self, rule, verb, callback, name=name,\n plugins=plugins, skiplist=skiplist, **config)\n self.add_route(route)\n return callback\n return decorator(callback) if callback else decorator","function_tokens":["def","route","(","self",",","path","=","None",",","method","=","'GET'",",","callback","=","None",",","name","=","None",",","apply","=","None",",","skip","=","None",",","*","*","config",")",":","if","callable","(","path",")",":","path",",","callback","=","None",",","path","plugins","=","makelist","(","apply",")","skiplist","=","makelist","(","skip",")","def","decorator","(","callback",")",":","# TODO: Documentation and tests","if","isinstance","(","callback",",","basestring",")",":","callback","=","load","(","callback",")","for","rule","in","makelist","(","path",")","or","yieldroutes","(","callback",")",":","for","verb","in","makelist","(","method",")",":","verb","=","verb",".","upper","(",")","route","=","Route","(","self",",","rule",",","verb",",","callback",",","name","=","name",",","plugins","=","plugins",",","skiplist","=","skiplist",",","*","*","config",")","self",".","add_route","(","route",")","return","callback","return","decorator","(","callback",")","if","callback","else","decorator"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L662-L702"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.get","parameters":"(self, path=None, method='GET', **options)","argument_list":"","return_statement":"return self.route(path, method, **options)","docstring":"Equals :meth:`route`.","docstring_summary":"Equals :meth:`route`.","docstring_tokens":["Equals",":","meth",":","route","."],"function":"def get(self, path=None, method='GET', **options):\n \"\"\" Equals :meth:`route`. \"\"\"\n return self.route(path, method, **options)","function_tokens":["def","get","(","self",",","path","=","None",",","method","=","'GET'",",","*","*","options",")",":","return","self",".","route","(","path",",","method",",","*","*","options",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L704-L706"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.post","parameters":"(self, path=None, method='POST', **options)","argument_list":"","return_statement":"return self.route(path, method, **options)","docstring":"Equals :meth:`route` with a ``POST`` method parameter.","docstring_summary":"Equals :meth:`route` with a ``POST`` method parameter.","docstring_tokens":["Equals",":","meth",":","route","with","a","POST","method","parameter","."],"function":"def post(self, path=None, method='POST', **options):\n \"\"\" Equals :meth:`route` with a ``POST`` method parameter. \"\"\"\n return self.route(path, method, **options)","function_tokens":["def","post","(","self",",","path","=","None",",","method","=","'POST'",",","*","*","options",")",":","return","self",".","route","(","path",",","method",",","*","*","options",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L708-L710"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.put","parameters":"(self, path=None, method='PUT', **options)","argument_list":"","return_statement":"return self.route(path, method, **options)","docstring":"Equals :meth:`route` with a ``PUT`` method parameter.","docstring_summary":"Equals :meth:`route` with a ``PUT`` method parameter.","docstring_tokens":["Equals",":","meth",":","route","with","a","PUT","method","parameter","."],"function":"def put(self, path=None, method='PUT', **options):\n \"\"\" Equals :meth:`route` with a ``PUT`` method parameter. \"\"\"\n return self.route(path, method, **options)","function_tokens":["def","put","(","self",",","path","=","None",",","method","=","'PUT'",",","*","*","options",")",":","return","self",".","route","(","path",",","method",",","*","*","options",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L712-L714"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.delete","parameters":"(self, path=None, method='DELETE', **options)","argument_list":"","return_statement":"return self.route(path, method, **options)","docstring":"Equals :meth:`route` with a ``DELETE`` method parameter.","docstring_summary":"Equals :meth:`route` with a ``DELETE`` method parameter.","docstring_tokens":["Equals",":","meth",":","route","with","a","DELETE","method","parameter","."],"function":"def delete(self, path=None, method='DELETE', **options):\n \"\"\" Equals :meth:`route` with a ``DELETE`` method parameter. \"\"\"\n return self.route(path, method, **options)","function_tokens":["def","delete","(","self",",","path","=","None",",","method","=","'DELETE'",",","*","*","options",")",":","return","self",".","route","(","path",",","method",",","*","*","options",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L716-L718"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.error","parameters":"(self, code=500)","argument_list":"","return_statement":"return wrapper","docstring":"Decorator: Register an output handler for a HTTP error code","docstring_summary":"Decorator: Register an output handler for a HTTP error code","docstring_tokens":["Decorator",":","Register","an","output","handler","for","a","HTTP","error","code"],"function":"def error(self, code=500):\n \"\"\" Decorator: Register an output handler for a HTTP error code\"\"\"\n def wrapper(handler):\n self.error_handler[int(code)] = handler\n return handler\n return wrapper","function_tokens":["def","error","(","self",",","code","=","500",")",":","def","wrapper","(","handler",")",":","self",".","error_handler","[","int","(","code",")","]","=","handler","return","handler","return","wrapper"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L720-L725"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.hook","parameters":"(self, name)","argument_list":"","return_statement":"return wrapper","docstring":"Return a decorator that attaches a callback to a hook. Three hooks\n are currently implemented:\n\n - before_request: Executed once before each request\n - after_request: Executed once after each request\n - app_reset: Called whenever :meth:`reset` is called.","docstring_summary":"Return a decorator that attaches a callback to a hook. Three hooks\n are currently implemented:","docstring_tokens":["Return","a","decorator","that","attaches","a","callback","to","a","hook",".","Three","hooks","are","currently","implemented",":"],"function":"def hook(self, name):\n \"\"\" Return a decorator that attaches a callback to a hook. Three hooks\n are currently implemented:\n\n - before_request: Executed once before each request\n - after_request: Executed once after each request\n - app_reset: Called whenever :meth:`reset` is called.\n \"\"\"\n def wrapper(func):\n self.hooks.add(name, func)\n return func\n return wrapper","function_tokens":["def","hook","(","self",",","name",")",":","def","wrapper","(","func",")",":","self",".","hooks",".","add","(","name",",","func",")","return","func","return","wrapper"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L727-L738"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.handle","parameters":"(self, path, method='GET')","argument_list":"","return_statement":"return self._handle({'PATH_INFO': path, 'REQUEST_METHOD': method.upper()})","docstring":"(deprecated) Execute the first matching route callback and return\n the result. :exc:`HTTPResponse` exceptions are caught and returned.\n If :attr:`Bottle.catchall` is true, other exceptions are caught as\n well and returned as :exc:`HTTPError` instances (500).","docstring_summary":"(deprecated) Execute the first matching route callback and return\n the result. :exc:`HTTPResponse` exceptions are caught and returned.\n If :attr:`Bottle.catchall` is true, other exceptions are caught as\n well and returned as :exc:`HTTPError` instances (500).","docstring_tokens":["(","deprecated",")","Execute","the","first","matching","route","callback","and","return","the","result",".",":","exc",":","HTTPResponse","exceptions","are","caught","and","returned",".","If",":","attr",":","Bottle",".","catchall","is","true","other","exceptions","are","caught","as","well","and","returned","as",":","exc",":","HTTPError","instances","(","500",")","."],"function":"def handle(self, path, method='GET'):\n \"\"\" (deprecated) Execute the first matching route callback and return\n the result. :exc:`HTTPResponse` exceptions are caught and returned.\n If :attr:`Bottle.catchall` is true, other exceptions are caught as\n well and returned as :exc:`HTTPError` instances (500).\n \"\"\"\n depr(\"This method will change semantics in 0.10. Try to avoid it.\")\n if isinstance(path, dict):\n return self._handle(path)\n return self._handle({'PATH_INFO': path, 'REQUEST_METHOD': method.upper()})","function_tokens":["def","handle","(","self",",","path",",","method","=","'GET'",")",":","depr","(","\"This method will change semantics in 0.10. Try to avoid it.\"",")","if","isinstance","(","path",",","dict",")",":","return","self",".","_handle","(","path",")","return","self",".","_handle","(","{","'PATH_INFO'",":","path",",","'REQUEST_METHOD'",":","method",".","upper","(",")","}",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L740-L749"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle._cast","parameters":"(self, out, peek=None)","argument_list":"","return_statement":"return self._cast(HTTPError(500, 'Unsupported response type: %s'\\\n % type(first)))","docstring":"Try to convert the parameter into something WSGI compatible and set\n correct HTTP headers when possible.\n Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like,\n iterable of strings and iterable of unicodes","docstring_summary":"Try to convert the parameter into something WSGI compatible and set\n correct HTTP headers when possible.\n Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like,\n iterable of strings and iterable of unicodes","docstring_tokens":["Try","to","convert","the","parameter","into","something","WSGI","compatible","and","set","correct","HTTP","headers","when","possible",".","Support",":","False","str","unicode","dict","HTTPResponse","HTTPError","file","-","like","iterable","of","strings","and","iterable","of","unicodes"],"function":"def _cast(self, out, peek=None):\n \"\"\" Try to convert the parameter into something WSGI compatible and set\n correct HTTP headers when possible.\n Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like,\n iterable of strings and iterable of unicodes\n \"\"\"\n\n # Empty output is done here\n if not out:\n if 'Content-Length' not in response:\n response['Content-Length'] = 0\n return []\n # Join lists of byte or unicode strings. Mixed lists are NOT supported\n if isinstance(out, (tuple, list))\\\n and isinstance(out[0], (bytes, unicode)):\n out = out[0][0:0].join(out) # b'abc'[0:0] -> b''\n # Encode unicode strings\n if isinstance(out, unicode):\n out = out.encode(response.charset)\n # Byte Strings are just returned\n if isinstance(out, bytes):\n if 'Content-Length' not in response:\n response['Content-Length'] = len(out)\n return [out]\n # HTTPError or HTTPException (recursive, because they may wrap anything)\n # TODO: Handle these explicitly in handle() or make them iterable.\n if isinstance(out, HTTPError):\n out.apply(response)\n out = self.error_handler.get(out.status_code, self.default_error_handler)(out)\n return self._cast(out)\n if isinstance(out, HTTPResponse):\n out.apply(response)\n return self._cast(out.body)\n\n # File-like objects.\n if hasattr(out, 'read'):\n if 'wsgi.file_wrapper' in request.environ:\n return request.environ['wsgi.file_wrapper'](out)\n elif hasattr(out, 'close') or not hasattr(out, '__iter__'):\n return WSGIFileWrapper(out)\n\n # Handle Iterables. We peek into them to detect their inner type.\n try:\n out = iter(out)\n first = next(out)\n while not first:\n first = next(out)\n except StopIteration:\n return self._cast('')\n except HTTPResponse:\n first = _e()\n except (KeyboardInterrupt, SystemExit, MemoryError):\n raise\n except Exception:\n if not self.catchall: raise\n first = HTTPError(500, 'Unhandled exception', _e(), format_exc())\n\n # These are the inner types allowed in iterator or generator objects.\n if isinstance(first, HTTPResponse):\n return self._cast(first)\n if isinstance(first, bytes):\n return itertools.chain([first], out)\n if isinstance(first, unicode):\n return imap(lambda x: x.encode(response.charset),\n itertools.chain([first], out))\n return self._cast(HTTPError(500, 'Unsupported response type: %s'\\\n % type(first)))","function_tokens":["def","_cast","(","self",",","out",",","peek","=","None",")",":","# Empty output is done here","if","not","out",":","if","'Content-Length'","not","in","response",":","response","[","'Content-Length'","]","=","0","return","[","]","# Join lists of byte or unicode strings. Mixed lists are NOT supported","if","isinstance","(","out",",","(","tuple",",","list",")",")","and","isinstance","(","out","[","0","]",",","(","bytes",",","unicode",")",")",":","out","=","out","[","0","]","[","0",":","0","]",".","join","(","out",")","# b'abc'[0:0] -> b''","# Encode unicode strings","if","isinstance","(","out",",","unicode",")",":","out","=","out",".","encode","(","response",".","charset",")","# Byte Strings are just returned","if","isinstance","(","out",",","bytes",")",":","if","'Content-Length'","not","in","response",":","response","[","'Content-Length'","]","=","len","(","out",")","return","[","out","]","# HTTPError or HTTPException (recursive, because they may wrap anything)","# TODO: Handle these explicitly in handle() or make them iterable.","if","isinstance","(","out",",","HTTPError",")",":","out",".","apply","(","response",")","out","=","self",".","error_handler",".","get","(","out",".","status_code",",","self",".","default_error_handler",")","(","out",")","return","self",".","_cast","(","out",")","if","isinstance","(","out",",","HTTPResponse",")",":","out",".","apply","(","response",")","return","self",".","_cast","(","out",".","body",")","# File-like objects.","if","hasattr","(","out",",","'read'",")",":","if","'wsgi.file_wrapper'","in","request",".","environ",":","return","request",".","environ","[","'wsgi.file_wrapper'","]","(","out",")","elif","hasattr","(","out",",","'close'",")","or","not","hasattr","(","out",",","'__iter__'",")",":","return","WSGIFileWrapper","(","out",")","# Handle Iterables. We peek into them to detect their inner type.","try",":","out","=","iter","(","out",")","first","=","next","(","out",")","while","not","first",":","first","=","next","(","out",")","except","StopIteration",":","return","self",".","_cast","(","''",")","except","HTTPResponse",":","first","=","_e","(",")","except","(","KeyboardInterrupt",",","SystemExit",",","MemoryError",")",":","raise","except","Exception",":","if","not","self",".","catchall",":","raise","first","=","HTTPError","(","500",",","'Unhandled exception'",",","_e","(",")",",","format_exc","(",")",")","# These are the inner types allowed in iterator or generator objects.","if","isinstance","(","first",",","HTTPResponse",")",":","return","self",".","_cast","(","first",")","if","isinstance","(","first",",","bytes",")",":","return","itertools",".","chain","(","[","first","]",",","out",")","if","isinstance","(","first",",","unicode",")",":","return","imap","(","lambda","x",":","x",".","encode","(","response",".","charset",")",",","itertools",".","chain","(","[","first","]",",","out",")",")","return","self",".","_cast","(","HTTPError","(","500",",","'Unsupported response type: %s'","%","type","(","first",")",")",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L777-L843"} {"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.wsgi","parameters":"(self, environ, start_response)","argument_list":"","return_statement":"","docstring":"The bottle WSGI-interface.","docstring_summary":"The bottle WSGI-interface.","docstring_tokens":["The","bottle","WSGI","-","interface","."],"function":"def wsgi(self, environ, start_response):\n \"\"\" The bottle WSGI-interface. \"\"\"\n try:\n out = self._cast(self._handle(environ))\n # rfc2616 section 4.3\n if response._status_code in (100, 101, 204, 304)\\\n or environ['REQUEST_METHOD'] == 'HEAD':\n if hasattr(out, 'close'): out.close()\n out = []\n start_response(response._status_line, response.headerlist)\n return out\n except (KeyboardInterrupt, SystemExit, MemoryError):\n raise\n except Exception:\n if not self.catchall: raise\n err = '

Critical error while processing request: %s<\/h1>' \\\n % html_escape(environ.get('PATH_INFO', '\/'))\n if DEBUG:\n err += '

Error:<\/h2>\\n
\\n%s\\n<\/pre>\\n' \\\n                       '

Traceback:<\/h2>\\n
\\n%s\\n<\/pre>\\n' \\\n                       % (html_escape(repr(_e())), html_escape(format_exc()))\n            environ['wsgi.errors'].write(err)\n            headers = [('Content-Type', 'text\/html; charset=UTF-8')]\n            start_response('500 INTERNAL SERVER ERROR', headers)\n            return [tob(err)]","function_tokens":["def","wsgi","(","self",",","environ",",","start_response",")",":","try",":","out","=","self",".","_cast","(","self",".","_handle","(","environ",")",")","# rfc2616 section 4.3","if","response",".","_status_code","in","(","100",",","101",",","204",",","304",")","or","environ","[","'REQUEST_METHOD'","]","==","'HEAD'",":","if","hasattr","(","out",",","'close'",")",":","out",".","close","(",")","out","=","[","]","start_response","(","response",".","_status_line",",","response",".","headerlist",")","return","out","except","(","KeyboardInterrupt",",","SystemExit",",","MemoryError",")",":","raise","except","Exception",":","if","not","self",".","catchall",":","raise","err","=","'

Critical error while processing request: %s<\/h1>'","%","html_escape","(","environ",".","get","(","'PATH_INFO'",",","'\/'",")",")","if","DEBUG",":","err","+=","'

Error:<\/h2>\\n
\\n%s\\n<\/pre>\\n'","'

Traceback:<\/h2>\\n
\\n%s\\n<\/pre>\\n'","%","(","html_escape","(","repr","(","_e","(",")",")",")",",","html_escape","(","format_exc","(",")",")",")","environ","[","'wsgi.errors'","]",".","write","(","err",")","headers","=","[","(","'Content-Type'",",","'text\/html; charset=UTF-8'",")","]","start_response","(","'500 INTERNAL SERVER ERROR'",",","headers",")","return","[","tob","(","err",")","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L845-L869"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"Bottle.__call__","parameters":"(self, environ, start_response)","argument_list":"","return_statement":"return self.wsgi(environ, start_response)","docstring":"Each instance of :class:'Bottle' is a WSGI application.","docstring_summary":"Each instance of :class:'Bottle' is a WSGI application.","docstring_tokens":["Each","instance","of",":","class",":","Bottle","is","a","WSGI","application","."],"function":"def __call__(self, environ, start_response):\n        ''' Each instance of :class:'Bottle' is a WSGI application. '''\n        return self.wsgi(environ, start_response)","function_tokens":["def","__call__","(","self",",","environ",",","start_response",")",":","return","self",".","wsgi","(","environ",",","start_response",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L871-L873"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.__init__","parameters":"(self, environ=None)","argument_list":"","return_statement":"","docstring":"Wrap a WSGI environ dictionary.","docstring_summary":"Wrap a WSGI environ dictionary.","docstring_tokens":["Wrap","a","WSGI","environ","dictionary","."],"function":"def __init__(self, environ=None):\n        \"\"\" Wrap a WSGI environ dictionary. \"\"\"\n        #: The wrapped WSGI environ dictionary. This is the only real attribute.\n        #: All other attributes actually are read-only properties.\n        self.environ = {} if environ is None else environ\n        self.environ['bottle.request'] = self","function_tokens":["def","__init__","(","self",",","environ","=","None",")",":","#: The wrapped WSGI environ dictionary. This is the only real attribute.","#: All other attributes actually are read-only properties.","self",".","environ","=","{","}","if","environ","is","None","else","environ","self",".","environ","[","'bottle.request'","]","=","self"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L901-L906"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.app","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Bottle application handling this request.","docstring_summary":"Bottle application handling this request.","docstring_tokens":["Bottle","application","handling","this","request","."],"function":"def app(self):\n        ''' Bottle application handling this request. '''\n        raise RuntimeError('This request is not connected to an application.')","function_tokens":["def","app","(","self",")",":","raise","RuntimeError","(","'This request is not connected to an application.'",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L909-L911"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.path","parameters":"(self)","argument_list":"","return_statement":"return '\/' + self.environ.get('PATH_INFO','').lstrip('\/')","docstring":"The value of ``PATH_INFO`` with exactly one prefixed slash (to fix\n            broken clients and avoid the \"empty path\" edge case).","docstring_summary":"The value of ``PATH_INFO`` with exactly one prefixed slash (to fix\n            broken clients and avoid the \"empty path\" edge case).","docstring_tokens":["The","value","of","PATH_INFO","with","exactly","one","prefixed","slash","(","to","fix","broken","clients","and","avoid","the","empty","path","edge","case",")","."],"function":"def path(self):\n        ''' The value of ``PATH_INFO`` with exactly one prefixed slash (to fix\n            broken clients and avoid the \"empty path\" edge case). '''\n        return '\/' + self.environ.get('PATH_INFO','').lstrip('\/')","function_tokens":["def","path","(","self",")",":","return","'\/'","+","self",".","environ",".","get","(","'PATH_INFO'",",","''",")",".","lstrip","(","'\/'",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L914-L917"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.method","parameters":"(self)","argument_list":"","return_statement":"return self.environ.get('REQUEST_METHOD', 'GET').upper()","docstring":"The ``REQUEST_METHOD`` value as an uppercase string.","docstring_summary":"The ``REQUEST_METHOD`` value as an uppercase string.","docstring_tokens":["The","REQUEST_METHOD","value","as","an","uppercase","string","."],"function":"def method(self):\n        ''' The ``REQUEST_METHOD`` value as an uppercase string. '''\n        return self.environ.get('REQUEST_METHOD', 'GET').upper()","function_tokens":["def","method","(","self",")",":","return","self",".","environ",".","get","(","'REQUEST_METHOD'",",","'GET'",")",".","upper","(",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L920-L922"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.headers","parameters":"(self)","argument_list":"","return_statement":"return WSGIHeaderDict(self.environ)","docstring":"A :class:`WSGIHeaderDict` that provides case-insensitive access to\n            HTTP request headers.","docstring_summary":"A :class:`WSGIHeaderDict` that provides case-insensitive access to\n            HTTP request headers.","docstring_tokens":["A",":","class",":","WSGIHeaderDict","that","provides","case","-","insensitive","access","to","HTTP","request","headers","."],"function":"def headers(self):\n        ''' A :class:`WSGIHeaderDict` that provides case-insensitive access to\n            HTTP request headers. '''\n        return WSGIHeaderDict(self.environ)","function_tokens":["def","headers","(","self",")",":","return","WSGIHeaderDict","(","self",".","environ",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L925-L928"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.get_header","parameters":"(self, name, default=None)","argument_list":"","return_statement":"return self.headers.get(name, default)","docstring":"Return the value of a request header, or a given default value.","docstring_summary":"Return the value of a request header, or a given default value.","docstring_tokens":["Return","the","value","of","a","request","header","or","a","given","default","value","."],"function":"def get_header(self, name, default=None):\n        ''' Return the value of a request header, or a given default value. '''\n        return self.headers.get(name, default)","function_tokens":["def","get_header","(","self",",","name",",","default","=","None",")",":","return","self",".","headers",".","get","(","name",",","default",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L930-L932"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.cookies","parameters":"(self)","argument_list":"","return_statement":"return FormsDict((c.key, c.value) for c in cookies)","docstring":"Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT\n            decoded. Use :meth:`get_cookie` if you expect signed cookies.","docstring_summary":"Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT\n            decoded. Use :meth:`get_cookie` if you expect signed cookies.","docstring_tokens":["Cookies","parsed","into","a",":","class",":","FormsDict",".","Signed","cookies","are","NOT","decoded",".","Use",":","meth",":","get_cookie","if","you","expect","signed","cookies","."],"function":"def cookies(self):\n        \"\"\" Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT\n            decoded. Use :meth:`get_cookie` if you expect signed cookies. \"\"\"\n        cookies = SimpleCookie(self.environ.get('HTTP_COOKIE',''))\n        cookies = list(cookies.values())[:self.MAX_PARAMS]\n        return FormsDict((c.key, c.value) for c in cookies)","function_tokens":["def","cookies","(","self",")",":","cookies","=","SimpleCookie","(","self",".","environ",".","get","(","'HTTP_COOKIE'",",","''",")",")","cookies","=","list","(","cookies",".","values","(",")",")","[",":","self",".","MAX_PARAMS","]","return","FormsDict","(","(","c",".","key",",","c",".","value",")","for","c","in","cookies",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L935-L940"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.get_cookie","parameters":"(self, key, default=None, secret=None)","argument_list":"","return_statement":"return value or default","docstring":"Return the content of a cookie. To read a `Signed Cookie`, the\n            `secret` must match the one used to create the cookie (see\n            :meth:`BaseResponse.set_cookie`). If anything goes wrong (missing\n            cookie or wrong signature), return a default value.","docstring_summary":"Return the content of a cookie. To read a `Signed Cookie`, the\n            `secret` must match the one used to create the cookie (see\n            :meth:`BaseResponse.set_cookie`). If anything goes wrong (missing\n            cookie or wrong signature), return a default value.","docstring_tokens":["Return","the","content","of","a","cookie",".","To","read","a","Signed","Cookie","the","secret","must","match","the","one","used","to","create","the","cookie","(","see",":","meth",":","BaseResponse",".","set_cookie",")",".","If","anything","goes","wrong","(","missing","cookie","or","wrong","signature",")","return","a","default","value","."],"function":"def get_cookie(self, key, default=None, secret=None):\n        \"\"\" Return the content of a cookie. To read a `Signed Cookie`, the\n            `secret` must match the one used to create the cookie (see\n            :meth:`BaseResponse.set_cookie`). If anything goes wrong (missing\n            cookie or wrong signature), return a default value. \"\"\"\n        value = self.cookies.get(key)\n        if secret and value:\n            dec = cookie_decode(value, secret) # (key, value) tuple or None\n            return dec[1] if dec and dec[0] == key else default\n        return value or default","function_tokens":["def","get_cookie","(","self",",","key",",","default","=","None",",","secret","=","None",")",":","value","=","self",".","cookies",".","get","(","key",")","if","secret","and","value",":","dec","=","cookie_decode","(","value",",","secret",")","# (key, value) tuple or None","return","dec","[","1","]","if","dec","and","dec","[","0","]","==","key","else","default","return","value","or","default"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L942-L951"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.query","parameters":"(self)","argument_list":"","return_statement":"return get","docstring":"The :attr:`query_string` parsed into a :class:`FormsDict`. These\n            values are sometimes called \"URL arguments\" or \"GET parameters\", but\n            not to be confused with \"URL wildcards\" as they are provided by the\n            :class:`Router`.","docstring_summary":"The :attr:`query_string` parsed into a :class:`FormsDict`. These\n            values are sometimes called \"URL arguments\" or \"GET parameters\", but\n            not to be confused with \"URL wildcards\" as they are provided by the\n            :class:`Router`.","docstring_tokens":["The",":","attr",":","query_string","parsed","into","a",":","class",":","FormsDict",".","These","values","are","sometimes","called","URL","arguments","or","GET","parameters","but","not","to","be","confused","with","URL","wildcards","as","they","are","provided","by","the",":","class",":","Router","."],"function":"def query(self):\n        ''' The :attr:`query_string` parsed into a :class:`FormsDict`. These\n            values are sometimes called \"URL arguments\" or \"GET parameters\", but\n            not to be confused with \"URL wildcards\" as they are provided by the\n            :class:`Router`. '''\n        get = self.environ['bottle.get'] = FormsDict()\n        pairs = _parse_qsl(self.environ.get('QUERY_STRING', ''))\n        for key, value in pairs[:self.MAX_PARAMS]:\n            get[key] = value\n        return get","function_tokens":["def","query","(","self",")",":","get","=","self",".","environ","[","'bottle.get'","]","=","FormsDict","(",")","pairs","=","_parse_qsl","(","self",".","environ",".","get","(","'QUERY_STRING'",",","''",")",")","for","key",",","value","in","pairs","[",":","self",".","MAX_PARAMS","]",":","get","[","key","]","=","value","return","get"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L954-L963"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.forms","parameters":"(self)","argument_list":"","return_statement":"return forms","docstring":"Form values parsed from an `url-encoded` or `multipart\/form-data`\n            encoded POST or PUT request body. The result is retuned as a\n            :class:`FormsDict`. All keys and values are strings. File uploads\n            are stored separately in :attr:`files`.","docstring_summary":"Form values parsed from an `url-encoded` or `multipart\/form-data`\n            encoded POST or PUT request body. The result is retuned as a\n            :class:`FormsDict`. All keys and values are strings. File uploads\n            are stored separately in :attr:`files`.","docstring_tokens":["Form","values","parsed","from","an","url","-","encoded","or","multipart","\/","form","-","data","encoded","POST","or","PUT","request","body",".","The","result","is","retuned","as","a",":","class",":","FormsDict",".","All","keys","and","values","are","strings",".","File","uploads","are","stored","separately","in",":","attr",":","files","."],"function":"def forms(self):\n        \"\"\" Form values parsed from an `url-encoded` or `multipart\/form-data`\n            encoded POST or PUT request body. The result is retuned as a\n            :class:`FormsDict`. All keys and values are strings. File uploads\n            are stored separately in :attr:`files`. \"\"\"\n        forms = FormsDict()\n        for name, item in self.POST.allitems():\n            if not hasattr(item, 'filename'):\n                forms[name] = item\n        return forms","function_tokens":["def","forms","(","self",")",":","forms","=","FormsDict","(",")","for","name",",","item","in","self",".","POST",".","allitems","(",")",":","if","not","hasattr","(","item",",","'filename'",")",":","forms","[","name","]","=","item","return","forms"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L966-L975"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.params","parameters":"(self)","argument_list":"","return_statement":"return params","docstring":"A :class:`FormsDict` with the combined values of :attr:`query` and\n            :attr:`forms`. File uploads are stored in :attr:`files`.","docstring_summary":"A :class:`FormsDict` with the combined values of :attr:`query` and\n            :attr:`forms`. File uploads are stored in :attr:`files`.","docstring_tokens":["A",":","class",":","FormsDict","with","the","combined","values","of",":","attr",":","query","and",":","attr",":","forms",".","File","uploads","are","stored","in",":","attr",":","files","."],"function":"def params(self):\n        \"\"\" A :class:`FormsDict` with the combined values of :attr:`query` and\n            :attr:`forms`. File uploads are stored in :attr:`files`. \"\"\"\n        params = FormsDict()\n        for key, value in self.query.allitems():\n            params[key] = value\n        for key, value in self.forms.allitems():\n            params[key] = value\n        return params","function_tokens":["def","params","(","self",")",":","params","=","FormsDict","(",")","for","key",",","value","in","self",".","query",".","allitems","(",")",":","params","[","key","]","=","value","for","key",",","value","in","self",".","forms",".","allitems","(",")",":","params","[","key","]","=","value","return","params"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L978-L986"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.files","parameters":"(self)","argument_list":"","return_statement":"return files","docstring":"File uploads parsed from an `url-encoded` or `multipart\/form-data`\n            encoded POST or PUT request body. The values are instances of\n            :class:`cgi.FieldStorage`. The most important attributes are:\n\n            filename\n                The filename, if specified; otherwise None; this is the client\n                side filename, *not* the file name on which it is stored (that's\n                a temporary file you don't deal with)\n            file\n                The file(-like) object from which you can read the data.\n            value\n                The value as a *string*; for file uploads, this transparently\n                reads the file every time you request the value. Do not do this\n                on big files.","docstring_summary":"File uploads parsed from an `url-encoded` or `multipart\/form-data`\n            encoded POST or PUT request body. The values are instances of\n            :class:`cgi.FieldStorage`. The most important attributes are:","docstring_tokens":["File","uploads","parsed","from","an","url","-","encoded","or","multipart","\/","form","-","data","encoded","POST","or","PUT","request","body",".","The","values","are","instances","of",":","class",":","cgi",".","FieldStorage",".","The","most","important","attributes","are",":"],"function":"def files(self):\n        \"\"\" File uploads parsed from an `url-encoded` or `multipart\/form-data`\n            encoded POST or PUT request body. The values are instances of\n            :class:`cgi.FieldStorage`. The most important attributes are:\n\n            filename\n                The filename, if specified; otherwise None; this is the client\n                side filename, *not* the file name on which it is stored (that's\n                a temporary file you don't deal with)\n            file\n                The file(-like) object from which you can read the data.\n            value\n                The value as a *string*; for file uploads, this transparently\n                reads the file every time you request the value. Do not do this\n                on big files.\n        \"\"\"\n        files = FormsDict()\n        for name, item in self.POST.allitems():\n            if hasattr(item, 'filename'):\n                files[name] = item\n        return files","function_tokens":["def","files","(","self",")",":","files","=","FormsDict","(",")","for","name",",","item","in","self",".","POST",".","allitems","(",")",":","if","hasattr","(","item",",","'filename'",")",":","files","[","name","]","=","item","return","files"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L989-L1009"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.json","parameters":"(self)","argument_list":"","return_statement":"return None","docstring":"If the ``Content-Type`` header is ``application\/json``, this\n            property holds the parsed content of the request body. Only requests\n            smaller than :attr:`MEMFILE_MAX` are processed to avoid memory\n            exhaustion.","docstring_summary":"If the ``Content-Type`` header is ``application\/json``, this\n            property holds the parsed content of the request body. Only requests\n            smaller than :attr:`MEMFILE_MAX` are processed to avoid memory\n            exhaustion.","docstring_tokens":["If","the","Content","-","Type","header","is","application","\/","json","this","property","holds","the","parsed","content","of","the","request","body",".","Only","requests","smaller","than",":","attr",":","MEMFILE_MAX","are","processed","to","avoid","memory","exhaustion","."],"function":"def json(self):\n        ''' If the ``Content-Type`` header is ``application\/json``, this\n            property holds the parsed content of the request body. Only requests\n            smaller than :attr:`MEMFILE_MAX` are processed to avoid memory\n            exhaustion. '''\n        if 'application\/json' in self.environ.get('CONTENT_TYPE', '') \\\n        and 0 < self.content_length < self.MEMFILE_MAX:\n            return json_loads(self.body.read(self.MEMFILE_MAX))\n        return None","function_tokens":["def","json","(","self",")",":","if","'application\/json'","in","self",".","environ",".","get","(","'CONTENT_TYPE'",",","''",")","and","0","<","self",".","content_length","<","self",".","MEMFILE_MAX",":","return","json_loads","(","self",".","body",".","read","(","self",".","MEMFILE_MAX",")",")","return","None"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1012-L1020"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.body","parameters":"(self)","argument_list":"","return_statement":"return self._body","docstring":"The HTTP request body as a seek-able file-like object. Depending on\n            :attr:`MEMFILE_MAX`, this is either a temporary file or a\n            :class:`io.BytesIO` instance. Accessing this property for the first\n            time reads and replaces the ``wsgi.input`` environ variable.\n            Subsequent accesses just do a `seek(0)` on the file object.","docstring_summary":"The HTTP request body as a seek-able file-like object. Depending on\n            :attr:`MEMFILE_MAX`, this is either a temporary file or a\n            :class:`io.BytesIO` instance. Accessing this property for the first\n            time reads and replaces the ``wsgi.input`` environ variable.\n            Subsequent accesses just do a `seek(0)` on the file object.","docstring_tokens":["The","HTTP","request","body","as","a","seek","-","able","file","-","like","object",".","Depending","on",":","attr",":","MEMFILE_MAX","this","is","either","a","temporary","file","or","a",":","class",":","io",".","BytesIO","instance",".","Accessing","this","property","for","the","first","time","reads","and","replaces","the","wsgi",".","input","environ","variable",".","Subsequent","accesses","just","do","a","seek","(","0",")","on","the","file","object","."],"function":"def body(self):\n        \"\"\" The HTTP request body as a seek-able file-like object. Depending on\n            :attr:`MEMFILE_MAX`, this is either a temporary file or a\n            :class:`io.BytesIO` instance. Accessing this property for the first\n            time reads and replaces the ``wsgi.input`` environ variable.\n            Subsequent accesses just do a `seek(0)` on the file object. \"\"\"\n        self._body.seek(0)\n        return self._body","function_tokens":["def","body","(","self",")",":","self",".","_body",".","seek","(","0",")","return","self",".","_body"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1037-L1044"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.POST","parameters":"(self)","argument_list":"","return_statement":"return post","docstring":"The values of :attr:`forms` and :attr:`files` combined into a single\n            :class:`FormsDict`. Values are either strings (form values) or\n            instances of :class:`cgi.FieldStorage` (file uploads).","docstring_summary":"The values of :attr:`forms` and :attr:`files` combined into a single\n            :class:`FormsDict`. Values are either strings (form values) or\n            instances of :class:`cgi.FieldStorage` (file uploads).","docstring_tokens":["The","values","of",":","attr",":","forms","and",":","attr",":","files","combined","into","a","single",":","class",":","FormsDict",".","Values","are","either","strings","(","form","values",")","or","instances","of",":","class",":","cgi",".","FieldStorage","(","file","uploads",")","."],"function":"def POST(self):\n        \"\"\" The values of :attr:`forms` and :attr:`files` combined into a single\n            :class:`FormsDict`. Values are either strings (form values) or\n            instances of :class:`cgi.FieldStorage` (file uploads).\n        \"\"\"\n        post = FormsDict()\n        # We default to application\/x-www-form-urlencoded for everything that\n        # is not multipart and take the fast path (also: 3.1 workaround)\n        if not self.content_type.startswith('multipart\/'):\n            maxlen = max(0, min(self.content_length, self.MEMFILE_MAX))\n            pairs = _parse_qsl(tonat(self.body.read(maxlen), 'latin1'))\n            for key, value in pairs[:self.MAX_PARAMS]:\n                post[key] = value\n            return post\n\n        safe_env = {'QUERY_STRING':''} # Build a safe environment for cgi\n        for key in ('REQUEST_METHOD', 'CONTENT_TYPE', 'CONTENT_LENGTH'):\n            if key in self.environ: safe_env[key] = self.environ[key]\n        args = dict(fp=self.body, environ=safe_env, keep_blank_values=True)\n        if py31:\n            args['fp'] = NCTextIOWrapper(args['fp'], encoding='ISO-8859-1',\n                                         newline='\\n')\n        elif py3k:\n            args['encoding'] = 'ISO-8859-1'\n        data = FieldStorage(**args)\n        for item in (data.list or [])[:self.MAX_PARAMS]:\n            post[item.name] = item if item.filename else item.value\n        return post","function_tokens":["def","POST","(","self",")",":","post","=","FormsDict","(",")","# We default to application\/x-www-form-urlencoded for everything that","# is not multipart and take the fast path (also: 3.1 workaround)","if","not","self",".","content_type",".","startswith","(","'multipart\/'",")",":","maxlen","=","max","(","0",",","min","(","self",".","content_length",",","self",".","MEMFILE_MAX",")",")","pairs","=","_parse_qsl","(","tonat","(","self",".","body",".","read","(","maxlen",")",",","'latin1'",")",")","for","key",",","value","in","pairs","[",":","self",".","MAX_PARAMS","]",":","post","[","key","]","=","value","return","post","safe_env","=","{","'QUERY_STRING'",":","''","}","# Build a safe environment for cgi","for","key","in","(","'REQUEST_METHOD'",",","'CONTENT_TYPE'",",","'CONTENT_LENGTH'",")",":","if","key","in","self",".","environ",":","safe_env","[","key","]","=","self",".","environ","[","key","]","args","=","dict","(","fp","=","self",".","body",",","environ","=","safe_env",",","keep_blank_values","=","True",")","if","py31",":","args","[","'fp'","]","=","NCTextIOWrapper","(","args","[","'fp'","]",",","encoding","=","'ISO-8859-1'",",","newline","=","'\\n'",")","elif","py3k",":","args","[","'encoding'","]","=","'ISO-8859-1'","data","=","FieldStorage","(","*","*","args",")","for","item","in","(","data",".","list","or","[","]",")","[",":","self",".","MAX_PARAMS","]",":","post","[","item",".","name","]","=","item","if","item",".","filename","else","item",".","value","return","post"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1050-L1077"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.COOKIES","parameters":"(self)","argument_list":"","return_statement":"return self.cookies","docstring":"Alias for :attr:`cookies` (deprecated).","docstring_summary":"Alias for :attr:`cookies` (deprecated).","docstring_tokens":["Alias","for",":","attr",":","cookies","(","deprecated",")","."],"function":"def COOKIES(self):\n        ''' Alias for :attr:`cookies` (deprecated). '''\n        depr('BaseRequest.COOKIES was renamed to BaseRequest.cookies (lowercase).')\n        return self.cookies","function_tokens":["def","COOKIES","(","self",")",":","depr","(","'BaseRequest.COOKIES was renamed to BaseRequest.cookies (lowercase).'",")","return","self",".","cookies"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1080-L1083"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.url","parameters":"(self)","argument_list":"","return_statement":"return self.urlparts.geturl()","docstring":"The full request URI including hostname and scheme. If your app\n            lives behind a reverse proxy or load balancer and you get confusing\n            results, make sure that the ``X-Forwarded-Host`` header is set\n            correctly.","docstring_summary":"The full request URI including hostname and scheme. If your app\n            lives behind a reverse proxy or load balancer and you get confusing\n            results, make sure that the ``X-Forwarded-Host`` header is set\n            correctly.","docstring_tokens":["The","full","request","URI","including","hostname","and","scheme",".","If","your","app","lives","behind","a","reverse","proxy","or","load","balancer","and","you","get","confusing","results","make","sure","that","the","X","-","Forwarded","-","Host","header","is","set","correctly","."],"function":"def url(self):\n        \"\"\" The full request URI including hostname and scheme. If your app\n            lives behind a reverse proxy or load balancer and you get confusing\n            results, make sure that the ``X-Forwarded-Host`` header is set\n            correctly. \"\"\"\n        return self.urlparts.geturl()","function_tokens":["def","url","(","self",")",":","return","self",".","urlparts",".","geturl","(",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1086-L1091"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.urlparts","parameters":"(self)","argument_list":"","return_statement":"return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '')","docstring":"The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.\n            The tuple contains (scheme, host, path, query_string and fragment),\n            but the fragment is always empty because it is not visible to the\n            server.","docstring_summary":"The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.\n            The tuple contains (scheme, host, path, query_string and fragment),\n            but the fragment is always empty because it is not visible to the\n            server.","docstring_tokens":["The",":","attr",":","url","string","as","an",":","class",":","urlparse",".","SplitResult","tuple",".","The","tuple","contains","(","scheme","host","path","query_string","and","fragment",")","but","the","fragment","is","always","empty","because","it","is","not","visible","to","the","server","."],"function":"def urlparts(self):\n        ''' The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.\n            The tuple contains (scheme, host, path, query_string and fragment),\n            but the fragment is always empty because it is not visible to the\n            server. '''\n        env = self.environ\n        http = env.get('HTTP_X_FORWARDED_PROTO') or env.get('wsgi.url_scheme', 'http')\n        host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST')\n        if not host:\n            # HTTP 1.1 requires a Host-header. This is for HTTP\/1.0 clients.\n            host = env.get('SERVER_NAME', '127.0.0.1')\n            port = env.get('SERVER_PORT')\n            if port and port != ('80' if http == 'http' else '443'):\n                host += ':' + port\n        path = urlquote(self.fullpath)\n        return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '')","function_tokens":["def","urlparts","(","self",")",":","env","=","self",".","environ","http","=","env",".","get","(","'HTTP_X_FORWARDED_PROTO'",")","or","env",".","get","(","'wsgi.url_scheme'",",","'http'",")","host","=","env",".","get","(","'HTTP_X_FORWARDED_HOST'",")","or","env",".","get","(","'HTTP_HOST'",")","if","not","host",":","# HTTP 1.1 requires a Host-header. This is for HTTP\/1.0 clients.","host","=","env",".","get","(","'SERVER_NAME'",",","'127.0.0.1'",")","port","=","env",".","get","(","'SERVER_PORT'",")","if","port","and","port","!=","(","'80'","if","http","==","'http'","else","'443'",")",":","host","+=","':'","+","port","path","=","urlquote","(","self",".","fullpath",")","return","UrlSplitResult","(","http",",","host",",","path",",","env",".","get","(","'QUERY_STRING'",")",",","''",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1094-L1109"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.fullpath","parameters":"(self)","argument_list":"","return_statement":"return urljoin(self.script_name, self.path.lstrip('\/'))","docstring":"Request path including :attr:`script_name` (if present).","docstring_summary":"Request path including :attr:`script_name` (if present).","docstring_tokens":["Request","path","including",":","attr",":","script_name","(","if","present",")","."],"function":"def fullpath(self):\n        \"\"\" Request path including :attr:`script_name` (if present). \"\"\"\n        return urljoin(self.script_name, self.path.lstrip('\/'))","function_tokens":["def","fullpath","(","self",")",":","return","urljoin","(","self",".","script_name",",","self",".","path",".","lstrip","(","'\/'",")",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1112-L1114"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.query_string","parameters":"(self)","argument_list":"","return_statement":"return self.environ.get('QUERY_STRING', '')","docstring":"The raw :attr:`query` part of the URL (everything in between ``?``\n            and ``#``) as a string.","docstring_summary":"The raw :attr:`query` part of the URL (everything in between ``?``\n            and ``#``) as a string.","docstring_tokens":["The","raw",":","attr",":","query","part","of","the","URL","(","everything","in","between","?","and","#",")","as","a","string","."],"function":"def query_string(self):\n        \"\"\" The raw :attr:`query` part of the URL (everything in between ``?``\n            and ``#``) as a string. \"\"\"\n        return self.environ.get('QUERY_STRING', '')","function_tokens":["def","query_string","(","self",")",":","return","self",".","environ",".","get","(","'QUERY_STRING'",",","''",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1117-L1120"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.script_name","parameters":"(self)","argument_list":"","return_statement":"return '\/' + script_name + '\/' if script_name else '\/'","docstring":"The initial portion of the URL's `path` that was removed by a higher\n            level (server or routing middleware) before the application was\n            called. This script path is returned with leading and tailing\n            slashes.","docstring_summary":"The initial portion of the URL's `path` that was removed by a higher\n            level (server or routing middleware) before the application was\n            called. This script path is returned with leading and tailing\n            slashes.","docstring_tokens":["The","initial","portion","of","the","URL","s","path","that","was","removed","by","a","higher","level","(","server","or","routing","middleware",")","before","the","application","was","called",".","This","script","path","is","returned","with","leading","and","tailing","slashes","."],"function":"def script_name(self):\n        ''' The initial portion of the URL's `path` that was removed by a higher\n            level (server or routing middleware) before the application was\n            called. This script path is returned with leading and tailing\n            slashes. '''\n        script_name = self.environ.get('SCRIPT_NAME', '').strip('\/')\n        return '\/' + script_name + '\/' if script_name else '\/'","function_tokens":["def","script_name","(","self",")",":","script_name","=","self",".","environ",".","get","(","'SCRIPT_NAME'",",","''",")",".","strip","(","'\/'",")","return","'\/'","+","script_name","+","'\/'","if","script_name","else","'\/'"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1123-L1129"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.path_shift","parameters":"(self, shift=1)","argument_list":"","return_statement":"","docstring":"Shift path segments from :attr:`path` to :attr:`script_name` and\n            vice versa.\n\n           :param shift: The number of path segments to shift. May be negative\n                         to change the shift direction. (default: 1)","docstring_summary":"Shift path segments from :attr:`path` to :attr:`script_name` and\n            vice versa.","docstring_tokens":["Shift","path","segments","from",":","attr",":","path","to",":","attr",":","script_name","and","vice","versa","."],"function":"def path_shift(self, shift=1):\n        ''' Shift path segments from :attr:`path` to :attr:`script_name` and\n            vice versa.\n\n           :param shift: The number of path segments to shift. May be negative\n                         to change the shift direction. (default: 1)\n        '''\n        script = self.environ.get('SCRIPT_NAME','\/')\n        self['SCRIPT_NAME'], self['PATH_INFO'] = path_shift(script, self.path, shift)","function_tokens":["def","path_shift","(","self",",","shift","=","1",")",":","script","=","self",".","environ",".","get","(","'SCRIPT_NAME'",",","'\/'",")","self","[","'SCRIPT_NAME'","]",",","self","[","'PATH_INFO'","]","=","path_shift","(","script",",","self",".","path",",","shift",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1131-L1139"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.content_length","parameters":"(self)","argument_list":"","return_statement":"return int(self.environ.get('CONTENT_LENGTH') or -1)","docstring":"The request body length as an integer. The client is responsible to\n            set this header. Otherwise, the real length of the body is unknown\n            and -1 is returned. In this case, :attr:`body` will be empty.","docstring_summary":"The request body length as an integer. The client is responsible to\n            set this header. Otherwise, the real length of the body is unknown\n            and -1 is returned. In this case, :attr:`body` will be empty.","docstring_tokens":["The","request","body","length","as","an","integer",".","The","client","is","responsible","to","set","this","header",".","Otherwise","the","real","length","of","the","body","is","unknown","and","-","1","is","returned",".","In","this","case",":","attr",":","body","will","be","empty","."],"function":"def content_length(self):\n        ''' The request body length as an integer. The client is responsible to\n            set this header. Otherwise, the real length of the body is unknown\n            and -1 is returned. In this case, :attr:`body` will be empty. '''\n        return int(self.environ.get('CONTENT_LENGTH') or -1)","function_tokens":["def","content_length","(","self",")",":","return","int","(","self",".","environ",".","get","(","'CONTENT_LENGTH'",")","or","-","1",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1142-L1146"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.content_type","parameters":"(self)","argument_list":"","return_statement":"return self.environ.get('CONTENT_TYPE', '').lower()","docstring":"The Content-Type header as a lowercase-string (default: empty).","docstring_summary":"The Content-Type header as a lowercase-string (default: empty).","docstring_tokens":["The","Content","-","Type","header","as","a","lowercase","-","string","(","default",":","empty",")","."],"function":"def content_type(self):\n        ''' The Content-Type header as a lowercase-string (default: empty). '''\n        return self.environ.get('CONTENT_TYPE', '').lower()","function_tokens":["def","content_type","(","self",")",":","return","self",".","environ",".","get","(","'CONTENT_TYPE'",",","''",")",".","lower","(",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1149-L1151"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.is_xhr","parameters":"(self)","argument_list":"","return_statement":"return requested_with.lower() == 'xmlhttprequest'","docstring":"True if the request was triggered by a XMLHttpRequest. This only\n            works with JavaScript libraries that support the `X-Requested-With`\n            header (most of the popular libraries do).","docstring_summary":"True if the request was triggered by a XMLHttpRequest. This only\n            works with JavaScript libraries that support the `X-Requested-With`\n            header (most of the popular libraries do).","docstring_tokens":["True","if","the","request","was","triggered","by","a","XMLHttpRequest",".","This","only","works","with","JavaScript","libraries","that","support","the","X","-","Requested","-","With","header","(","most","of","the","popular","libraries","do",")","."],"function":"def is_xhr(self):\n        ''' True if the request was triggered by a XMLHttpRequest. This only\n            works with JavaScript libraries that support the `X-Requested-With`\n            header (most of the popular libraries do). '''\n        requested_with = self.environ.get('HTTP_X_REQUESTED_WITH','')\n        return requested_with.lower() == 'xmlhttprequest'","function_tokens":["def","is_xhr","(","self",")",":","requested_with","=","self",".","environ",".","get","(","'HTTP_X_REQUESTED_WITH'",",","''",")","return","requested_with",".","lower","(",")","==","'xmlhttprequest'"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1154-L1159"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.is_ajax","parameters":"(self)","argument_list":"","return_statement":"return self.is_xhr","docstring":"Alias for :attr:`is_xhr`. \"Ajax\" is not the right term.","docstring_summary":"Alias for :attr:`is_xhr`. \"Ajax\" is not the right term.","docstring_tokens":["Alias","for",":","attr",":","is_xhr",".","Ajax","is","not","the","right","term","."],"function":"def is_ajax(self):\n        ''' Alias for :attr:`is_xhr`. \"Ajax\" is not the right term. '''\n        return self.is_xhr","function_tokens":["def","is_ajax","(","self",")",":","return","self",".","is_xhr"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1162-L1164"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.auth","parameters":"(self)","argument_list":"","return_statement":"return None","docstring":"HTTP authentication data as a (user, password) tuple. This\n            implementation currently supports basic (not digest) authentication\n            only. If the authentication happened at a higher level (e.g. in the\n            front web-server or a middleware), the password field is None, but\n            the user field is looked up from the ``REMOTE_USER`` environ\n            variable. On any errors, None is returned.","docstring_summary":"HTTP authentication data as a (user, password) tuple. This\n            implementation currently supports basic (not digest) authentication\n            only. If the authentication happened at a higher level (e.g. in the\n            front web-server or a middleware), the password field is None, but\n            the user field is looked up from the ``REMOTE_USER`` environ\n            variable. On any errors, None is returned.","docstring_tokens":["HTTP","authentication","data","as","a","(","user","password",")","tuple",".","This","implementation","currently","supports","basic","(","not","digest",")","authentication","only",".","If","the","authentication","happened","at","a","higher","level","(","e",".","g",".","in","the","front","web","-","server","or","a","middleware",")","the","password","field","is","None","but","the","user","field","is","looked","up","from","the","REMOTE_USER","environ","variable",".","On","any","errors","None","is","returned","."],"function":"def auth(self):\n        \"\"\" HTTP authentication data as a (user, password) tuple. This\n            implementation currently supports basic (not digest) authentication\n            only. If the authentication happened at a higher level (e.g. in the\n            front web-server or a middleware), the password field is None, but\n            the user field is looked up from the ``REMOTE_USER`` environ\n            variable. On any errors, None is returned. \"\"\"\n        basic = parse_auth(self.environ.get('HTTP_AUTHORIZATION',''))\n        if basic: return basic\n        ruser = self.environ.get('REMOTE_USER')\n        if ruser: return (ruser, None)\n        return None","function_tokens":["def","auth","(","self",")",":","basic","=","parse_auth","(","self",".","environ",".","get","(","'HTTP_AUTHORIZATION'",",","''",")",")","if","basic",":","return","basic","ruser","=","self",".","environ",".","get","(","'REMOTE_USER'",")","if","ruser",":","return","(","ruser",",","None",")","return","None"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1167-L1178"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.remote_route","parameters":"(self)","argument_list":"","return_statement":"return [remote] if remote else []","docstring":"A list of all IPs that were involved in this request, starting with\n            the client IP and followed by zero or more proxies. This does only\n            work if all proxies support the ```X-Forwarded-For`` header. Note\n            that this information can be forged by malicious clients.","docstring_summary":"A list of all IPs that were involved in this request, starting with\n            the client IP and followed by zero or more proxies. This does only\n            work if all proxies support the ```X-Forwarded-For`` header. Note\n            that this information can be forged by malicious clients.","docstring_tokens":["A","list","of","all","IPs","that","were","involved","in","this","request","starting","with","the","client","IP","and","followed","by","zero","or","more","proxies",".","This","does","only","work","if","all","proxies","support","the","X","-","Forwarded","-","For","header",".","Note","that","this","information","can","be","forged","by","malicious","clients","."],"function":"def remote_route(self):\n        \"\"\" A list of all IPs that were involved in this request, starting with\n            the client IP and followed by zero or more proxies. This does only\n            work if all proxies support the ```X-Forwarded-For`` header. Note\n            that this information can be forged by malicious clients. \"\"\"\n        proxy = self.environ.get('HTTP_X_FORWARDED_FOR')\n        if proxy: return [ip.strip() for ip in proxy.split(',')]\n        remote = self.environ.get('REMOTE_ADDR')\n        return [remote] if remote else []","function_tokens":["def","remote_route","(","self",")",":","proxy","=","self",".","environ",".","get","(","'HTTP_X_FORWARDED_FOR'",")","if","proxy",":","return","[","ip",".","strip","(",")","for","ip","in","proxy",".","split","(","','",")","]","remote","=","self",".","environ",".","get","(","'REMOTE_ADDR'",")","return","[","remote","]","if","remote","else","[","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1181-L1189"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.remote_addr","parameters":"(self)","argument_list":"","return_statement":"return route[0] if route else None","docstring":"The client IP as a string. Note that this information can be forged\n            by malicious clients.","docstring_summary":"The client IP as a string. Note that this information can be forged\n            by malicious clients.","docstring_tokens":["The","client","IP","as","a","string",".","Note","that","this","information","can","be","forged","by","malicious","clients","."],"function":"def remote_addr(self):\n        \"\"\" The client IP as a string. Note that this information can be forged\n            by malicious clients. \"\"\"\n        route = self.remote_route\n        return route[0] if route else None","function_tokens":["def","remote_addr","(","self",")",":","route","=","self",".","remote_route","return","route","[","0","]","if","route","else","None"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1192-L1196"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.copy","parameters":"(self)","argument_list":"","return_statement":"return Request(self.environ.copy())","docstring":"Return a new :class:`Request` with a shallow :attr:`environ` copy.","docstring_summary":"Return a new :class:`Request` with a shallow :attr:`environ` copy.","docstring_tokens":["Return","a","new",":","class",":","Request","with","a","shallow",":","attr",":","environ","copy","."],"function":"def copy(self):\n        \"\"\" Return a new :class:`Request` with a shallow :attr:`environ` copy. \"\"\"\n        return Request(self.environ.copy())","function_tokens":["def","copy","(","self",")",":","return","Request","(","self",".","environ",".","copy","(",")",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1198-L1200"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.__setitem__","parameters":"(self, key, value)","argument_list":"","return_statement":"","docstring":"Change an environ value and clear all caches that depend on it.","docstring_summary":"Change an environ value and clear all caches that depend on it.","docstring_tokens":["Change","an","environ","value","and","clear","all","caches","that","depend","on","it","."],"function":"def __setitem__(self, key, value):\n        \"\"\" Change an environ value and clear all caches that depend on it. \"\"\"\n\n        if self.environ.get('bottle.request.readonly'):\n            raise KeyError('The environ dictionary is read-only.')\n\n        self.environ[key] = value\n        todelete = ()\n\n        if key == 'wsgi.input':\n            todelete = ('body', 'forms', 'files', 'params', 'post', 'json')\n        elif key == 'QUERY_STRING':\n            todelete = ('query', 'params')\n        elif key.startswith('HTTP_'):\n            todelete = ('headers', 'cookies')\n\n        for key in todelete:\n            self.environ.pop('bottle.request.'+key, None)","function_tokens":["def","__setitem__","(","self",",","key",",","value",")",":","if","self",".","environ",".","get","(","'bottle.request.readonly'",")",":","raise","KeyError","(","'The environ dictionary is read-only.'",")","self",".","environ","[","key","]","=","value","todelete","=","(",")","if","key","==","'wsgi.input'",":","todelete","=","(","'body'",",","'forms'",",","'files'",",","'params'",",","'post'",",","'json'",")","elif","key","==","'QUERY_STRING'",":","todelete","=","(","'query'",",","'params'",")","elif","key",".","startswith","(","'HTTP_'",")",":","todelete","=","(","'headers'",",","'cookies'",")","for","key","in","todelete",":","self",".","environ",".","pop","(","'bottle.request.'","+","key",",","None",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1208-L1225"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseRequest.__getattr__","parameters":"(self, name)","argument_list":"","return_statement":"","docstring":"Search in self.environ for additional user defined attributes.","docstring_summary":"Search in self.environ for additional user defined attributes.","docstring_tokens":["Search","in","self",".","environ","for","additional","user","defined","attributes","."],"function":"def __getattr__(self, name):\n        ''' Search in self.environ for additional user defined attributes. '''\n        try:\n            var = self.environ['bottle.request.ext.%s'%name]\n            return var.__get__(self) if hasattr(var, '__get__') else var\n        except KeyError:\n            raise AttributeError('Attribute %r not defined.' % name)","function_tokens":["def","__getattr__","(","self",",","name",")",":","try",":","var","=","self",".","environ","[","'bottle.request.ext.%s'","%","name","]","return","var",".","__get__","(","self",")","if","hasattr","(","var",",","'__get__'",")","else","var","except","KeyError",":","raise","AttributeError","(","'Attribute %r not defined.'","%","name",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1230-L1236"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.copy","parameters":"(self)","argument_list":"","return_statement":"return copy","docstring":"Returns a copy of self.","docstring_summary":"Returns a copy of self.","docstring_tokens":["Returns","a","copy","of","self","."],"function":"def copy(self):\n        ''' Returns a copy of self. '''\n        copy = Response()\n        copy.status = self.status\n        copy._headers = dict((k, v[:]) for (k, v) in self._headers.items())\n        return copy","function_tokens":["def","copy","(","self",")",":","copy","=","Response","(",")","copy",".","status","=","self",".","status","copy",".","_headers","=","dict","(","(","k",",","v","[",":","]",")","for","(","k",",","v",")","in","self",".","_headers",".","items","(",")",")","return","copy"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1295-L1300"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.status_line","parameters":"(self)","argument_list":"","return_statement":"return self._status_line","docstring":"The HTTP status line as a string (e.g. ``404 Not Found``).","docstring_summary":"The HTTP status line as a string (e.g. ``404 Not Found``).","docstring_tokens":["The","HTTP","status","line","as","a","string","(","e",".","g",".","404","Not","Found",")","."],"function":"def status_line(self):\n        ''' The HTTP status line as a string (e.g. ``404 Not Found``).'''\n        return self._status_line","function_tokens":["def","status_line","(","self",")",":","return","self",".","_status_line"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1310-L1312"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.status_code","parameters":"(self)","argument_list":"","return_statement":"return self._status_code","docstring":"The HTTP status code as an integer (e.g. 404).","docstring_summary":"The HTTP status code as an integer (e.g. 404).","docstring_tokens":["The","HTTP","status","code","as","an","integer","(","e",".","g",".","404",")","."],"function":"def status_code(self):\n        ''' The HTTP status code as an integer (e.g. 404).'''\n        return self._status_code","function_tokens":["def","status_code","(","self",")",":","return","self",".","_status_code"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1315-L1317"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.headers","parameters":"(self)","argument_list":"","return_statement":"return hdict","docstring":"An instance of :class:`HeaderDict`, a case-insensitive dict-like\n            view on the response headers.","docstring_summary":"An instance of :class:`HeaderDict`, a case-insensitive dict-like\n            view on the response headers.","docstring_tokens":["An","instance","of",":","class",":","HeaderDict","a","case","-","insensitive","dict","-","like","view","on","the","response","headers","."],"function":"def headers(self):\n        ''' An instance of :class:`HeaderDict`, a case-insensitive dict-like\n            view on the response headers. '''\n        hdict = HeaderDict()\n        hdict.dict = self._headers\n        return hdict","function_tokens":["def","headers","(","self",")",":","hdict","=","HeaderDict","(",")","hdict",".","dict","=","self",".","_headers","return","hdict"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1343-L1348"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.get_header","parameters":"(self, name, default=None)","argument_list":"","return_statement":"return self._headers.get(_hkey(name), [default])[-1]","docstring":"Return the value of a previously defined header. If there is no\n            header with that name, return a default value.","docstring_summary":"Return the value of a previously defined header. If there is no\n            header with that name, return a default value.","docstring_tokens":["Return","the","value","of","a","previously","defined","header",".","If","there","is","no","header","with","that","name","return","a","default","value","."],"function":"def get_header(self, name, default=None):\n        ''' Return the value of a previously defined header. If there is no\n            header with that name, return a default value. '''\n        return self._headers.get(_hkey(name), [default])[-1]","function_tokens":["def","get_header","(","self",",","name",",","default","=","None",")",":","return","self",".","_headers",".","get","(","_hkey","(","name",")",",","[","default","]",")","[","-","1","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1355-L1358"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.set_header","parameters":"(self, name, value)","argument_list":"","return_statement":"","docstring":"Create a new response header, replacing any previously defined\n            headers with the same name.","docstring_summary":"Create a new response header, replacing any previously defined\n            headers with the same name.","docstring_tokens":["Create","a","new","response","header","replacing","any","previously","defined","headers","with","the","same","name","."],"function":"def set_header(self, name, value):\n        ''' Create a new response header, replacing any previously defined\n            headers with the same name. '''\n        self._headers[_hkey(name)] = [str(value)]","function_tokens":["def","set_header","(","self",",","name",",","value",")",":","self",".","_headers","[","_hkey","(","name",")","]","=","[","str","(","value",")","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1360-L1363"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.add_header","parameters":"(self, name, value)","argument_list":"","return_statement":"","docstring":"Add an additional response header, not removing duplicates.","docstring_summary":"Add an additional response header, not removing duplicates.","docstring_tokens":["Add","an","additional","response","header","not","removing","duplicates","."],"function":"def add_header(self, name, value):\n        ''' Add an additional response header, not removing duplicates. '''\n        self._headers.setdefault(_hkey(name), []).append(str(value))","function_tokens":["def","add_header","(","self",",","name",",","value",")",":","self",".","_headers",".","setdefault","(","_hkey","(","name",")",",","[","]",")",".","append","(","str","(","value",")",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1365-L1367"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.iter_headers","parameters":"(self)","argument_list":"","return_statement":"return self.headerlist","docstring":"Yield (header, value) tuples, skipping headers that are not\n            allowed with the current response status code.","docstring_summary":"Yield (header, value) tuples, skipping headers that are not\n            allowed with the current response status code.","docstring_tokens":["Yield","(","header","value",")","tuples","skipping","headers","that","are","not","allowed","with","the","current","response","status","code","."],"function":"def iter_headers(self):\n        ''' Yield (header, value) tuples, skipping headers that are not\n            allowed with the current response status code. '''\n        return self.headerlist","function_tokens":["def","iter_headers","(","self",")",":","return","self",".","headerlist"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1369-L1372"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.headerlist","parameters":"(self)","argument_list":"","return_statement":"return out","docstring":"WSGI conform list of (header, value) tuples.","docstring_summary":"WSGI conform list of (header, value) tuples.","docstring_tokens":["WSGI","conform","list","of","(","header","value",")","tuples","."],"function":"def headerlist(self):\n        ''' WSGI conform list of (header, value) tuples. '''\n        out = []\n        headers = self._headers.items()\n        if self._status_code in self.bad_headers:\n            bad_headers = self.bad_headers[self._status_code]\n            headers = [h for h in headers if h[0] not in bad_headers]\n        out += [(name, val) for name, vals in headers for val in vals]\n        if self._cookies:\n            for c in self._cookies.values():\n                out.append(('Set-Cookie', c.OutputString()))\n        return out","function_tokens":["def","headerlist","(","self",")",":","out","=","[","]","headers","=","self",".","_headers",".","items","(",")","if","self",".","_status_code","in","self",".","bad_headers",":","bad_headers","=","self",".","bad_headers","[","self",".","_status_code","]","headers","=","[","h","for","h","in","headers","if","h","[","0","]","not","in","bad_headers","]","out","+=","[","(","name",",","val",")","for","name",",","vals","in","headers","for","val","in","vals","]","if","self",".","_cookies",":","for","c","in","self",".","_cookies",".","values","(",")",":","out",".","append","(","(","'Set-Cookie'",",","c",".","OutputString","(",")",")",")","return","out"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1379-L1390"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.charset","parameters":"(self)","argument_list":"","return_statement":"return 'UTF-8'","docstring":"Return the charset specified in the content-type header (default: utf8).","docstring_summary":"Return the charset specified in the content-type header (default: utf8).","docstring_tokens":["Return","the","charset","specified","in","the","content","-","type","header","(","default",":","utf8",")","."],"function":"def charset(self):\n        \"\"\" Return the charset specified in the content-type header (default: utf8). \"\"\"\n        if 'charset=' in self.content_type:\n            return self.content_type.split('charset=')[-1].split(';')[0].strip()\n        return 'UTF-8'","function_tokens":["def","charset","(","self",")",":","if","'charset='","in","self",".","content_type",":","return","self",".","content_type",".","split","(","'charset='",")","[","-","1","]",".","split","(","';'",")","[","0","]",".","strip","(",")","return","'UTF-8'"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1396-L1400"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.COOKIES","parameters":"(self)","argument_list":"","return_statement":"return self._cookies","docstring":"A dict-like SimpleCookie instance. This should not be used directly.\n            See :meth:`set_cookie`.","docstring_summary":"A dict-like SimpleCookie instance. This should not be used directly.\n            See :meth:`set_cookie`.","docstring_tokens":["A","dict","-","like","SimpleCookie","instance",".","This","should","not","be","used","directly",".","See",":","meth",":","set_cookie","."],"function":"def COOKIES(self):\n        \"\"\" A dict-like SimpleCookie instance. This should not be used directly.\n            See :meth:`set_cookie`. \"\"\"\n        depr('The COOKIES dict is deprecated. Use `set_cookie()` instead.') # 0.10\n        if not self._cookies:\n            self._cookies = SimpleCookie()\n        return self._cookies","function_tokens":["def","COOKIES","(","self",")",":","depr","(","'The COOKIES dict is deprecated. Use `set_cookie()` instead.'",")","# 0.10","if","not","self",".","_cookies",":","self",".","_cookies","=","SimpleCookie","(",")","return","self",".","_cookies"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1403-L1409"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.set_cookie","parameters":"(self, name, value, secret=None, **options)","argument_list":"","return_statement":"","docstring":"Create a new cookie or replace an old one. If the `secret` parameter is\n            set, create a `Signed Cookie` (described below).\n\n            :param name: the name of the cookie.\n            :param value: the value of the cookie.\n            :param secret: a signature key required for signed cookies.\n\n            Additionally, this method accepts all RFC 2109 attributes that are\n            supported by :class:`cookie.Morsel`, including:\n\n            :param max_age: maximum age in seconds. (default: None)\n            :param expires: a datetime object or UNIX timestamp. (default: None)\n            :param domain: the domain that is allowed to read the cookie.\n              (default: current domain)\n            :param path: limits the cookie to a given path (default: current path)\n            :param secure: limit the cookie to HTTPS connections (default: off).\n            :param httponly: prevents client-side javascript to read this cookie\n              (default: off, requires Python 2.6 or newer).\n\n            If neither `expires` nor `max_age` is set (default), the cookie will\n            expire at the end of the browser session (as soon as the browser\n            window is closed).\n\n            Signed cookies may store any pickle-able object and are\n            cryptographically signed to prevent manipulation. Keep in mind that\n            cookies are limited to 4kb in most browsers.\n\n            Warning: Signed cookies are not encrypted (the client can still see\n            the content) and not copy-protected (the client can restore an old\n            cookie). The main intention is to make pickling and unpickling\n            save, not to store secret information at client side.","docstring_summary":"Create a new cookie or replace an old one. If the `secret` parameter is\n            set, create a `Signed Cookie` (described below).","docstring_tokens":["Create","a","new","cookie","or","replace","an","old","one",".","If","the","secret","parameter","is","set","create","a","Signed","Cookie","(","described","below",")","."],"function":"def set_cookie(self, name, value, secret=None, **options):\n        ''' Create a new cookie or replace an old one. If the `secret` parameter is\n            set, create a `Signed Cookie` (described below).\n\n            :param name: the name of the cookie.\n            :param value: the value of the cookie.\n            :param secret: a signature key required for signed cookies.\n\n            Additionally, this method accepts all RFC 2109 attributes that are\n            supported by :class:`cookie.Morsel`, including:\n\n            :param max_age: maximum age in seconds. (default: None)\n            :param expires: a datetime object or UNIX timestamp. (default: None)\n            :param domain: the domain that is allowed to read the cookie.\n              (default: current domain)\n            :param path: limits the cookie to a given path (default: current path)\n            :param secure: limit the cookie to HTTPS connections (default: off).\n            :param httponly: prevents client-side javascript to read this cookie\n              (default: off, requires Python 2.6 or newer).\n\n            If neither `expires` nor `max_age` is set (default), the cookie will\n            expire at the end of the browser session (as soon as the browser\n            window is closed).\n\n            Signed cookies may store any pickle-able object and are\n            cryptographically signed to prevent manipulation. Keep in mind that\n            cookies are limited to 4kb in most browsers.\n\n            Warning: Signed cookies are not encrypted (the client can still see\n            the content) and not copy-protected (the client can restore an old\n            cookie). The main intention is to make pickling and unpickling\n            save, not to store secret information at client side.\n        '''\n        if not self._cookies:\n            self._cookies = SimpleCookie()\n\n        if secret:\n            value = touni(cookie_encode((name, value), secret))\n        elif not isinstance(value, basestring):\n            raise TypeError('Secret key missing for non-string Cookie.')\n\n        if len(value) > 4096: raise ValueError('Cookie value to long.')\n        self._cookies[name] = value\n\n        for key, value in options.items():\n            if key == 'max_age':\n                if isinstance(value, timedelta):\n                    value = value.seconds + value.days * 24 * 3600\n            if key == 'expires':\n                if isinstance(value, (datedate, datetime)):\n                    value = value.timetuple()\n                elif isinstance(value, (int, float)):\n                    value = time.gmtime(value)\n                value = time.strftime(\"%a, %d %b %Y %H:%M:%S GMT\", value)\n            self._cookies[name][key.replace('_', '-')] = value","function_tokens":["def","set_cookie","(","self",",","name",",","value",",","secret","=","None",",","*","*","options",")",":","if","not","self",".","_cookies",":","self",".","_cookies","=","SimpleCookie","(",")","if","secret",":","value","=","touni","(","cookie_encode","(","(","name",",","value",")",",","secret",")",")","elif","not","isinstance","(","value",",","basestring",")",":","raise","TypeError","(","'Secret key missing for non-string Cookie.'",")","if","len","(","value",")",">","4096",":","raise","ValueError","(","'Cookie value to long.'",")","self",".","_cookies","[","name","]","=","value","for","key",",","value","in","options",".","items","(",")",":","if","key","==","'max_age'",":","if","isinstance","(","value",",","timedelta",")",":","value","=","value",".","seconds","+","value",".","days","*","24","*","3600","if","key","==","'expires'",":","if","isinstance","(","value",",","(","datedate",",","datetime",")",")",":","value","=","value",".","timetuple","(",")","elif","isinstance","(","value",",","(","int",",","float",")",")",":","value","=","time",".","gmtime","(","value",")","value","=","time",".","strftime","(","\"%a, %d %b %Y %H:%M:%S GMT\"",",","value",")","self",".","_cookies","[","name","]","[","key",".","replace","(","'_'",",","'-'",")","]","=","value"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1411-L1465"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseResponse.delete_cookie","parameters":"(self, key, **kwargs)","argument_list":"","return_statement":"","docstring":"Delete a cookie. Be sure to use the same `domain` and `path`\n            settings as used to create the cookie.","docstring_summary":"Delete a cookie. Be sure to use the same `domain` and `path`\n            settings as used to create the cookie.","docstring_tokens":["Delete","a","cookie",".","Be","sure","to","use","the","same","domain","and","path","settings","as","used","to","create","the","cookie","."],"function":"def delete_cookie(self, key, **kwargs):\n        ''' Delete a cookie. Be sure to use the same `domain` and `path`\n            settings as used to create the cookie. '''\n        kwargs['max_age'] = -1\n        kwargs['expires'] = 0\n        self.set_cookie(key, '', **kwargs)","function_tokens":["def","delete_cookie","(","self",",","key",",","*","*","kwargs",")",":","kwargs","[","'max_age'","]","=","-","1","kwargs","[","'expires'","]","=","0","self",".","set_cookie","(","key",",","''",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1467-L1472"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"HooksPlugin.add","parameters":"(self, name, func)","argument_list":"","return_statement":"","docstring":"Attach a callback to a hook.","docstring_summary":"Attach a callback to a hook.","docstring_tokens":["Attach","a","callback","to","a","hook","."],"function":"def add(self, name, func):\n        ''' Attach a callback to a hook. '''\n        was_empty = self._empty()\n        self.hooks.setdefault(name, []).append(func)\n        if self.app and was_empty and not self._empty(): self.app.reset()","function_tokens":["def","add","(","self",",","name",",","func",")",":","was_empty","=","self",".","_empty","(",")","self",".","hooks",".","setdefault","(","name",",","[","]",")",".","append","(","func",")","if","self",".","app","and","was_empty","and","not","self",".","_empty","(",")",":","self",".","app",".","reset","(",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1599-L1603"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"HooksPlugin.remove","parameters":"(self, name, func)","argument_list":"","return_statement":"","docstring":"Remove a callback from a hook.","docstring_summary":"Remove a callback from a hook.","docstring_tokens":["Remove","a","callback","from","a","hook","."],"function":"def remove(self, name, func):\n        ''' Remove a callback from a hook. '''\n        was_empty = self._empty()\n        if name in self.hooks and func in self.hooks[name]:\n            self.hooks[name].remove(func)\n        if self.app and not was_empty and self._empty(): self.app.reset()","function_tokens":["def","remove","(","self",",","name",",","func",")",":","was_empty","=","self",".","_empty","(",")","if","name","in","self",".","hooks","and","func","in","self",".","hooks","[","name","]",":","self",".","hooks","[","name","]",".","remove","(","func",")","if","self",".","app","and","not","was_empty","and","self",".","_empty","(",")",":","self",".","app",".","reset","(",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1605-L1610"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"HooksPlugin.trigger","parameters":"(self, name, *a, **ka)","argument_list":"","return_statement":"return [hook(*a, **ka) for hook in hooks]","docstring":"Trigger a hook and return a list of results.","docstring_summary":"Trigger a hook and return a list of results.","docstring_tokens":["Trigger","a","hook","and","return","a","list","of","results","."],"function":"def trigger(self, name, *a, **ka):\n        ''' Trigger a hook and return a list of results. '''\n        hooks = self.hooks[name]\n        if ka.pop('reversed', False): hooks = hooks[::-1]\n        return [hook(*a, **ka) for hook in hooks]","function_tokens":["def","trigger","(","self",",","name",",","*","a",",","*","*","ka",")",":","hooks","=","self",".","hooks","[","name","]","if","ka",".","pop","(","'reversed'",",","False",")",":","hooks","=","hooks","[",":",":","-","1","]","return","[","hook","(","*","a",",","*","*","ka",")","for","hook","in","hooks","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1612-L1616"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"_ImportRedirect.__init__","parameters":"(self, name, impmask)","argument_list":"","return_statement":"","docstring":"Create a virtual package that redirects imports (see PEP 302).","docstring_summary":"Create a virtual package that redirects imports (see PEP 302).","docstring_tokens":["Create","a","virtual","package","that","redirects","imports","(","see","PEP","302",")","."],"function":"def __init__(self, name, impmask):\n        ''' Create a virtual package that redirects imports (see PEP 302). '''\n        self.name = name\n        self.impmask = impmask\n        self.module = sys.modules.setdefault(name, imp.new_module(name))\n        self.module.__dict__.update({'__file__': __file__, '__path__': [],\n                                    '__all__': [], '__loader__': self})\n        sys.meta_path.append(self)","function_tokens":["def","__init__","(","self",",","name",",","impmask",")",":","self",".","name","=","name","self",".","impmask","=","impmask","self",".","module","=","sys",".","modules",".","setdefault","(","name",",","imp",".","new_module","(","name",")",")","self",".","module",".","__dict__",".","update","(","{","'__file__'",":","__file__",",","'__path__'",":","[","]",",","'__all__'",":","[","]",",","'__loader__'",":","self","}",")","sys",".","meta_path",".","append","(","self",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1651-L1658"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"MultiDict.get","parameters":"(self, key, default=None, index=-1, type=None)","argument_list":"","return_statement":"return default","docstring":"Return the most recent value for a key.\n\n            :param default: The default value to be returned if the key is not\n                   present or the type conversion fails.\n            :param index: An index for the list of available values.\n            :param type: If defined, this callable is used to cast the value\n                    into a specific type. Exception are suppressed and result in\n                    the default value to be returned.","docstring_summary":"Return the most recent value for a key.","docstring_tokens":["Return","the","most","recent","value","for","a","key","."],"function":"def get(self, key, default=None, index=-1, type=None):\n        ''' Return the most recent value for a key.\n\n            :param default: The default value to be returned if the key is not\n                   present or the type conversion fails.\n            :param index: An index for the list of available values.\n            :param type: If defined, this callable is used to cast the value\n                    into a specific type. Exception are suppressed and result in\n                    the default value to be returned.\n        '''\n        try:\n            val = self.dict[key][index]\n            return type(val) if type else val\n        except Exception:\n            pass\n        return default","function_tokens":["def","get","(","self",",","key",",","default","=","None",",","index","=","-","1",",","type","=","None",")",":","try",":","val","=","self",".","dict","[","key","]","[","index","]","return","type","(","val",")","if","type","else","val","except","Exception",":","pass","return","default"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1725-L1740"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"MultiDict.append","parameters":"(self, key, value)","argument_list":"","return_statement":"","docstring":"Add a new value to the list of values for this key.","docstring_summary":"Add a new value to the list of values for this key.","docstring_tokens":["Add","a","new","value","to","the","list","of","values","for","this","key","."],"function":"def append(self, key, value):\n        ''' Add a new value to the list of values for this key. '''\n        self.dict.setdefault(key, []).append(value)","function_tokens":["def","append","(","self",",","key",",","value",")",":","self",".","dict",".","setdefault","(","key",",","[","]",")",".","append","(","value",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1742-L1744"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"MultiDict.replace","parameters":"(self, key, value)","argument_list":"","return_statement":"","docstring":"Replace the list of values with a single value.","docstring_summary":"Replace the list of values with a single value.","docstring_tokens":["Replace","the","list","of","values","with","a","single","value","."],"function":"def replace(self, key, value):\n        ''' Replace the list of values with a single value. '''\n        self.dict[key] = [value]","function_tokens":["def","replace","(","self",",","key",",","value",")",":","self",".","dict","[","key","]","=","[","value","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1746-L1748"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"MultiDict.getall","parameters":"(self, key)","argument_list":"","return_statement":"return self.dict.get(key) or []","docstring":"Return a (possibly empty) list of values for a key.","docstring_summary":"Return a (possibly empty) list of values for a key.","docstring_tokens":["Return","a","(","possibly","empty",")","list","of","values","for","a","key","."],"function":"def getall(self, key):\n        ''' Return a (possibly empty) list of values for a key. '''\n        return self.dict.get(key) or []","function_tokens":["def","getall","(","self",",","key",")",":","return","self",".","dict",".","get","(","key",")","or","[","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1750-L1752"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"FormsDict.decode","parameters":"(self, encoding=None)","argument_list":"","return_statement":"return copy","docstring":"Returns a copy with all keys and values de- or recoded to match\n            :attr:`input_encoding`. Some libraries (e.g. WTForms) want a\n            unicode dictionary.","docstring_summary":"Returns a copy with all keys and values de- or recoded to match\n            :attr:`input_encoding`. Some libraries (e.g. WTForms) want a\n            unicode dictionary.","docstring_tokens":["Returns","a","copy","with","all","keys","and","values","de","-","or","recoded","to","match",":","attr",":","input_encoding",".","Some","libraries","(","e",".","g",".","WTForms",")","want","a","unicode","dictionary","."],"function":"def decode(self, encoding=None):\n        ''' Returns a copy with all keys and values de- or recoded to match\n            :attr:`input_encoding`. Some libraries (e.g. WTForms) want a\n            unicode dictionary. '''\n        copy = FormsDict()\n        enc = copy.input_encoding = encoding or self.input_encoding\n        copy.recode_unicode = False\n        for key, value in self.allitems():\n            copy.append(self._fix(key, enc), self._fix(value, enc))\n        return copy","function_tokens":["def","decode","(","self",",","encoding","=","None",")",":","copy","=","FormsDict","(",")","enc","=","copy",".","input_encoding","=","encoding","or","self",".","input_encoding","copy",".","recode_unicode","=","False","for","key",",","value","in","self",".","allitems","(",")",":","copy",".","append","(","self",".","_fix","(","key",",","enc",")",",","self",".","_fix","(","value",",","enc",")",")","return","copy"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1781-L1790"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"WSGIHeaderDict._ekey","parameters":"(self, key)","argument_list":"","return_statement":"return 'HTTP_' + key","docstring":"Translate header field name to CGI\/WSGI environ key.","docstring_summary":"Translate header field name to CGI\/WSGI environ key.","docstring_tokens":["Translate","header","field","name","to","CGI","\/","WSGI","environ","key","."],"function":"def _ekey(self, key):\n        ''' Translate header field name to CGI\/WSGI environ key. '''\n        key = key.replace('-','_').upper()\n        if key in self.cgikeys:\n            return key\n        return 'HTTP_' + key","function_tokens":["def","_ekey","(","self",",","key",")",":","key","=","key",".","replace","(","'-'",",","'_'",")",".","upper","(",")","if","key","in","self",".","cgikeys",":","return","key","return","'HTTP_'","+","key"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1846-L1851"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"WSGIHeaderDict.raw","parameters":"(self, key, default=None)","argument_list":"","return_statement":"return self.environ.get(self._ekey(key), default)","docstring":"Return the header value as is (may be bytes or unicode).","docstring_summary":"Return the header value as is (may be bytes or unicode).","docstring_tokens":["Return","the","header","value","as","is","(","may","be","bytes","or","unicode",")","."],"function":"def raw(self, key, default=None):\n        ''' Return the header value as is (may be bytes or unicode). '''\n        return self.environ.get(self._ekey(key), default)","function_tokens":["def","raw","(","self",",","key",",","default","=","None",")",":","return","self",".","environ",".","get","(","self",".","_ekey","(","key",")",",","default",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1853-L1855"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"AppStack.__call__","parameters":"(self)","argument_list":"","return_statement":"return self[-1]","docstring":"Return the current default application.","docstring_summary":"Return the current default application.","docstring_tokens":["Return","the","current","default","application","."],"function":"def __call__(self):\n        \"\"\" Return the current default application. \"\"\"\n        return self[-1]","function_tokens":["def","__call__","(","self",")",":","return","self","[","-","1","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1914-L1916"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"AppStack.push","parameters":"(self, value=None)","argument_list":"","return_statement":"return value","docstring":"Add a new :class:`Bottle` instance to the stack","docstring_summary":"Add a new :class:`Bottle` instance to the stack","docstring_tokens":["Add","a","new",":","class",":","Bottle","instance","to","the","stack"],"function":"def push(self, value=None):\n        \"\"\" Add a new :class:`Bottle` instance to the stack \"\"\"\n        if not isinstance(value, Bottle):\n            value = Bottle()\n        self.append(value)\n        return value","function_tokens":["def","push","(","self",",","value","=","None",")",":","if","not","isinstance","(","value",",","Bottle",")",":","value","=","Bottle","(",")","self",".","append","(","value",")","return","value"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1918-L1923"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"ResourceManager.add_path","parameters":"(self, path, base=None, index=None, create=False)","argument_list":"","return_statement":"return os.path.exists(path)","docstring":"Add a new path to the list of search paths. Return False if the\n            path does not exist.\n\n            :param path: The new search path. Relative paths are turned into\n                an absolute and normalized form. If the path looks like a file\n                (not ending in `\/`), the filename is stripped off.\n            :param base: Path used to absolutize relative search paths.\n                Defaults to :attr:`base` which defaults to ``os.getcwd()``.\n            :param index: Position within the list of search paths. Defaults\n                to last index (appends to the list).\n\n            The `base` parameter makes it easy to reference files installed\n            along with a python module or package::\n\n                res.add_path('.\/resources\/', __file__)","docstring_summary":"Add a new path to the list of search paths. Return False if the\n            path does not exist.","docstring_tokens":["Add","a","new","path","to","the","list","of","search","paths",".","Return","False","if","the","path","does","not","exist","."],"function":"def add_path(self, path, base=None, index=None, create=False):\n        ''' Add a new path to the list of search paths. Return False if the\n            path does not exist.\n\n            :param path: The new search path. Relative paths are turned into\n                an absolute and normalized form. If the path looks like a file\n                (not ending in `\/`), the filename is stripped off.\n            :param base: Path used to absolutize relative search paths.\n                Defaults to :attr:`base` which defaults to ``os.getcwd()``.\n            :param index: Position within the list of search paths. Defaults\n                to last index (appends to the list).\n\n            The `base` parameter makes it easy to reference files installed\n            along with a python module or package::\n\n                res.add_path('.\/resources\/', __file__)\n        '''\n        base = os.path.abspath(os.path.dirname(base or self.base))\n        path = os.path.abspath(os.path.join(base, os.path.dirname(path)))\n        path += os.sep\n        if path in self.path:\n            self.path.remove(path)\n        if create and not os.path.isdir(path):\n            os.makedirs(path)\n        if index is None:\n            self.path.append(path)\n        else:\n            self.path.insert(index, path)\n        self.cache.clear()\n        return os.path.exists(path)","function_tokens":["def","add_path","(","self",",","path",",","base","=","None",",","index","=","None",",","create","=","False",")",":","base","=","os",".","path",".","abspath","(","os",".","path",".","dirname","(","base","or","self",".","base",")",")","path","=","os",".","path",".","abspath","(","os",".","path",".","join","(","base",",","os",".","path",".","dirname","(","path",")",")",")","path","+=","os",".","sep","if","path","in","self",".","path",":","self",".","path",".","remove","(","path",")","if","create","and","not","os",".","path",".","isdir","(","path",")",":","os",".","makedirs","(","path",")","if","index","is","None",":","self",".","path",".","append","(","path",")","else",":","self",".","path",".","insert","(","index",",","path",")","self",".","cache",".","clear","(",")","return","os",".","path",".","exists","(","path",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1961-L1990"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"ResourceManager.__iter__","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Iterate over all existing files in all registered paths.","docstring_summary":"Iterate over all existing files in all registered paths.","docstring_tokens":["Iterate","over","all","existing","files","in","all","registered","paths","."],"function":"def __iter__(self):\n        ''' Iterate over all existing files in all registered paths. '''\n        search = self.path[:]\n        while search:\n            path = search.pop()\n            if not os.path.isdir(path): continue\n            for name in os.listdir(path):\n                full = os.path.join(path, name)\n                if os.path.isdir(full): search.append(full)\n                else: yield full","function_tokens":["def","__iter__","(","self",")",":","search","=","self",".","path","[",":","]","while","search",":","path","=","search",".","pop","(",")","if","not","os",".","path",".","isdir","(","path",")",":","continue","for","name","in","os",".","listdir","(","path",")",":","full","=","os",".","path",".","join","(","path",",","name",")","if","os",".","path",".","isdir","(","full",")",":","search",".","append","(","full",")","else",":","yield","full"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L1992-L2001"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"ResourceManager.lookup","parameters":"(self, name)","argument_list":"","return_statement":"return self.cache[name]","docstring":"Search for a resource and return an absolute file path, or `None`.\n\n            The :attr:`path` list is searched in order. The first match is\n            returend. Symlinks are followed. The result is cached to speed up\n            future lookups.","docstring_summary":"Search for a resource and return an absolute file path, or `None`.","docstring_tokens":["Search","for","a","resource","and","return","an","absolute","file","path","or","None","."],"function":"def lookup(self, name):\n        ''' Search for a resource and return an absolute file path, or `None`.\n\n            The :attr:`path` list is searched in order. The first match is\n            returend. Symlinks are followed. The result is cached to speed up\n            future lookups. '''\n        if name not in self.cache or DEBUG:\n            for path in self.path:\n                fpath = os.path.join(path, name)\n                if os.path.isfile(fpath):\n                    if self.cachemode in ('all', 'found'):\n                        self.cache[name] = fpath\n                    return fpath\n            if self.cachemode == 'all':\n                self.cache[name] = None\n        return self.cache[name]","function_tokens":["def","lookup","(","self",",","name",")",":","if","name","not","in","self",".","cache","or","DEBUG",":","for","path","in","self",".","path",":","fpath","=","os",".","path",".","join","(","path",",","name",")","if","os",".","path",".","isfile","(","fpath",")",":","if","self",".","cachemode","in","(","'all'",",","'found'",")",":","self",".","cache","[","name","]","=","fpath","return","fpath","if","self",".","cachemode","==","'all'",":","self",".","cache","[","name","]","=","None","return","self",".","cache","[","name","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2003-L2018"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"ResourceManager.open","parameters":"(self, name, mode='r', *args, **kwargs)","argument_list":"","return_statement":"return self.opener(name, mode=mode, *args, **kwargs)","docstring":"Find a resource and return a file object, or raise IOError.","docstring_summary":"Find a resource and return a file object, or raise IOError.","docstring_tokens":["Find","a","resource","and","return","a","file","object","or","raise","IOError","."],"function":"def open(self, name, mode='r', *args, **kwargs):\n        ''' Find a resource and return a file object, or raise IOError. '''\n        fname = self.lookup(name)\n        if not fname: raise IOError(\"Resource %r not found.\" % name)\n        return self.opener(name, mode=mode, *args, **kwargs)","function_tokens":["def","open","(","self",",","name",",","mode","=","'r'",",","*","args",",","*","*","kwargs",")",":","fname","=","self",".","lookup","(","name",")","if","not","fname",":","raise","IOError","(","\"Resource %r not found.\"","%","name",")","return","self",".","opener","(","name",",","mode","=","mode",",","*","args",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2020-L2024"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseTemplate.__init__","parameters":"(self, source=None, name=None, lookup=[], encoding='utf8', **settings)","argument_list":"","return_statement":"","docstring":"Create a new template.\n        If the source parameter (str or buffer) is missing, the name argument\n        is used to guess a template filename. Subclasses can assume that\n        self.source and\/or self.filename are set. Both are strings.\n        The lookup, encoding and settings parameters are stored as instance\n        variables.\n        The lookup parameter stores a list containing directory paths.\n        The encoding parameter should be used to decode byte strings or files.\n        The settings parameter contains a dict for engine-specific settings.","docstring_summary":"Create a new template.\n        If the source parameter (str or buffer) is missing, the name argument\n        is used to guess a template filename. Subclasses can assume that\n        self.source and\/or self.filename are set. Both are strings.\n        The lookup, encoding and settings parameters are stored as instance\n        variables.\n        The lookup parameter stores a list containing directory paths.\n        The encoding parameter should be used to decode byte strings or files.\n        The settings parameter contains a dict for engine-specific settings.","docstring_tokens":["Create","a","new","template",".","If","the","source","parameter","(","str","or","buffer",")","is","missing","the","name","argument","is","used","to","guess","a","template","filename",".","Subclasses","can","assume","that","self",".","source","and","\/","or","self",".","filename","are","set",".","Both","are","strings",".","The","lookup","encoding","and","settings","parameters","are","stored","as","instance","variables",".","The","lookup","parameter","stores","a","list","containing","directory","paths",".","The","encoding","parameter","should","be","used","to","decode","byte","strings","or","files",".","The","settings","parameter","contains","a","dict","for","engine","-","specific","settings","."],"function":"def __init__(self, source=None, name=None, lookup=[], encoding='utf8', **settings):\n        \"\"\" Create a new template.\n        If the source parameter (str or buffer) is missing, the name argument\n        is used to guess a template filename. Subclasses can assume that\n        self.source and\/or self.filename are set. Both are strings.\n        The lookup, encoding and settings parameters are stored as instance\n        variables.\n        The lookup parameter stores a list containing directory paths.\n        The encoding parameter should be used to decode byte strings or files.\n        The settings parameter contains a dict for engine-specific settings.\n        \"\"\"\n        self.name = name\n        self.source = source.read() if hasattr(source, 'read') else source\n        self.filename = source.filename if hasattr(source, 'filename') else None\n        self.lookup = [os.path.abspath(x) for x in lookup]\n        self.encoding = encoding\n        self.settings = self.settings.copy() # Copy from class variable\n        self.settings.update(settings) # Apply\n        if not self.source and self.name:\n            self.filename = self.search(self.name, self.lookup)\n            if not self.filename:\n                raise TemplateError('Template %s not found.' % repr(name))\n        if not self.source and not self.filename:\n            raise TemplateError('No template specified.')\n        self.prepare(**self.settings)","function_tokens":["def","__init__","(","self",",","source","=","None",",","name","=","None",",","lookup","=","[","]",",","encoding","=","'utf8'",",","*","*","settings",")",":","self",".","name","=","name","self",".","source","=","source",".","read","(",")","if","hasattr","(","source",",","'read'",")","else","source","self",".","filename","=","source",".","filename","if","hasattr","(","source",",","'filename'",")","else","None","self",".","lookup","=","[","os",".","path",".","abspath","(","x",")","for","x","in","lookup","]","self",".","encoding","=","encoding","self",".","settings","=","self",".","settings",".","copy","(",")","# Copy from class variable","self",".","settings",".","update","(","settings",")","# Apply","if","not","self",".","source","and","self",".","name",":","self",".","filename","=","self",".","search","(","self",".","name",",","self",".","lookup",")","if","not","self",".","filename",":","raise","TemplateError","(","'Template %s not found.'","%","repr","(","name",")",")","if","not","self",".","source","and","not","self",".","filename",":","raise","TemplateError","(","'No template specified.'",")","self",".","prepare","(","*","*","self",".","settings",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2774-L2798"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseTemplate.search","parameters":"(cls, name, lookup=[])","argument_list":"","return_statement":"","docstring":"Search name in all directories specified in lookup.\n        First without, then with common extensions. Return first hit.","docstring_summary":"Search name in all directories specified in lookup.\n        First without, then with common extensions. Return first hit.","docstring_tokens":["Search","name","in","all","directories","specified","in","lookup",".","First","without","then","with","common","extensions",".","Return","first","hit","."],"function":"def search(cls, name, lookup=[]):\n        \"\"\" Search name in all directories specified in lookup.\n        First without, then with common extensions. Return first hit. \"\"\"\n        if not lookup:\n            depr('The template lookup path list should not be empty.')\n            lookup = ['.']\n\n        if os.path.isabs(name) and os.path.isfile(name):\n            depr('Absolute template path names are deprecated.')\n            return os.path.abspath(name)\n\n        for spath in lookup:\n            spath = os.path.abspath(spath) + os.sep\n            fname = os.path.abspath(os.path.join(spath, name))\n            if not fname.startswith(spath): continue\n            if os.path.isfile(fname): return fname\n            for ext in cls.extensions:\n                if os.path.isfile('%s.%s' % (fname, ext)):\n                    return '%s.%s' % (fname, ext)","function_tokens":["def","search","(","cls",",","name",",","lookup","=","[","]",")",":","if","not","lookup",":","depr","(","'The template lookup path list should not be empty.'",")","lookup","=","[","'.'","]","if","os",".","path",".","isabs","(","name",")","and","os",".","path",".","isfile","(","name",")",":","depr","(","'Absolute template path names are deprecated.'",")","return","os",".","path",".","abspath","(","name",")","for","spath","in","lookup",":","spath","=","os",".","path",".","abspath","(","spath",")","+","os",".","sep","fname","=","os",".","path",".","abspath","(","os",".","path",".","join","(","spath",",","name",")",")","if","not","fname",".","startswith","(","spath",")",":","continue","if","os",".","path",".","isfile","(","fname",")",":","return","fname","for","ext","in","cls",".","extensions",":","if","os",".","path",".","isfile","(","'%s.%s'","%","(","fname",",","ext",")",")",":","return","'%s.%s'","%","(","fname",",","ext",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2801-L2819"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseTemplate.global_config","parameters":"(cls, key, *args)","argument_list":"","return_statement":"","docstring":"This reads or sets the global settings stored in class.settings.","docstring_summary":"This reads or sets the global settings stored in class.settings.","docstring_tokens":["This","reads","or","sets","the","global","settings","stored","in","class",".","settings","."],"function":"def global_config(cls, key, *args):\n        ''' This reads or sets the global settings stored in class.settings. '''\n        if args:\n            cls.settings = cls.settings.copy() # Make settings local to class\n            cls.settings[key] = args[0]\n        else:\n            return cls.settings[key]","function_tokens":["def","global_config","(","cls",",","key",",","*","args",")",":","if","args",":","cls",".","settings","=","cls",".","settings",".","copy","(",")","# Make settings local to class","cls",".","settings","[","key","]","=","args","[","0","]","else",":","return","cls",".","settings","[","key","]"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2822-L2828"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseTemplate.prepare","parameters":"(self, **options)","argument_list":"","return_statement":"","docstring":"Run preparations (parsing, caching, ...).\n        It should be possible to call this again to refresh a template or to\n        update settings.","docstring_summary":"Run preparations (parsing, caching, ...).\n        It should be possible to call this again to refresh a template or to\n        update settings.","docstring_tokens":["Run","preparations","(","parsing","caching","...",")",".","It","should","be","possible","to","call","this","again","to","refresh","a","template","or","to","update","settings","."],"function":"def prepare(self, **options):\n        \"\"\" Run preparations (parsing, caching, ...).\n        It should be possible to call this again to refresh a template or to\n        update settings.\n        \"\"\"\n        raise NotImplementedError","function_tokens":["def","prepare","(","self",",","*","*","options",")",":","raise","NotImplementedError"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2830-L2835"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"BaseTemplate.render","parameters":"(self, *args, **kwargs)","argument_list":"","return_statement":"","docstring":"Render the template with the specified local variables and return\n        a single byte or unicode string. If it is a byte string, the encoding\n        must match self.encoding. This method must be thread-safe!\n        Local variables may be provided in dictionaries (*args)\n        or directly, as keywords (**kwargs).","docstring_summary":"Render the template with the specified local variables and return\n        a single byte or unicode string. If it is a byte string, the encoding\n        must match self.encoding. This method must be thread-safe!\n        Local variables may be provided in dictionaries (*args)\n        or directly, as keywords (**kwargs).","docstring_tokens":["Render","the","template","with","the","specified","local","variables","and","return","a","single","byte","or","unicode","string",".","If","it","is","a","byte","string","the","encoding","must","match","self",".","encoding",".","This","method","must","be","thread","-","safe!","Local","variables","may","be","provided","in","dictionaries","(","*","args",")","or","directly","as","keywords","(","**","kwargs",")","."],"function":"def render(self, *args, **kwargs):\n        \"\"\" Render the template with the specified local variables and return\n        a single byte or unicode string. If it is a byte string, the encoding\n        must match self.encoding. This method must be thread-safe!\n        Local variables may be provided in dictionaries (*args)\n        or directly, as keywords (**kwargs).\n        \"\"\"\n        raise NotImplementedError","function_tokens":["def","render","(","self",",","*","args",",","*","*","kwargs",")",":","raise","NotImplementedError"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2837-L2844"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"SimpleTemplate.re_pytokens","parameters":"(cls)","argument_list":"","return_statement":"return re.compile(r'''\n            (''(?!')|\"\"(?!\")|'{6}|\"{6}    # Empty strings (all 4 types)\n             |'(?:[^\\\\']|\\\\.)+?'          # Single quotes (')\n             |\"(?:[^\\\\\"]|\\\\.)+?\"          # Double quotes (\")\n             |'{3}(?:[^\\\\]|\\\\.|\\n)+?'{3}  # Triple-quoted strings (')\n             |\"{3}(?:[^\\\\]|\\\\.|\\n)+?\"{3}  # Triple-quoted strings (\")\n             |\\#.*                        # Comments\n            )''', re.VERBOSE)","docstring":"This matches comments and all kinds of quoted strings but does\n            NOT match comments (#...) within quoted strings. (trust me)","docstring_summary":"This matches comments and all kinds of quoted strings but does\n            NOT match comments (#...) within quoted strings. (trust me)","docstring_tokens":["This","matches","comments","and","all","kinds","of","quoted","strings","but","does","NOT","match","comments","(","#","...",")","within","quoted","strings",".","(","trust","me",")"],"function":"def re_pytokens(cls):\n        ''' This matches comments and all kinds of quoted strings but does\n            NOT match comments (#...) within quoted strings. (trust me) '''\n        return re.compile(r'''\n            (''(?!')|\"\"(?!\")|'{6}|\"{6}    # Empty strings (all 4 types)\n             |'(?:[^\\\\']|\\\\.)+?'          # Single quotes (')\n             |\"(?:[^\\\\\"]|\\\\.)+?\"          # Double quotes (\")\n             |'{3}(?:[^\\\\]|\\\\.|\\n)+?'{3}  # Triple-quoted strings (')\n             |\"{3}(?:[^\\\\]|\\\\.|\\n)+?\"{3}  # Triple-quoted strings (\")\n             |\\#.*                        # Comments\n            )''', re.VERBOSE)","function_tokens":["def","re_pytokens","(","cls",")",":","return","re",".","compile","(","r'''\n            (''(?!')|\"\"(?!\")|'{6}|\"{6}    # Empty strings (all 4 types)\n             |'(?:[^\\\\']|\\\\.)+?'          # Single quotes (')\n             |\"(?:[^\\\\\"]|\\\\.)+?\"          # Double quotes (\")\n             |'{3}(?:[^\\\\]|\\\\.|\\n)+?'{3}  # Triple-quoted strings (')\n             |\"{3}(?:[^\\\\]|\\\\.|\\n)+?\"{3}  # Triple-quoted strings (\")\n             |\\#.*                        # Comments\n            )'''",",","re",".","VERBOSE",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2944-L2954"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"SimpleTemplate.split_comment","parameters":"(cls, code)","argument_list":"","return_statement":"return re.sub(cls.re_pytokens, subf, code)","docstring":"Removes comments (#...) from python code.","docstring_summary":"Removes comments (#...) from python code.","docstring_tokens":["Removes","comments","(","#","...",")","from","python","code","."],"function":"def split_comment(cls, code):\n        \"\"\" Removes comments (#...) from python code. \"\"\"\n        if '#' not in code: return code\n        #: Remove comments only (leave quoted strings as they are)\n        subf = lambda m: '' if m.group(0)[0]=='#' else m.group(0)\n        return re.sub(cls.re_pytokens, subf, code)","function_tokens":["def","split_comment","(","cls",",","code",")",":","if","'#'","not","in","code",":","return","code","#: Remove comments only (leave quoted strings as they are)","subf","=","lambda","m",":","''","if","m",".","group","(","0",")","[","0","]","==","'#'","else","m",".","group","(","0",")","return","re",".","sub","(","cls",".","re_pytokens",",","subf",",","code",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L2965-L2970"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"bottle.py","language":"python","identifier":"SimpleTemplate.render","parameters":"(self, *args, **kwargs)","argument_list":"","return_statement":"return ''.join(stdout)","docstring":"Render the template using keyword arguments as local variables.","docstring_summary":"Render the template using keyword arguments as local variables.","docstring_tokens":["Render","the","template","using","keyword","arguments","as","local","variables","."],"function":"def render(self, *args, **kwargs):\n        \"\"\" Render the template using keyword arguments as local variables. \"\"\"\n        for dictarg in args: kwargs.update(dictarg)\n        stdout = []\n        self.execute(stdout, kwargs)\n        return ''.join(stdout)","function_tokens":["def","render","(","self",",","*","args",",","*","*","kwargs",")",":","for","dictarg","in","args",":","kwargs",".","update","(","dictarg",")","stdout","=","[","]","self",".","execute","(","stdout",",","kwargs",")","return","''",".","join","(","stdout",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/bottle.py#L3083-L3088"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"anthracite-web.py","language":"python","identifier":"call_func","parameters":"(fn_name, *args, **kwargs)","argument_list":"","return_statement":"","docstring":"since plugin's functions are not in the global scope, you can\n    use this wrapper to call a function, whether it's in global\n    scope or in one of the plugins","docstring_summary":"since plugin's functions are not in the global scope, you can\n    use this wrapper to call a function, whether it's in global\n    scope or in one of the plugins","docstring_tokens":["since","plugin","s","functions","are","not","in","the","global","scope","you","can","use","this","wrapper","to","call","a","function","whether","it","s","in","global","scope","or","in","one","of","the","plugins"],"function":"def call_func(fn_name, *args, **kwargs):\n    '''\n    since plugin's functions are not in the global scope, you can\n    use this wrapper to call a function, whether it's in global\n    scope or in one of the plugins\n    '''\n    if fn_name in globals():\n        return globals()[fn_name](*args, **kwargs)\n    else:\n        for loaded_plugin in state['loaded_plugins']:\n            for attrib_key in dir(loaded_plugin):\n                attrib = loaded_plugin.__dict__.get(attrib_key)\n                if isinstance(attrib, types.FunctionType):\n                    if attrib.__name__ == fn_name:\n                        return attrib(*args, **kwargs)","function_tokens":["def","call_func","(","fn_name",",","*","args",",","*","*","kwargs",")",":","if","fn_name","in","globals","(",")",":","return","globals","(",")","[","fn_name","]","(","*","args",",","*","*","kwargs",")","else",":","for","loaded_plugin","in","state","[","'loaded_plugins'","]",":","for","attrib_key","in","dir","(","loaded_plugin",")",":","attrib","=","loaded_plugin",".","__dict__",".","get","(","attrib_key",")","if","isinstance","(","attrib",",","types",".","FunctionType",")",":","if","attrib",".","__name__","==","fn_name",":","return","attrib","(","*","args",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/anthracite-web.py#L18-L32"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"anthracite-web.py","language":"python","identifier":"track_history","parameters":"()","argument_list":"","return_statement":"","docstring":"maintain a list of the 10 most recent pages loaded per earch particular user","docstring_summary":"maintain a list of the 10 most recent pages loaded per earch particular user","docstring_tokens":["maintain","a","list","of","the","10","most","recent","pages","loaded","per","earch","particular","user"],"function":"def track_history():\n    '''\n    maintain a list of the 10 most recent pages loaded per earch particular user\n    '''\n    global session\n    # ignore everything that's not a page being loaded by the user:\n    if request.fullpath.startswith('\/assets'):\n        return\n    # loaded in background by report page\n    if request.fullpath.startswith('\/report\/data'):\n        return\n    session = request.environ.get('beaker.session')\n    session['history'] = session.get('history', deque())\n    # loaded in background by timeline\n    if len(session['history']) and request.fullpath == '\/events\/xml' and session['history'][len(session['history']) - 1] == '\/events\/timeline':\n        return\n    # note the url always misses the '#foo' part\n    url = request.fullpath\n    if request.query_string:\n        url += \"?%s\" % request.query_string\n    if len(session['history']) and url == session['history'][len(session['history']) - 1]:\n        return\n    session['history'].append(url)\n    if len(session['history']) > 10:\n        session['history'].popleft()\n    session.save()","function_tokens":["def","track_history","(",")",":","global","session","# ignore everything that's not a page being loaded by the user:","if","request",".","fullpath",".","startswith","(","'\/assets'",")",":","return","# loaded in background by report page","if","request",".","fullpath",".","startswith","(","'\/report\/data'",")",":","return","session","=","request",".","environ",".","get","(","'beaker.session'",")","session","[","'history'","]","=","session",".","get","(","'history'",",","deque","(",")",")","# loaded in background by timeline","if","len","(","session","[","'history'","]",")","and","request",".","fullpath","==","'\/events\/xml'","and","session","[","'history'","]","[","len","(","session","[","'history'","]",")","-","1","]","==","'\/events\/timeline'",":","return","# note the url always misses the '#foo' part","url","=","request",".","fullpath","if","request",".","query_string",":","url","+=","\"?%s\"","%","request",".","query_string","if","len","(","session","[","'history'","]",")","and","url","==","session","[","'history'","]","[","len","(","session","[","'history'","]",")","-","1","]",":","return","session","[","'history'","]",".","append","(","url",")","if","len","(","session","[","'history'","]",")",">","10",":","session","[","'history'","]",".","popleft","(",")","session",".","save","(",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/anthracite-web.py#L36-L61"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"anthracite-web.py","language":"python","identifier":"events_json","parameters":"()","argument_list":"","return_statement":"return {\"events\": backend.get_events_raw()}","docstring":"much like http:\/\/localhost:9200\/anthracite\/event\/_search?q=*:*&pretty=true\n    but: displays only the actual events, not index etc, they are sorted, and uses unix timestamps","docstring_summary":"much like http:\/\/localhost:9200\/anthracite\/event\/_search?q=*:*&pretty=true\n    but: displays only the actual events, not index etc, they are sorted, and uses unix timestamps","docstring_tokens":["much","like","http",":","\/\/","localhost",":","9200","\/","anthracite","\/","event","\/","_search?q","=","*",":","*","&pretty","=","true","but",":","displays","only","the","actual","events","not","index","etc","they","are","sorted","and","uses","unix","timestamps"],"function":"def events_json():\n    '''\n    much like http:\/\/localhost:9200\/anthracite\/event\/_search?q=*:*&pretty=true\n    but: displays only the actual events, not index etc, they are sorted, and uses unix timestamps\n    '''\n    response.set_header(\"Access-Control-Allow-Origin\", \"*\")\n    response.set_header(\"Access-Control-Allow-Credentials\", \"true\")\n    response.set_header(\"Access-Control-Allow-Methods\", \"OPTIONS, GET, POST\")\n    response.set_header(\"Access-Control-Allow-Headers\", \"Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control\")\n    return {\"events\": backend.get_events_raw()}","function_tokens":["def","events_json","(",")",":","response",".","set_header","(","\"Access-Control-Allow-Origin\"",",","\"*\"",")","response",".","set_header","(","\"Access-Control-Allow-Credentials\"",",","\"true\"",")","response",".","set_header","(","\"Access-Control-Allow-Methods\"",",","\"OPTIONS, GET, POST\"",")","response",".","set_header","(","\"Access-Control-Allow-Headers\"",",","\"Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control\"",")","return","{","\"events\"",":","backend",".","get_events_raw","(",")","}"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/anthracite-web.py#L129-L138"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"anthracite-web.py","language":"python","identifier":"events_csv","parameters":"()","argument_list":"","return_statement":"return \"\\n\".join(events)","docstring":"returns the first line of every event","docstring_summary":"returns the first line of every event","docstring_tokens":["returns","the","first","line","of","every","event"],"function":"def events_csv():\n    '''\n    returns the first line of every event\n    '''\n    response.content_type = 'text\/plain'\n    events = []\n    for event in backend.get_events_raw():\n        desc = event['desc'].replace(\"\\n\", '  ').replace(\"\\r\", ' ').strip()\n        formatted = [event['id'], str(event['date']), desc, ' '.join(event['tags'])]\n        events.append(','.join(formatted))\n    return \"\\n\".join(events)","function_tokens":["def","events_csv","(",")",":","response",".","content_type","=","'text\/plain'","events","=","[","]","for","event","in","backend",".","get_events_raw","(",")",":","desc","=","event","[","'desc'","]",".","replace","(","\"\\n\"",",","'  '",")",".","replace","(","\"\\r\"",",","' '",")",".","strip","(",")","formatted","=","[","event","[","'id'","]",",","str","(","event","[","'date'","]",")",",","desc",",","' '",".","join","(","event","[","'tags'","]",")","]","events",".","append","(","','",".","join","(","formatted",")",")","return","\"\\n\"",".","join","(","events",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/anthracite-web.py#L142-L152"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"anthracite-web.py","language":"python","identifier":"local_datepick_to_unix_timestamp","parameters":"(datepick)","argument_list":"","return_statement":"return int(time.mktime(datetime.datetime.strptime(datepick, \"%m\/%d\/%Y %I:%M:%S %p\").timetuple()))","docstring":"in: something like 12\/31\/2012 10:25:35 PM, which is local time.\n    out: unix timestamp","docstring_summary":"in: something like 12\/31\/2012 10:25:35 PM, which is local time.\n    out: unix timestamp","docstring_tokens":["in",":","something","like","12","\/","31","\/","2012","10",":","25",":","35","PM","which","is","local","time",".","out",":","unix","timestamp"],"function":"def local_datepick_to_unix_timestamp(datepick):\n    '''\n    in: something like 12\/31\/2012 10:25:35 PM, which is local time.\n    out: unix timestamp\n    '''\n    import time\n    import datetime\n    return int(time.mktime(datetime.datetime.strptime(datepick, \"%m\/%d\/%Y %I:%M:%S %p\").timetuple()))","function_tokens":["def","local_datepick_to_unix_timestamp","(","datepick",")",":","import","time","import","datetime","return","int","(","time",".","mktime","(","datetime",".","datetime",".","strptime","(","datepick",",","\"%m\/%d\/%Y %I:%M:%S %p\"",")",".","timetuple","(",")",")",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/anthracite-web.py#L187-L194"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"backend.py","language":"python","identifier":"load_plugins","parameters":"(plugins_to_load, config)","argument_list":"","return_statement":"return (state, errors)","docstring":"loads all the plugins sub-modules\n    returns encountered errors, doesn't raise them because\n    whoever calls this function defines how any errors are\n    handled. meanwhile, loading must continue","docstring_summary":"loads all the plugins sub-modules\n    returns encountered errors, doesn't raise them because\n    whoever calls this function defines how any errors are\n    handled. meanwhile, loading must continue","docstring_tokens":["loads","all","the","plugins","sub","-","modules","returns","encountered","errors","doesn","t","raise","them","because","whoever","calls","this","function","defines","how","any","errors","are","handled",".","meanwhile","loading","must","continue"],"function":"def load_plugins(plugins_to_load, config):\n    '''\n    loads all the plugins sub-modules\n    returns encountered errors, doesn't raise them because\n    whoever calls this function defines how any errors are\n    handled. meanwhile, loading must continue\n    '''\n    import plugins\n    errors = []\n    add_urls = {}\n    remove_urls = []\n    loaded_plugins = []\n    plugins_dir = os.path.dirname(plugins.__file__)\n    wd = os.getcwd()\n    os.chdir(plugins_dir)\n    for module in plugins_to_load:\n        try:\n            print \"importing plugin '%s'\" % module\n            imp = __import__('plugins.' + module, {}, {}, ['*'])\n            loaded_plugins.append(imp)\n            try:\n                add_urls[module] = imp.add_urls\n            except Exception:\n                pass\n            try:\n                remove_urls.extend(imp.remove_urls)\n            except Exception:\n                pass\n        except Exception, e:\n            errors.append(PluginError(module, \"Failed to add plugin '%s'\" % module, e))\n            continue\n\n    os.chdir(wd)\n    state = {\n        'add_urls': add_urls,\n        'remove_urls': remove_urls,\n        'loaded_plugins': loaded_plugins\n    }\n    #  make some vars accessible for all imported plugins\n    __builtins__['state'] = state\n    __builtins__['config'] = config\n    return (state, errors)","function_tokens":["def","load_plugins","(","plugins_to_load",",","config",")",":","import","plugins","errors","=","[","]","add_urls","=","{","}","remove_urls","=","[","]","loaded_plugins","=","[","]","plugins_dir","=","os",".","path",".","dirname","(","plugins",".","__file__",")","wd","=","os",".","getcwd","(",")","os",".","chdir","(","plugins_dir",")","for","module","in","plugins_to_load",":","try",":","print","\"importing plugin '%s'\"","%","module","imp","=","__import__","(","'plugins.'","+","module",",","{","}",",","{","}",",","[","'*'","]",")","loaded_plugins",".","append","(","imp",")","try",":","add_urls","[","module","]","=","imp",".","add_urls","except","Exception",":","pass","try",":","remove_urls",".","extend","(","imp",".","remove_urls",")","except","Exception",":","pass","except","Exception",",","e",":","errors",".","append","(","PluginError","(","module",",","\"Failed to add plugin '%s'\"","%","module",",","e",")",")","continue","os",".","chdir","(","wd",")","state","=","{","'add_urls'",":","add_urls",",","'remove_urls'",":","remove_urls",",","'loaded_plugins'",":","loaded_plugins","}","#  make some vars accessible for all imported plugins","__builtins__","[","'state'","]","=","state","__builtins__","[","'config'","]","=","config","return","(","state",",","errors",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/backend.py#L342-L383"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"backend.py","language":"python","identifier":"Backend.iso8601_to_unix_timestamp","parameters":"(self, iso8601)","argument_list":"","return_statement":"return unix","docstring":"elasticsearch returns something like 2013-03-20T20:41:16","docstring_summary":"elasticsearch returns something like 2013-03-20T20:41:16","docstring_tokens":["elasticsearch","returns","something","like","2013","-","03","-","20T20",":","41",":","16"],"function":"def iso8601_to_unix_timestamp(self, iso8601):\n        '''\n            elasticsearch returns something like 2013-03-20T20:41:16\n\n        '''\n        unix = calendar.timegm(datetime.datetime.strptime(iso8601, \"%Y-%m-%dT%H:%M:%S\").timetuple())\n        return unix","function_tokens":["def","iso8601_to_unix_timestamp","(","self",",","iso8601",")",":","unix","=","calendar",".","timegm","(","datetime",".","datetime",".","strptime","(","iso8601",",","\"%Y-%m-%dT%H:%M:%S\"",")",".","timetuple","(",")",")","return","unix"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/backend.py#L167-L173"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"backend.py","language":"python","identifier":"Backend.get_events_raw","parameters":"(self, query=None)","argument_list":"","return_statement":"return events","docstring":"return format that's optimized for elasticsearch","docstring_summary":"return format that's optimized for elasticsearch","docstring_tokens":["return","format","that","s","optimized","for","elasticsearch"],"function":"def get_events_raw(self, query=None):\n        '''\n        return format that's optimized for elasticsearch\n        '''\n        hits = self.es_get_events(query)\n        events = hits['hits']['hits']\n        for (i, event) in enumerate(events):\n            event_id = event['_id']\n            events[i] = event['_source']\n            events[i]['id'] = event_id\n            events[i]['date'] = self.iso8601_to_unix_timestamp(events[i]['date'])\n        return events","function_tokens":["def","get_events_raw","(","self",",","query","=","None",")",":","hits","=","self",".","es_get_events","(","query",")","events","=","hits","[","'hits'","]","[","'hits'","]","for","(","i",",","event",")","in","enumerate","(","events",")",":","event_id","=","event","[","'_id'","]","events","[","i","]","=","event","[","'_source'","]","events","[","i","]","[","'id'","]","=","event_id","events","[","i","]","[","'date'","]","=","self",".","iso8601_to_unix_timestamp","(","events","[","i","]","[","'date'","]",")","return","events"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/backend.py#L220-L231"}
{"nwo":"Dieterbe\/anthracite","sha":"10d5b54e21a79aa0abc66d638828f0f251beacb5","path":"plugins\/vimeo_analytics.py","language":"python","identifier":"events_csv_vimeo_analytics","parameters":"()","argument_list":"","return_statement":"return \"\\n\".join(line_yielder(events_vimeo_analytics()))","docstring":"desc is the entire desc, with '\\n' replaced with '  '. this output doesn't attempt to shorten the desc string.","docstring_summary":"desc is the entire desc, with '\\n' replaced with '  '. this output doesn't attempt to shorten the desc string.","docstring_tokens":["desc","is","the","entire","desc","with","\\","n","replaced","with",".","this","output","doesn","t","attempt","to","shorten","the","desc","string","."],"function":"def events_csv_vimeo_analytics():\n    '''\n    desc is the entire desc, with '\\n' replaced with '  '. this output doesn't attempt to shorten the desc string.\n    '''\n    response.content_type = 'text\/plain'\n\n    def line_yielder(events):\n        for event in events:\n            yield ','.join([str(field).replace(',', '') for field in event])\n\n    return \"\\n\".join(line_yielder(events_vimeo_analytics()))","function_tokens":["def","events_csv_vimeo_analytics","(",")",":","response",".","content_type","=","'text\/plain'","def","line_yielder","(","events",")",":","for","event","in","events",":","yield","','",".","join","(","[","str","(","field",")",".","replace","(","','",",","''",")","for","field","in","event","]",")","return","\"\\n\"",".","join","(","line_yielder","(","events_vimeo_analytics","(",")",")",")"],"url":"https:\/\/github.com\/Dieterbe\/anthracite\/blob\/10d5b54e21a79aa0abc66d638828f0f251beacb5\/plugins\/vimeo_analytics.py#L39-L49"}