mathviz_hopper.src package¶
Submodules¶
mathviz_hopper.src.Scatter module¶
Author: Sam Helms Date: Nov 1
This class creates an scatter plot for visualizing embeddings (probably using TSNE)
mathviz_hopper.src.bottle module¶
Bottle is a fast and simple micro-framework for small web applications. It offers request dispatching (Routes) with URL parameter support, templates, a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines - all in a single file and with no dependencies other than the Python Standard Library.
Homepage and documentation: http://bottlepy.org/
Copyright (c) 2017, Marcel Hellkamp. License: MIT (see LICENSE for details)
- 
class mathviz_hopper.src.bottle.AiohttpServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.AsyncioServerAdapter- Untested. aiohttp https://pypi.python.org/pypi/aiohttp/ 
- 
class mathviz_hopper.src.bottle.AiohttpUVLoopServer(host='127.0.0.1', port=8080, **options)[source]¶
- 
class mathviz_hopper.src.bottle.AppEngineServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Adapter for Google App Engine. - 
quiet= True¶
 
- 
- 
class mathviz_hopper.src.bottle.AppStack[source]¶
- Bases: - list- A stack-like list. Calling it returns the head of the stack. - 
default¶
 
- 
- 
class mathviz_hopper.src.bottle.AsyncioServerAdapter(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Extend ServerAdapter for adding custom event loop 
- 
class mathviz_hopper.src.bottle.AutoServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Untested. - 
adapters= [<class 'mathviz_hopper.src.bottle.WaitressServer'>, <class 'mathviz_hopper.src.bottle.PasteServer'>, <class 'mathviz_hopper.src.bottle.TwistedServer'>, <class 'mathviz_hopper.src.bottle.CherryPyServer'>, <class 'mathviz_hopper.src.bottle.CherootServer'>, <class 'mathviz_hopper.src.bottle.WSGIRefServer'>]¶
 
- 
- 
class mathviz_hopper.src.bottle.BaseRequest(environ=None)[source]¶
- Bases: - object- A wrapper for WSGI environment dictionaries that adds a lot of convenient access methods and properties. Most of them are read-only. - Adding new attributes to a request actually adds them to the environ dictionary (as ‘bottle.request.ext.<name>’). This is the recommended way to store and access request-specific data. - 
POST[source]¶
- The values of - formsand- filescombined into a single- FormsDict. Values are either strings (form values) or instances of- cgi.FieldStorage(file uploads).
 - 
auth¶
- 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_USERenviron variable. On any errors, None is returned.
 - 
body¶
- The HTTP request body as a seek-able file-like object. Depending on - MEMFILE_MAX, this is either a temporary file or a- io.BytesIOinstance. Accessing this property for the first time reads and replaces the- wsgi.inputenviron variable. Subsequent accesses just do a seek(0) on the file object.
 - 
chunked¶
- True if Chunked transfer encoding was. 
 - 
content_length¶
- 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, - bodywill be empty.
 - 
content_type¶
- The Content-Type header as a lowercase-string (default: empty). 
 - Cookies parsed into a - FormsDict. Signed cookies are NOT decoded. Use- get_cookie()if you expect signed cookies.
 - 
environ¶
- The wrapped WSGI environ dictionary. This is the only real attribute. All other attributes actually are read-only properties. 
 - 
files[source]¶
- File uploads parsed from multipart/form-data encoded POST or PUT request body. The values are instances of - FileUpload.
 - 
forms[source]¶
- Form values parsed from an url-encoded or multipart/form-data encoded POST or PUT request body. The result is returned as a - FormsDict. All keys and values are strings. File uploads are stored separately in- files.
 - 
fullpath¶
- Request path including - script_name(if present).
 - Return the content of a cookie. To read a Signed Cookie, the secret must match the one used to create the cookie (see - BaseResponse.set_cookie()). If anything goes wrong (missing cookie or wrong signature), return a default value.
 - 
get_header(name, default=None)[source]¶
- Return the value of a request header, or a given default value. 
 - 
headers[source]¶
- A - WSGIHeaderDictthat provides case-insensitive access to HTTP request headers.
 - 
is_xhr¶
- 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). 
 - 
json[source]¶
- If the - Content-Typeheader is- application/jsonor- application/json-rpc, this property holds the parsed content of the request body. Only requests smaller than- MEMFILE_MAXare processed to avoid memory exhaustion. Invalid JSON raises a 400 error response.
 - 
method¶
- The - REQUEST_METHODvalue as an uppercase string.
 - 
params[source]¶
- A - FormsDictwith the combined values of- queryand- forms. File uploads are stored in- files.
 - 
path¶
- The value of - PATH_INFOwith exactly one prefixed slash (to fix broken clients and avoid the “empty path” edge case).
 - 
path_shift(shift=1)[source]¶
- Shift path segments from pathtoscript_nameand
- vice versa.
 - Parameters: - shift – The number of path segments to shift. May be negative to change the shift direction. (default: 1) 
- Shift path segments from 
 - 
query[source]¶
- The - query_stringparsed into a- 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- Router.
 - 
remote_addr¶
- The client IP as a string. Note that this information can be forged by malicious clients. 
 - 
remote_route¶
- 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-Forheader. Note that this information can be forged by malicious clients.
 - 
script_name¶
- 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. 
 - 
url¶
- 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-Hostheader is set correctly.
 
- 
- 
class mathviz_hopper.src.bottle.BaseResponse(body='', status=None, headers=None, **more_headers)[source]¶
- Bases: - object- Storage class for a response body as well as headers and cookies. - This class does support dict-like case-insensitive item-access to headers, but is NOT a dict. Most notably, iterating over a response yields parts of the body and not the headers. - Parameters: - body – The response body as one of the supported types.
- status – Either an HTTP status code (e.g. 200) or a status line including the reason phrase (e.g. ‘200 OK’).
- headers – A dictionary or a list of name-value pairs.
 - Additional keyword arguments are added to the list of headers. Underscores in the header name are replaced with dashes. - 
bad_headers= {304: frozenset(['Content-Length', 'Content-Language', 'Content-Encoding', 'Content-Md5', 'Last-Modified', 'Content-Range', 'Allow', 'Content-Type']), 204: frozenset(['Content-Length', 'Content-Type'])}¶
 - 
charset¶
- Return the charset specified in the content-type header (default: utf8). 
 - 
content_length¶
- Current value of the ‘Content-Length’ header. 
 - 
content_type¶
- Current value of the ‘Content-Type’ header. 
 - 
default_content_type= 'text/html; charset=UTF-8'¶
 - 
default_status= 200¶
 - Delete a cookie. Be sure to use the same domain and path settings as used to create the cookie. 
 - 
expires¶
- Current value of the ‘Expires’ header. 
 - 
get_header(name, default=None)[source]¶
- Return the value of a previously defined header. If there is no header with that name, return a default value. 
 - 
headerlist¶
- WSGI conform list of (header, value) tuples. 
 - 
headers¶
- An instance of - HeaderDict, a case-insensitive dict-like view on the response headers.
 - 
iter_headers()[source]¶
- Yield (header, value) tuples, skipping headers that are not allowed with the current response status code. 
 - Create a new cookie or replace an old one. If the secret parameter is set, create a Signed Cookie (described below). - Parameters: - name – the name of the cookie.
- value – the value of the cookie.
- secret – a signature key required for signed cookies.
 - Additionally, this method accepts all RFC 2109 attributes that are supported by - cookie.Morsel, including:- Parameters: - max_age – maximum age in seconds. (default: None)
- expires – a datetime object or UNIX timestamp. (default: None)
- domain – the domain that is allowed to read the cookie. (default: current domain)
- path – limits the cookie to a given path (default: current path)
- secure – limit the cookie to HTTPS connections (default: off).
- httponly – prevents client-side javascript to read this cookie (default: off, requires Python 2.6 or newer).
- same_site – disables third-party use for a cookie. Allowed attributes: lax and strict. In strict mode the cookie will never be sent. In lax mode the cookie is only sent with a top-level GET request.
 - If neither expires nor max_age is set (default), the cookie will expire at the end of the browser session (as soon as the browser window is closed). - Signed cookies may store any pickle-able object and are cryptographically signed to prevent manipulation. Keep in mind that cookies are limited to 4kb in most browsers. - Warning: Pickle is a potentially dangerous format. If an attacker gains access to the secret key, he could forge cookies that execute code on server side if unpickeld. Using pickle is discouraged and support for it will be removed in later versions of bottle. - Warning: Signed cookies are not encrypted (the client can still see the content) and not copy-protected (the client can restore an old cookie). The main intention is to make pickling and unpickling save, not to store secret information at client side. 
 - 
set_header(name, value)[source]¶
- Create a new response header, replacing any previously defined headers with the same name. 
 - 
status¶
- A writeable property to change the HTTP response status. It accepts either a numeric code (100-999) or a string with a custom reason phrase (e.g. “404 Brain not found”). Both - status_lineand- status_codeare updated accordingly. The return value is always a status string.
 - 
status_code¶
- The HTTP status code as an integer (e.g. 404). 
 - 
status_line¶
- The HTTP status line as a string (e.g. - 404 Not Found).
 
- 
class mathviz_hopper.src.bottle.BaseTemplate(source=None, name=None, lookup=None, encoding='utf8', **settings)[source]¶
- Bases: - object- Base class and minimal API for template adapters - 
defaults= {}¶
 - 
extensions= ['tpl', 'html', 'thtml', 'stpl']¶
 - 
classmethod global_config(key, *args)[source]¶
- This reads or sets the global settings stored in class.settings. 
 - 
prepare(**options)[source]¶
- Run preparations (parsing, caching, …). It should be possible to call this again to refresh a template or to update settings. 
 - 
render(*args, **kwargs)[source]¶
- 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). 
 - 
classmethod search(name, lookup=None)[source]¶
- Search name in all directories specified in lookup. First without, then with common extensions. Return first hit. 
 - 
settings= {}¶
 
- 
- 
class mathviz_hopper.src.bottle.BjoernServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Fast server written in C: https://github.com/jonashaag/bjoern 
- 
class mathviz_hopper.src.bottle.Bottle(**kwargs)[source]¶
- Bases: - object- Each Bottle object represents a single, distinct web application and consists of routes, callbacks, plugins, resources and configuration. Instances are callable WSGI applications. - Parameters: - catchall – If true (default), handle all exceptions. Turn off to let debugging middleware handle exceptions. - 
add_hook(name, func)[source]¶
- Attach a callback to a hook. Three hooks are currently implemented: - before_request
- Executed once before each request. The request context is available, but no routing has happened yet.
- after_request
- Executed once after each request regardless of its outcome.
- app_reset
- Called whenever Bottle.reset()is called.
 
 - 
config= None¶
- A - ConfigDictfor app specific configuration.
 - 
delete(path=None, method='DELETE', **options)[source]¶
- Equals - route()with a- DELETEmethod parameter.
 - 
error(code=500, callback=None)[source]¶
- Register an output handler for a HTTP error code. Can be used as a decorator or called directly - def error_handler_500(error): return 'error_handler_500' app.error(code=500, callback=error_handler_500) @app.error(404) def error_handler_404(error): return 'error_handler_404' 
 - 
hook(name)[source]¶
- Return a decorator that attaches a callback to a hook. See - add_hook()for details.
 - 
install(plugin)[source]¶
- 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 - PluginAPI.
 - 
match(environ)[source]¶
- Search for a matching route and return a ( - Route, urlargs) tuple. The second value is a dictionary with parameters extracted from the URL. Raise- HTTPError(404/405) on a non-match.
 - 
merge(routes)[source]¶
- Merge the routes of another - Bottleapplication or a list of- Routeobjects into this application. The routes keep their ‘owner’, meaning that the- Route.appattribute is not changed.
 - 
mount(prefix, app, **options)[source]¶
- Mount an application ( - Bottleor plain WSGI) to a specific URL prefix. Example:- parent_app.mount('/prefix/', child_app) - Parameters: - prefix – path prefix or mount-point.
- app – an instance of Bottleor a WSGI application.
 - Plugins from the parent application are not applied to the routes of the mounted child application. If you need plugins in the child application, install them separately. - While it is possible to use path wildcards within the prefix path ( - Bottlechilds only), it is highly discouraged.- The prefix path must end with a slash. If you want to access the root of the child application via /prefix in addition to /prefix/, consider adding a route with a 307 redirect to the parent application. 
 - 
reset(route=None)[source]¶
- 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. 
 - 
resources= None¶
- A - ResourceManagerfor application files
 - 
route(path=None, method='GET', callback=None, name=None, apply=None, skip=None, **config)[source]¶
- A decorator to bind a function to a request URL. Example: - @app.route('/hello/<name>') def hello(name): return 'Hello %s' % name - The - <name>part is a wildcard. See- Routerfor syntax details.- Parameters: - path – Request path or a list of paths to listen to. If no path is specified, it is automatically generated from the signature of the function.
- method – HTTP method (GET, POST, PUT, …) or a list of methods to listen to. (default: GET)
- callback – An optional shortcut to avoid the decorator
syntax. route(..., callback=func)equalsroute(...)(func)
- name – The name for this route. (default: None)
- apply – A decorator or plugin or a list of plugins. These are applied to the route callback in addition to installed plugins.
- skip – A list of plugins, plugin classes or names. Matching
plugins are not installed to this route. Trueskips all.
 - Any additional keyword arguments are stored as route-specific configuration and passed to plugins (see - Plugin.apply()).
 
- 
- 
exception mathviz_hopper.src.bottle.BottleException[source]¶
- Bases: - exceptions.Exception- A base class for exceptions used by bottle. 
- 
class mathviz_hopper.src.bottle.CGIServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- 
quiet= True¶
 
- 
- 
class mathviz_hopper.src.bottle.CheetahTemplate(source=None, name=None, lookup=None, encoding='utf8', **settings)[source]¶
- 
class mathviz_hopper.src.bottle.ConfigDict[source]¶
- Bases: - dict- A dict-like configuration storage with additional support for namespaces, validators, meta-data, overlays and more. - This dict-like class is heavily optimized for read access. All read-only methods as well as item access should be as fast as the built-in dict. - 
load_config(filename, **options)[source]¶
- Load values from an - *.inistyle config file.- A configuration file consists of sections, each led by a - [section]header, followed by key/value entries separated by either- =or- :. Section names and keys are case-insensitive. Leading and trailing whitespace is removed from keys and values. Values can be omitted, in which case the key/value delimiter may also be left out. Values can also span multiple lines, as long as they are indented deeper than the first line of the value. Commands are prefixed by- #or- ;and may only appear on their own on an otherwise empty line.- Both section and key names may contain dots ( - .) as namespace separators. The actual configuration parameter name is constructed by joining section name and key name together and converting to lower case.- The special sections - bottleand- ROOTrefer to the root namespace and the- DEFAULTsection defines default values for all other sections.- With Python 3, extended string interpolation is enabled. - Parameters: - filename – The path of a config file, or a list of paths.
- options – All keyword parameters are passed to the underlying
python:configparser.ConfigParserconstructor call.
 
 - 
load_dict(source, namespace='')[source]¶
- Load values from a dictionary structure. Nesting can be used to represent namespaces. - >>> c = ConfigDict() >>> c.load_dict({'some': {'namespace': {'key': 'value'} } }) {'some.namespace.key': 'value'} 
 - 
load_module(path, squash=True)[source]¶
- Load values from a Python module. - Example modue - config.py:- DEBUG = True SQLITE = { "db": ":memory:" } - >>> c = ConfigDict() >>> c.load_module('config') {DEBUG: True, 'SQLITE.DB': 'memory'} >>> c.load_module("config", False) {'DEBUG': True, 'SQLITE': {'DB': 'memory'}} - Parameters: - squash – If true (default), dictionary values are assumed to represent namespaces (see - load_dict()).
 
- 
- 
class mathviz_hopper.src.bottle.DictProperty(attr, key=None, read_only=False)[source]¶
- Bases: - object- Property that maps to a key in a local dict-like attribute. 
- 
class mathviz_hopper.src.bottle.DieselServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Untested. 
- 
mathviz_hopper.src.bottle.ERROR_PAGE_TEMPLATE= '\n%try:\n %from mathviz_hopper.src.bottle import DEBUG, request\n <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n <html>\n <head>\n <title>Error: {{e.status}}</title>\n <style type="text/css">\n html {background-color: #eee; font-family: sans-serif;}\n body {background-color: #fff; border: 1px solid #ddd;\n padding: 15px; margin: 15px;}\n pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}\n </style>\n </head>\n <body>\n <h1>Error: {{e.status}}</h1>\n <p>Sorry, the requested URL <tt>{{repr(request.url)}}</tt>\n caused an error:</p>\n <pre>{{e.body}}</pre>\n %if DEBUG and e.exception:\n <h2>Exception:</h2>\n %try:\n %exc = repr(e.exception)\n %except:\n %exc = \'<unprintable %s object>\' % type(e.exception).__name__\n %end\n <pre>{{exc}}</pre>\n %end\n %if DEBUG and e.traceback:\n <h2>Traceback:</h2>\n <pre>{{e.traceback}}</pre>\n %end\n </body>\n </html>\n%except ImportError:\n <b>ImportError:</b> Could not generate the error page. Please add bottle to\n the import path.\n%end\n'¶
- The default template used for error pages. Override with @error() 
- 
class mathviz_hopper.src.bottle.EventletServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Untested. Options: - backlog adjust the eventlet backlog parameter which is the maximum number of queued connections. Should be at least 1; the maximum value is system-dependent.
- family: (default is 2) socket family, optional. See socket documentation for available families.
 
- 
class mathviz_hopper.src.bottle.FapwsServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Extremely fast webserver using libev. See http://www.fapws.org/ 
- 
class mathviz_hopper.src.bottle.FileCheckerThread(lockfile, interval)[source]¶
- Bases: - threading.Thread- Interrupt main-thread as soon as a changed module file is detected, the lockfile gets deleted or gets too old. - 
status= None¶
- Is one of ‘reload’, ‘error’ or ‘exit’ 
 
- 
- 
class mathviz_hopper.src.bottle.FileUpload(fileobj, name, filename, headers=None)[source]¶
- Bases: - object- 
content_length¶
- Current value of the ‘Content-Length’ header. 
 - 
content_type¶
- Current value of the ‘Content-Type’ header. 
 - 
file= None¶
- Open file(-like) object (BytesIO buffer or temporary file) 
 - 
filename[source]¶
- Name of the file on the client file system, but normalized to ensure file system compatibility. An empty filename is returned as ‘empty’. - Only ASCII letters, digits, dashes, underscores and dots are allowed in the final filename. Accents are removed, if possible. Whitespace is replaced by a single dash. Leading or tailing dots or dashes are removed. The filename is limited to 255 characters. 
 - 
headers= None¶
- A - HeaderDictwith additional headers (e.g. content-type)
 - 
name= None¶
- Name of the upload form field 
 - 
raw_filename= None¶
- Raw filename as sent by the client (may contain unsafe characters) 
 - 
save(destination, overwrite=False, chunk_size=65536)[source]¶
- Save file to disk or copy its content to an open file(-like) object. If destination is a directory, - filenameis added to the path. Existing files are not overwritten by default (IOError).- Parameters: - destination – File path, directory or file(-like) object.
- overwrite – If True, replace existing files. (default: False)
- chunk_size – Bytes to read at a time. (default: 64kb)
 
 
- 
- 
class mathviz_hopper.src.bottle.FormsDict(*a, **k)[source]¶
- Bases: - mathviz_hopper.src.bottle.MultiDict- This - MultiDictsubclass is used to store request form data. Additionally to the normal dict-like item access methods (which return unmodified data as native strings), this container also supports attribute-like access to its values. Attributes are automatically de- or recoded to match- input_encoding(default: ‘utf8’). Missing attributes default to an empty string.- 
decode(encoding=None)[source]¶
- Returns a copy with all keys and values de- or recoded to match - input_encoding. Some libraries (e.g. WTForms) want a unicode dictionary.
 - 
getunicode(name, default=None, encoding=None)[source]¶
- Return the value as a unicode string, or the default. 
 - 
input_encoding= 'utf8'¶
- Encoding used for attribute values. 
 - 
recode_unicode= True¶
- If true (default), unicode strings are first encoded with latin1 and then decoded to match - input_encoding.
 
- 
- 
class mathviz_hopper.src.bottle.GeventServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Untested. Options: - See gevent.wsgi.WSGIServer() documentation for more options.
 
- 
class mathviz_hopper.src.bottle.GunicornServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Untested. See http://gunicorn.org/configure.html for options. 
- 
exception mathviz_hopper.src.bottle.HTTPError(status=None, body=None, exception=None, traceback=None, **more_headers)[source]¶
- Bases: - mathviz_hopper.src.bottle.HTTPResponse- 
default_status= 500¶
 
- 
- 
exception mathviz_hopper.src.bottle.HTTPResponse(body='', status=None, headers=None, **more_headers)[source]¶
- Bases: - mathviz_hopper.src.bottle.BaseResponse,- mathviz_hopper.src.bottle.BottleException
- 
mathviz_hopper.src.bottle.HTTP_CODES= {428: 'Precondition Required', 429: 'Too Many Requests', 400: 'Bad Request', 401: 'Unauthorized', 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', 405: 'Method Not Allowed', 406: 'Not Acceptable', 407: 'Proxy Authentication Required', 408: 'Request Timeout', 409: 'Conflict', 410: 'Gone', 411: 'Length Required', 412: 'Precondition Failed', 413: 'Request Entity Too Large', 414: 'Request-URI Too Long', 415: 'Unsupported Media Type', 416: 'Requested Range Not Satisfiable', 417: 'Expectation Failed', 418: "I'm a teapot", 300: 'Multiple Choices', 301: 'Moved Permanently', 302: 'Found', 303: 'See Other', 304: 'Not Modified', 305: 'Use Proxy', 306: '(Unused)', 307: 'Temporary Redirect', 451: 'Unavailable For Legal Reasons', 200: 'OK', 201: 'Created', 202: 'Accepted', 203: 'Non-Authoritative Information', 204: 'No Content', 205: 'Reset Content', 206: 'Partial Content', 100: 'Continue', 101: 'Switching Protocols', 431: 'Request Header Fields Too Large', 500: 'Internal Server Error', 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', 504: 'Gateway Timeout', 505: 'HTTP Version Not Supported', 511: 'Network Authentication Required'}¶
- A dict to map HTTP status codes (e.g. 404) to phrases (e.g. ‘Not Found’) 
- 
class mathviz_hopper.src.bottle.HeaderDict(*a, **ka)[source]¶
- Bases: - mathviz_hopper.src.bottle.MultiDict- A case-insensitive version of - MultiDictthat defaults to replace the old value instead of appending it.
- 
class mathviz_hopper.src.bottle.HeaderProperty(name, reader=None, writer=None, default='')[source]¶
- Bases: - object
- 
class mathviz_hopper.src.bottle.JSONPlugin(json_dumps=<function dumps>)[source]¶
- Bases: - object- 
api= 2¶
 - 
name= 'json'¶
 
- 
- 
class mathviz_hopper.src.bottle.Jinja2Template(source=None, name=None, lookup=None, encoding='utf8', **settings)[source]¶
- 
class mathviz_hopper.src.bottle.LocalRequest(environ=None)[source]¶
- Bases: - mathviz_hopper.src.bottle.BaseRequest- A thread-local subclass of - BaseRequestwith a different set of attributes for each thread. There is usually only one global instance of this class (- request). If accessed during a request/response cycle, this instance always refers to the current request (even on a multithreaded server).- 
bind(environ=None)¶
- Wrap a WSGI environ dictionary. 
 - 
environ¶
- Thread-local property 
 
- 
- 
class mathviz_hopper.src.bottle.LocalResponse(body='', status=None, headers=None, **more_headers)[source]¶
- Bases: - mathviz_hopper.src.bottle.BaseResponse- A thread-local subclass of - BaseResponsewith a different set of attributes for each thread. There is usually only one global instance of this class (- response). Its attributes are used to build the HTTP response at the end of the request/response cycle.- 
bind(body='', status=None, headers=None, **more_headers)¶
 - 
body¶
- Thread-local property 
 
- 
- 
class mathviz_hopper.src.bottle.MakoTemplate(source=None, name=None, lookup=None, encoding='utf8', **settings)[source]¶
- 
class mathviz_hopper.src.bottle.MultiDict(*a, **k)[source]¶
- Bases: - _abcoll.MutableMapping- This dict stores multiple values per key, but behaves exactly like a normal dict in that it returns only the newest value for any given key. There are special methods available to access the full list of values. - 
get(key, default=None, index=-1, type=None)[source]¶
- Return the most recent value for a key. - Parameters: - default – The default value to be returned if the key is not present or the type conversion fails.
- index – An index for the list of available values.
- type – If defined, this callable is used to cast the value into a specific type. Exception are suppressed and result in the default value to be returned.
 
 - 
getlist(key)¶
- Return a (possibly empty) list of values for a key. 
 - 
getone(key, default=None, index=-1, type=None)¶
- Aliases for WTForms to mimic other multi-dict APIs (Django) 
 
- 
- 
mathviz_hopper.src.bottle.Request¶
- alias of - BaseRequest
- 
class mathviz_hopper.src.bottle.ResourceManager(base='./', opener=<built-in function open>, cachemode='all')[source]¶
- Bases: - object- This class manages a list of search paths and helps to find and open application-bound resources (files). - Parameters: - base – default value for add_path()calls.
- opener – callable used to open resources.
- cachemode – controls which lookups are cached. One of ‘all’, ‘found’ or ‘none’.
 - 
add_path(path, base=None, index=None, create=False)[source]¶
- Add a new path to the list of search paths. Return False if the path does not exist. - Parameters: - path – The new search path. Relative paths are turned into an absolute and normalized form. If the path looks like a file (not ending in /), the filename is stripped off.
- base – Path used to absolutize relative search paths.
Defaults to basewhich defaults toos.getcwd().
- index – Position within the list of search paths. Defaults to last index (appends to the list).
 - The base parameter makes it easy to reference files installed along with a python module or package: - res.add_path('./resources/', __file__) 
 - 
cache= None¶
- A cache for resolved paths. - res.cache.clear()clears the cache.
 - 
lookup(name)[source]¶
- Search for a resource and return an absolute file path, or None. - The - pathlist is searched in order. The first match is returend. Symlinks are followed. The result is cached to speed up future lookups.
 - 
open(name, mode='r', *args, **kwargs)[source]¶
- Find a resource and return a file object, or raise IOError. 
 - 
path= None¶
- A list of search paths. See - add_path()for details.
 
- base – default value for 
- 
mathviz_hopper.src.bottle.Response¶
- alias of - BaseResponse
- 
class mathviz_hopper.src.bottle.RocketServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Untested. 
- 
class mathviz_hopper.src.bottle.Route(app, rule, method, callback, name=None, plugins=None, skiplist=None, **config)[source]¶
- Bases: - object- This class wraps a route callback along with route specific metadata and configuration and applies Plugins on demand. It is also responsible for turing an URL path rule into a regular expression usable by the Router. - 
app= None¶
- The application this route is installed to. 
 - 
call[source]¶
- The route callback with all plugins applied. This property is created on demand and then cached to speed up subsequent requests. 
 - 
callback= None¶
- The original callback with no plugins applied. Useful for introspection. 
 - 
config= None¶
- Additional keyword arguments passed to the - Bottle.route()decorator are stored in this dictionary. Used for route-specific plugin configuration and meta-data.
 - 
get_callback_args()[source]¶
- Return a list of argument names the callback (most likely) accepts as keyword arguments. If the callback is a decorated function, try to recover the original function before inspection. 
 - 
get_config(key, default=None)[source]¶
- Lookup a config field and return its value, first checking the route.config, then route.app.config. 
 - 
get_undecorated_callback()[source]¶
- Return the callback. If the callback is a decorated function, try to recover the original function. 
 - 
method= None¶
- The HTTP method as a string (e.g. - GET).
 - 
name= None¶
- The name of the route (if specified) or - None.
 - 
plugins= None¶
- A list of route-specific plugins (see - Bottle.route()).
 - 
reset()[source]¶
- Forget any cached values. The next time - callis accessed, all plugins are re-applied.
 - 
rule= None¶
- The path-rule string (e.g. - /wiki/<page>).
 - 
skiplist= None¶
- A list of plugins to not apply to this route (see - Bottle.route()).
 
- 
- 
exception mathviz_hopper.src.bottle.RouteBuildError[source]¶
- Bases: - mathviz_hopper.src.bottle.RouteError- The route could not be built. 
- 
exception mathviz_hopper.src.bottle.RouteError[source]¶
- Bases: - mathviz_hopper.src.bottle.BottleException- This is a base class for all routing related exceptions 
- 
exception mathviz_hopper.src.bottle.RouteReset[source]¶
- Bases: - mathviz_hopper.src.bottle.BottleException- If raised by a plugin or request handler, the route is reset and all plugins are re-applied. 
- 
exception mathviz_hopper.src.bottle.RouteSyntaxError[source]¶
- Bases: - mathviz_hopper.src.bottle.RouteError- The route parser found something not supported by this router. 
- 
class mathviz_hopper.src.bottle.Router(strict=False)[source]¶
- Bases: - object- A Router is an ordered collection of route->target pairs. It is used to efficiently match WSGI requests against a number of routes and return the first target that satisfies the request. The target may be anything, usually a string, ID or callable object. A route consists of a path-rule and a HTTP method. - The path-rule is either a static path (e.g. /contact) or a dynamic path that contains wildcards (e.g. /wiki/<page>). The wildcard syntax and details on the matching order are described in docs:routing. - 
add(rule, method, target, name=None)[source]¶
- Add a new rule or replace the target for an existing rule. 
 - 
add_filter(name, func)[source]¶
- 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. 
 - 
default_filter= 're'¶
 - 
default_pattern= '[^/]+'¶
 - 
rule_syntax= <_sre.SRE_Pattern object>¶
 - 
strict_order= None¶
- If true, static routes are no longer checked first. 
 
- 
- 
class mathviz_hopper.src.bottle.ServerAdapter(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - object- 
quiet= False¶
 
- 
- 
class mathviz_hopper.src.bottle.SimpleTemplate(source=None, name=None, lookup=None, encoding='utf8', **settings)[source]¶
- 
class mathviz_hopper.src.bottle.StplParser(source, syntax=None, encoding='utf8')[source]¶
- Bases: - object- Parser for stpl templates. - 
default_syntax= '<% %> % {{ }}'¶
 - 
syntax¶
- Tokens as a space separated string (default: <% %> % {{ }}) 
 
- 
- 
class mathviz_hopper.src.bottle.TemplatePlugin[source]¶
- Bases: - object- This plugin applies the - view()decorator to all routes with a template config parameter. If the parameter is a tuple, the second element must be a dict with additional options (e.g. template_engine) or default variables for the template.- 
api= 2¶
 - 
name= 'template'¶
 
- 
- 
class mathviz_hopper.src.bottle.TornadoServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- The super hyped asynchronous server by facebook. Untested. 
- 
class mathviz_hopper.src.bottle.TwistedServer(host='127.0.0.1', port=8080, **options)[source]¶
- Bases: - mathviz_hopper.src.bottle.ServerAdapter- Untested. 
- 
class mathviz_hopper.src.bottle.WSGIHeaderDict(environ)[source]¶
- Bases: - _abcoll.MutableMapping- This dict-like class wraps a WSGI environ dict and provides convenient access to HTTP_* fields. Keys and values are native strings (2.x bytes or 3.x unicode) and keys are case-insensitive. If the WSGI environment contains non-native string values, these are de- or encoded using a lossless ‘latin1’ character set. - The API will remain stable even on changes to the relevant PEPs. Currently PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-native strings.) - 
cgikeys= ('CONTENT_TYPE', 'CONTENT_LENGTH')¶
- List of keys that do not have a - HTTP_prefix.
 
- 
- 
mathviz_hopper.src.bottle.abort(code=500, text='Unknown Error.')[source]¶
- Aborts execution and causes a HTTP error. 
- 
mathviz_hopper.src.bottle.auth_basic(check, realm='private', text='Access denied')[source]¶
- Callback decorator to require HTTP auth (basic). TODO: Add route(check_auth=…) parameter. 
- 
class mathviz_hopper.src.bottle.cached_property(func)[source]¶
- Bases: - object- A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. 
- Verify and decode an encoded string. Return an object or None. 
- Encode and sign a pickle-able object. Return a (byte) string 
- Return True if the argument looks like a encoded cookie. 
- 
mathviz_hopper.src.bottle.debug(mode=True)[source]¶
- Change the debug level. There is only one debug level supported at the moment. 
- 
mathviz_hopper.src.bottle.error(*a, **ka)¶
- Register an output handler for a HTTP error code. Can be used as a decorator or called directly - def error_handler_500(error): return 'error_handler_500' app.error(code=500, callback=error_handler_500) @app.error(404) def error_handler_404(error): return 'error_handler_404' 
- 
mathviz_hopper.src.bottle.ext= <module 'mathviz_hopper.src.bottle.ext' from '/Users/sam/Documents/fall17/mathviz/mathviz_hopper/src/bottle.py'>¶
- A virtual package that redirects import statements. Example: - import bottle.ext.sqliteactually imports bottle_sqlite.
- 
mathviz_hopper.src.bottle.hook(*a, **ka)¶
- Return a decorator that attaches a callback to a hook. See - add_hook()for details.
- 
mathviz_hopper.src.bottle.html_escape(string)[source]¶
- Escape HTML special characters - &<>and quotes- '".
- 
mathviz_hopper.src.bottle.html_quote(string)[source]¶
- Escape and quote a string to be used as an HTTP attribute. 
- 
mathviz_hopper.src.bottle.install(*a, **ka)¶
- 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 - PluginAPI.
- 
class mathviz_hopper.src.bottle.lazy_attribute(func)[source]¶
- Bases: - object- A property that caches itself to the class object. 
- 
mathviz_hopper.src.bottle.load(target, **namespace)[source]¶
- Import a module or fetch an object from a module. - package.modulereturns module as a module object.
- pack.mod:namereturns the module variable name from pack.mod.
- pack.mod:func()calls pack.mod.func() and returns the result.
 - The last form accepts not only function calls, but any type of expression. Keyword arguments passed to this function are available as local variables. Example: - import_string('re:compile(x)', x='[a-z]')
- 
mathviz_hopper.src.bottle.load_app(target)[source]¶
- 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 - load()for the target parameter.
- 
mathviz_hopper.src.bottle.local= <thread._local object>¶
- A thread-safe namespace. Not used by Bottle. 
- 
mathviz_hopper.src.bottle.make_default_app_wrapper(name)[source]¶
- Return a callable that relays calls to the current default app. 
- 
mathviz_hopper.src.bottle.mount(*a, **ka)¶
- Mount an application ( - Bottleor plain WSGI) to a specific URL prefix. Example:- parent_app.mount('/prefix/', child_app) - Parameters: - prefix – path prefix or mount-point.
- app – an instance of Bottleor a WSGI application.
 - Plugins from the parent application are not applied to the routes of the mounted child application. If you need plugins in the child application, install them separately. - While it is possible to use path wildcards within the prefix path ( - Bottlechilds only), it is highly discouraged.- The prefix path must end with a slash. If you want to access the root of the child application via /prefix in addition to /prefix/, consider adding a route with a 307 redirect to the parent application. 
- 
mathviz_hopper.src.bottle.parse_auth(header)[source]¶
- Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None 
- 
mathviz_hopper.src.bottle.parse_date(ims)[source]¶
- Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch. 
- 
mathviz_hopper.src.bottle.parse_range_header(header, maxlen=0)[source]¶
- Yield (start, end) ranges parsed from a HTTP Range header. Skip unsatisfiable ranges. The end index is non-inclusive. 
- 
mathviz_hopper.src.bottle.path_shift(script_name, path_info, shift=1)[source]¶
- Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa. - Returns: - The modified paths. - Parameters: - script_name – The SCRIPT_NAME path.
- script_name – The PATH_INFO path.
- shift – The number of path fragments to shift. May be negative to change the shift direction. (default: 1)
 
- 
mathviz_hopper.src.bottle.redirect(url, code=None)[source]¶
- Aborts execution and causes a 303 or 302 redirect, depending on the HTTP protocol version. 
- 
mathviz_hopper.src.bottle.request= <LocalRequest: GET http://127.0.0.1/>¶
- A thread-safe instance of - LocalRequest. If accessed from within a request callback, this instance always refers to the current request (even on a multi-threaded server).
- 
mathviz_hopper.src.bottle.response= Content-Type: text/html; charset=UTF-8 ¶
- A thread-safe instance of - LocalResponse. It is used to change the HTTP response for the current request.
- 
mathviz_hopper.src.bottle.route(*a, **ka)¶
- A decorator to bind a function to a request URL. Example: - @app.route('/hello/<name>') def hello(name): return 'Hello %s' % name - The - <name>part is a wildcard. See- Routerfor syntax details.- Parameters: - path – Request path or a list of paths to listen to. If no path is specified, it is automatically generated from the signature of the function.
- method – HTTP method (GET, POST, PUT, …) or a list of methods to listen to. (default: GET)
- callback – An optional shortcut to avoid the decorator
syntax. route(..., callback=func)equalsroute(...)(func)
- name – The name for this route. (default: None)
- apply – A decorator or plugin or a list of plugins. These are applied to the route callback in addition to installed plugins.
- skip – A list of plugins, plugin classes or names. Matching
plugins are not installed to this route. Trueskips all.
 - Any additional keyword arguments are stored as route-specific configuration and passed to plugins (see - Plugin.apply()).
- 
mathviz_hopper.src.bottle.run(app=None, server='wsgiref', host='127.0.0.1', port=8080, interval=1, reloader=False, quiet=False, plugins=None, debug=None, config=None, **kargs)[source]¶
- Start a server instance. This method blocks until the server terminates. - Parameters: - app – WSGI application or target string supported by
load_app(). (default:default_app())
- server – Server adapter to use. See server_nameskeys for valid names or pass aServerAdaptersubclass. (default: wsgiref)
- host – Server address to bind to. Pass 0.0.0.0to listens on all interfaces including the external one. (default: 127.0.0.1)
- port – Server port to bind to. Values below 1024 require root privileges. (default: 8080)
- reloader – Start auto-reloading server? (default: False)
- interval – Auto-reloader interval in seconds (default: 1)
- quiet – Suppress output to stdout and stderr? (default: False)
- options – Options passed to the server adapter.
 
- app – WSGI application or target string supported by
- 
mathviz_hopper.src.bottle.static_file(filename, root, mimetype=True, download=False, charset='UTF-8', etag=None)[source]¶
- Open a file in a safe way and return an instance of - HTTPResponsethat can be sent back to the client.- Parameters: - filename – Name or path of the file to send, relative to root.
- root – Root path for file lookups. Should be an absolute directory path.
- mimetype – Provide the content-type header (default: guess from file extension)
- download – If True, ask the browser to open a Save as… dialog instead of opening the file with the associated program. You can specify a custom filename as a string. If not specified, the original filename is used (default: False).
- charset – The charset for files with a text/*mime-type. (default: UTF-8)
- etag – Provide a pre-computed ETag header. If set to False, ETag handling is disabled. (default: auto-generate ETag header)
 - While checking user input is always a good idea, this function provides additional protection against malicious - filenameparameters from breaking out of the- rootdirectory and leaking sensitive information to an attacker.- Read-protected files or files outside of the - rootdirectory are answered with- 403 Access Denied. Missing files result in a- 404 Not Foundresponse. Conditional requests (- If-Modified-Since,- If-None-Match) are answered with- 304 Not Modifiedwhenever possible.- HEADand- Rangerequests (used by download managers to check or continue partial downloads) are also handled automatically.
- filename – Name or path of the file to send, relative to 
- 
mathviz_hopper.src.bottle.template(*args, **kwargs)[source]¶
- 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). 
- 
mathviz_hopper.src.bottle.tonat(s, enc='utf8')¶
- 
mathviz_hopper.src.bottle.uninstall(*a, **ka)¶
- 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 - nameattribute or- Trueto remove all plugins. Return the list of removed plugins.
- 
mathviz_hopper.src.bottle.url(*a, **ka)¶
- Return a string that matches a named route 
- 
mathviz_hopper.src.bottle.view(tpl_name, **defaults)[source]¶
- Decorator: renders a template for a handler. The handler can control its behavior like that: - return a dict of template vars to fill out the template
- return something other than a dict and the view decorator will not process the template, but return the handler result as is. This includes returning a HTTPResponse(dict) to get, for instance, JSON with autojson or other castfilters.
 
- 
mathviz_hopper.src.bottle.yieldroutes(func)[source]¶
- 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: - a() -> '/a' b(x, y) -> '/b/<x>/<y>' c(x, y=5) -> '/c/<x>' and '/c/<x>/<y>' d(x=5, y=6) -> '/d' and '/d/<x>' and '/d/<x>/<y>' 
mathviz_hopper.src.helpers module¶
mathviz_hopper.src.index module¶
Author: Sam Helms Date: Nov 1
This class creates an index that can be served with the table class
mathviz_hopper.src.server_helpers module¶
mathviz_hopper.src.table module¶
Author: Sam Helms
Date: Nov 1
This module implements an interactive table that can display word embeddings. It can also render mathematics using KaTeX.
- 
class mathviz_hopper.src.table.Table(index, port=8081)[source]¶
- This class creates a server and a sets up an interactive javascript table for inspecting word embeddings. - 
print_html()[source]¶
- “prints” a javascript visualization that can be run in the browser (or TODO: a jupyter notebook cell) and initializes listening on a port to serve data to the viz. 
 - 
print_ipython()[source]¶
- Renders the javascript table to a jupyter/ipython notebook cell - Usage example: - >>> t = Table(ind) >>> t.print_ipython() ... renders the table to notebook cell 
 
-