index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
1.07M
signature
stringlengths
2
42.8k
6,369
threading
__repr__
null
def __repr__(self): assert self._initialized, "Thread.__init__() was not called" status = "initial" if self._started.is_set(): status = "started" self.is_alive() # easy way to get ._is_stopped set when appropriate if self._is_stopped: status = "stopped" if self._daemonic: ...
(self)
6,370
threading
_bootstrap
null
def _bootstrap(self): # Wrapper around the real bootstrap code that ignores # exceptions during interpreter cleanup. Those typically # happen when a daemon thread wakes up at an unfortunate # moment, finds the world around it destroyed, and raises some # random exception *** while trying to report ...
(self)
6,371
threading
_bootstrap_inner
null
def _bootstrap_inner(self): try: self._set_ident() self._set_tstate_lock() if _HAVE_THREAD_NATIVE_ID: self._set_native_id() self._started.set() with _active_limbo_lock: _active[self._ident] = self del _limbo[self] if _trace_hook: ...
(self)
6,372
threading
_delete
Remove current thread from the dict of currently running threads.
def _delete(self): "Remove current thread from the dict of currently running threads." with _active_limbo_lock: del _active[get_ident()] # There must not be any python code between the previous line # and after the lock is released. Otherwise a tracing function # could try to ac...
(self)
6,373
threading
_reset_internal_locks
null
def _reset_internal_locks(self, is_alive): # private! Called by _after_fork() to reset our internal locks as # they may be in an invalid state leading to a deadlock or crash. self._started._at_fork_reinit() if is_alive: # bpo-42350: If the fork happens when the thread is already stopped ...
(self, is_alive)
6,374
threading
_set_ident
null
def _set_ident(self): self._ident = get_ident()
(self)
6,375
threading
_set_native_id
null
def _set_native_id(self): self._native_id = get_native_id()
(self)
6,376
threading
_set_tstate_lock
Set a lock object which will be released by the interpreter when the underlying thread state (see pystate.h) gets deleted.
def _set_tstate_lock(self): """ Set a lock object which will be released by the interpreter when the underlying thread state (see pystate.h) gets deleted. """ self._tstate_lock = _set_sentinel() self._tstate_lock.acquire() if not self.daemon: with _shutdown_locks_lock: _m...
(self)
6,377
threading
_stop
null
def _stop(self): # After calling ._stop(), .is_alive() returns False and .join() returns # immediately. ._tstate_lock must be released before calling ._stop(). # # Normal case: C code at the end of the thread's life # (release_sentinel in _threadmodule.c) releases ._tstate_lock, and # that's d...
(self)
6,378
threading
_wait_for_tstate_lock
null
def _wait_for_tstate_lock(self, block=True, timeout=-1): # Issue #18808: wait for the thread state to be gone. # At the end of the thread's life, after all knowledge of the thread # is removed from C data structures, C code releases our _tstate_lock. # This method passes its arguments to _tstate_lock.ac...
(self, block=True, timeout=-1)
6,379
threading
getName
Return a string used for identification purposes only. This method is deprecated, use the name attribute instead.
def getName(self): """Return a string used for identification purposes only. This method is deprecated, use the name attribute instead. """ import warnings warnings.warn('getName() is deprecated, get the name attribute instead', DeprecationWarning, stacklevel=2) return self.nam...
(self)
6,380
threading
isDaemon
Return whether this thread is a daemon. This method is deprecated, use the daemon attribute instead.
def isDaemon(self): """Return whether this thread is a daemon. This method is deprecated, use the daemon attribute instead. """ import warnings warnings.warn('isDaemon() is deprecated, get the daemon attribute instead', DeprecationWarning, stacklevel=2) return self.daemon
(self)
6,381
threading
is_alive
Return whether the thread is alive. This method returns True just before the run() method starts until just after the run() method terminates. See also the module function enumerate().
def is_alive(self): """Return whether the thread is alive. This method returns True just before the run() method starts until just after the run() method terminates. See also the module function enumerate(). """ assert self._initialized, "Thread.__init__() not called" if self._is_stopped or ...
(self)
6,382
threading
join
Wait until the thread terminates. This blocks the calling thread until the thread whose join() method is called terminates -- either normally or through an unhandled exception or until the optional timeout occurs. When the timeout argument is present and not None, it should be a ...
def join(self, timeout=None): """Wait until the thread terminates. This blocks the calling thread until the thread whose join() method is called terminates -- either normally or through an unhandled exception or until the optional timeout occurs. When the timeout argument is present and not None, it...
(self, timeout=None)
6,383
bottle
run
null
def run(self): exists = os.path.exists mtime = lambda path: os.stat(path).st_mtime files = dict() for module in list(sys.modules.values()): path = getattr(module, '__file__', '') or '' if path[-4:] in ('.pyo', '.pyc'): path = path[:-1] if path and exists(path): files[path] = mtim...
(self)
6,384
threading
setDaemon
Set whether this thread is a daemon. This method is deprecated, use the .daemon property instead.
def setDaemon(self, daemonic): """Set whether this thread is a daemon. This method is deprecated, use the .daemon property instead. """ import warnings warnings.warn('setDaemon() is deprecated, set the daemon attribute instead', DeprecationWarning, stacklevel=2) self.daemon = d...
(self, daemonic)
6,385
threading
setName
Set the name string for this thread. This method is deprecated, use the name attribute instead.
def setName(self, name): """Set the name string for this thread. This method is deprecated, use the name attribute instead. """ import warnings warnings.warn('setName() is deprecated, set the name attribute instead', DeprecationWarning, stacklevel=2) self.name = name
(self, name)
6,386
threading
start
Start the thread's activity. It must be called at most once per thread object. It arranges for the object's run() method to be invoked in a separate thread of control. This method will raise a RuntimeError if called more than once on the same thread object.
def start(self): """Start the thread's activity. It must be called at most once per thread object. It arranges for the object's run() method to be invoked in a separate thread of control. This method will raise a RuntimeError if called more than once on the same thread object. """ if not sel...
(self)
6,387
bottle
FileUpload
null
class FileUpload(object): def __init__(self, fileobj, name, filename, headers=None): ''' Wrapper for file uploads. ''' #: Open file(-like) object (BytesIO buffer or temporary file) self.file = fileobj #: Name of the upload form field self.name = name #: Raw filename ...
(fileobj, name, filename, headers=None)
6,388
bottle
__init__
Wrapper for file uploads.
def __init__(self, fileobj, name, filename, headers=None): ''' Wrapper for file uploads. ''' #: Open file(-like) object (BytesIO buffer or temporary file) self.file = fileobj #: Name of the upload form field self.name = name #: Raw filename as sent by the client (may contain unsafe characters) ...
(self, fileobj, name, filename, headers=None)
6,389
bottle
_copy_file
null
def _copy_file(self, fp, chunk_size=2**16): read, write, offset = self.file.read, fp.write, self.file.tell() while 1: buf = read(chunk_size) if not buf: break write(buf) self.file.seek(offset)
(self, fp, chunk_size=65536)
6,390
bottle
get_header
Return the value of a header within the mulripart part.
def get_header(self, name, default=None): """ Return the value of a header within the mulripart part. """ return self.headers.get(name, default)
(self, name, default=None)
6,391
bottle
save
Save file to disk or copy its content to an open file(-like) object. If *destination* is a directory, :attr:`filename` is added to the path. Existing files are not overwritten by default (IOError). :param destination: File path, directory or file(-like) object. :param o...
def save(self, destination, overwrite=False, chunk_size=2**16): ''' Save file to disk or copy its content to an open file(-like) object. If *destination* is a directory, :attr:`filename` is added to the path. Existing files are not overwritten by default (IOError). :param destination: File p...
(self, destination, overwrite=False, chunk_size=65536)
6,392
bottle
FlupFCGIServer
null
class FlupFCGIServer(ServerAdapter): def run(self, handler): # pragma: no cover import flup.server.fcgi self.options.setdefault('bindAddress', (self.host, self.port)) flup.server.fcgi.WSGIServer(handler, **self.options).run()
(host='127.0.0.1', port=8080, **options)
6,395
bottle
run
null
def run(self, handler): # pragma: no cover import flup.server.fcgi self.options.setdefault('bindAddress', (self.host, self.port)) flup.server.fcgi.WSGIServer(handler, **self.options).run()
(self, handler)
6,396
bottle
FormsDict
This :class:`MultiDict` subclass 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 t...
class FormsDict(MultiDict): ''' This :class:`MultiDict` subclass 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 aut...
(*a, **k)
6,397
bottle
__contains__
null
def __contains__(self, key): return key in self.dict
(self, key)
6,398
bottle
__delitem__
null
def __delitem__(self, key): del self.dict[key]
(self, key)
6,400
bottle
__getattr__
null
def __getattr__(self, name, default=unicode()): # Without this guard, pickle generates a cryptic TypeError: if name.startswith('__') and name.endswith('__'): return super(FormsDict, self).__getattr__(name) return self.getunicode(name, default=default)
(self, name, default='')
6,401
bottle
__getitem__
null
def __getitem__(self, key): return self.dict[key][-1]
(self, key)
6,402
bottle
__init__
null
def __init__(self, *a, **k): self.dict = dict((k, [v]) for (k, v) in dict(*a, **k).items())
(self, *a, **k)
6,403
bottle
__iter__
null
def __iter__(self): return iter(self.dict)
(self)
6,404
bottle
__len__
null
def __len__(self): return len(self.dict)
(self)
6,405
bottle
__setitem__
null
def __setitem__(self, key, value): self.append(key, value)
(self, key, value)
6,406
bottle
_fix
null
def _fix(self, s, encoding=None): if isinstance(s, unicode) and self.recode_unicode: # Python 3 WSGI return s.encode('latin1').decode(encoding or self.input_encoding) elif isinstance(s, bytes): # Python 2 WSGI return s.decode(encoding or self.input_encoding) else: return s
(self, s, encoding=None)
6,407
bottle
allitems
null
def allitems(self): return ((k, v) for k, vl in self.dict.items() for v in vl)
(self)
6,408
bottle
append
Add a new value to the list of values for this key.
def append(self, key, value): ''' Add a new value to the list of values for this key. ''' self.dict.setdefault(key, []).append(value)
(self, key, value)
6,410
bottle
decode
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.
def decode(self, encoding=None): ''' 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. ''' copy = FormsDict() enc = copy.input_encoding = encoding or self.input_encoding copy.recode_unicode = F...
(self, encoding=None)
6,411
bottle
get
Return the most recent value for a key. :param default: The default value to be returned if the key is not present or the type conversion fails. :param index: An index for the list of available values. :param type: If defined, this callable is used to cast the va...
def get(self, key, default=None, index=-1, type=None): ''' Return the most recent value for a key. :param default: The default value to be returned if the key is not present or the type conversion fails. :param index: An index for the list of available values. :param type: If ...
(self, key, default=None, index=-1, type=None)
6,412
bottle
getall
Return a (possibly empty) list of values for a key.
def getall(self, key): ''' Return a (possibly empty) list of values for a key. ''' return self.dict.get(key) or []
(self, key)
6,415
bottle
getunicode
Return the value as a unicode string, or the default.
def getunicode(self, name, default=None, encoding=None): ''' Return the value as a unicode string, or the default. ''' try: return self._fix(self[name], encoding) except (UnicodeError, KeyError): return default
(self, name, default=None, encoding=None)
6,416
bottle
items
null
def items(self): return ((k, v[-1]) for k, v in self.dict.items())
(self)
6,419
bottle
keys
null
def keys(self): return self.dict.keys()
(self)
6,420
bottle
values
null
def values(self): return (v[-1] for v in self.dict.values())
(self)
6,424
bottle
replace
Replace the list of values with a single value.
def replace(self, key, value): ''' Replace the list of values with a single value. ''' self.dict[key] = [value]
(self, key, value)
6,428
bottle
GeventServer
Untested. Options: * `fast` (default: False) uses libevent's http server, but has some issues: No streaming, no pipelining, no SSL. * See gevent.wsgi.WSGIServer() documentation for more options.
class GeventServer(ServerAdapter): """ Untested. Options: * `fast` (default: False) uses libevent's http server, but has some issues: No streaming, no pipelining, no SSL. * See gevent.wsgi.WSGIServer() documentation for more options. """ def run(self, handler): from gevent...
(host='127.0.0.1', port=8080, **options)
6,431
bottle
run
null
def run(self, handler): from gevent import pywsgi, local if not isinstance(threading.local(), local.local): msg = "Bottle requires gevent.monkey.patch_all() (before import)" raise RuntimeError(msg) if self.options.pop('fast', None): depr('The "fast" option has been deprecated and rem...
(self, handler)
6,432
bottle
GeventSocketIOServer
null
class GeventSocketIOServer(ServerAdapter): def run(self,handler): from socketio import server address = (self.host, self.port) server.SocketIOServer(address, handler, **self.options).serve_forever()
(host='127.0.0.1', port=8080, **options)
6,435
bottle
run
null
def run(self,handler): from socketio import server address = (self.host, self.port) server.SocketIOServer(address, handler, **self.options).serve_forever()
(self, handler)
6,436
bottle
GunicornServer
Untested. See http://gunicorn.org/configure.html for options.
class GunicornServer(ServerAdapter): """ Untested. See http://gunicorn.org/configure.html for options. """ def run(self, handler): from gunicorn.app.base import Application config = {'bind': "%s:%d" % (self.host, int(self.port))} config.update(self.options) class GunicornApplic...
(host='127.0.0.1', port=8080, **options)
6,439
bottle
run
null
def run(self, handler): from gunicorn.app.base import Application config = {'bind': "%s:%d" % (self.host, int(self.port))} config.update(self.options) class GunicornApplication(Application): def init(self, parser, opts, args): return config def load(self): return ...
(self, handler)
6,440
bottle
HTTPError
null
class HTTPError(HTTPResponse): default_status = 500 def __init__(self, status=None, body=None, exception=None, traceback=None, **options): self.exception = exception self.traceback = traceback super(HTTPError, self).__init__(body, status, **options)
(status=None, body=None, exception=None, traceback=None, **options)
6,444
bottle
__init__
null
def __init__(self, status=None, body=None, exception=None, traceback=None, **options): self.exception = exception self.traceback = traceback super(HTTPError, self).__init__(body, status, **options)
(self, status=None, body=None, exception=None, traceback=None, **options)
6,449
bottle
apply
null
def apply(self, response): response._status_code = self._status_code response._status_line = self._status_line response._headers = self._headers response._cookies = self._cookies response.body = self.body
(self, response)
6,457
bottle
HTTPResponse
null
class HTTPResponse(Response, BottleException): def __init__(self, body='', status=None, headers=None, **more_headers): super(HTTPResponse, self).__init__(body, status, headers, **more_headers) def apply(self, response): response._status_code = self._status_code response._status_line = s...
(body='', status=None, headers=None, **more_headers)
6,461
bottle
__init__
null
def __init__(self, body='', status=None, headers=None, **more_headers): super(HTTPResponse, self).__init__(body, status, headers, **more_headers)
(self, body='', status=None, headers=None, **more_headers)
6,474
bottle
HeaderDict
A case-insensitive version of :class:`MultiDict` that defaults to replace the old value instead of appending it.
class HeaderDict(MultiDict): """ A case-insensitive version of :class:`MultiDict` that defaults to replace the old value instead of appending it. """ def __init__(self, *a, **ka): self.dict = {} if a or ka: self.update(*a, **ka) def __contains__(self, key): return _hkey(key) in sel...
(*a, **ka)
6,475
bottle
__contains__
null
def __contains__(self, key): return _hkey(key) in self.dict
(self, key)
6,476
bottle
__delitem__
null
def __delitem__(self, key): del self.dict[_hkey(key)]
(self, key)
6,478
bottle
__getitem__
null
def __getitem__(self, key): return self.dict[_hkey(key)][-1]
(self, key)
6,479
bottle
__init__
null
def __init__(self, *a, **ka): self.dict = {} if a or ka: self.update(*a, **ka)
(self, *a, **ka)
6,482
bottle
__setitem__
null
def __setitem__(self, key, value): self.dict[_hkey(key)] = [_hval(value)]
(self, key, value)
6,484
bottle
append
null
def append(self, key, value): self.dict.setdefault(_hkey(key), []).append(_hval(value))
(self, key, value)
6,486
bottle
filter
null
def filter(self, names): for name in (_hkey(n) for n in names): if name in self.dict: del self.dict[name]
(self, names)
6,487
bottle
get
null
def get(self, key, default=None, index=-1): return MultiDict.get(self, _hkey(key), default, index)
(self, key, default=None, index=-1)
6,488
bottle
getall
null
def getall(self, key): return self.dict.get(_hkey(key)) or []
(self, key)
6,499
bottle
replace
null
def replace(self, key, value): self.dict[_hkey(key)] = [_hval(value)]
(self, key, value)
6,503
bottle
HeaderProperty
null
class HeaderProperty(object): def __init__(self, name, reader=None, writer=None, default=''): self.name, self.default = name, default self.reader, self.writer = reader, writer self.__doc__ = 'Current value of the %r header.' % name.title() def __get__(self, obj, cls): if obj is ...
(name, reader=None, writer=None, default='')
6,504
bottle
__delete__
null
def __delete__(self, obj): del obj[self.name]
(self, obj)
6,505
bottle
__get__
null
def __get__(self, obj, cls): if obj is None: return self value = obj.get_header(self.name, self.default) return self.reader(value) if self.reader else value
(self, obj, cls)
6,506
bottle
__init__
null
def __init__(self, name, reader=None, writer=None, default=''): self.name, self.default = name, default self.reader, self.writer = reader, writer self.__doc__ = 'Current value of the %r header.' % name.title()
(self, name, reader=None, writer=None, default='')
6,507
bottle
__set__
null
def __set__(self, obj, value): obj[self.name] = self.writer(value) if self.writer else value
(self, obj, value)
6,508
bottle
JSONPlugin
null
class JSONPlugin(object): name = 'json' api = 2 def __init__(self, json_dumps=json_dumps): self.json_dumps = json_dumps def apply(self, callback, route): dumps = self.json_dumps if not dumps: return callback def wrapper(*a, **ka): try: rv = ...
(json_dumps=<function dumps at 0x7f454e0dcb80>)
6,509
bottle
__init__
null
def __init__(self, json_dumps=json_dumps): self.json_dumps = json_dumps
(self, json_dumps=<function dumps at 0x7f454e0dcb80>)
6,510
bottle
apply
null
def apply(self, callback, route): dumps = self.json_dumps if not dumps: return callback def wrapper(*a, **ka): try: rv = callback(*a, **ka) except HTTPResponse: rv = _e() if isinstance(rv, dict): #Attempt to serialize, raises exception on failure ...
(self, callback, route)
6,511
bottle
Jinja2Template
null
class Jinja2Template(BaseTemplate): def prepare(self, filters=None, tests=None, globals={}, **kwargs): from jinja2 import Environment, FunctionLoader if 'prefix' in kwargs: # TODO: to be removed after a while raise RuntimeError('The keyword argument `prefix` has been removed. ' ...
(source=None, name=None, lookup=[], encoding='utf8', **settings)
6,513
bottle
loader
null
def loader(self, name): fname = self.search(name, self.lookup) if not fname: return with open(fname, "rb") as f: return f.read().decode(self.encoding)
(self, name)
6,514
bottle
prepare
null
def prepare(self, filters=None, tests=None, globals={}, **kwargs): from jinja2 import Environment, FunctionLoader if 'prefix' in kwargs: # TODO: to be removed after a while raise RuntimeError('The keyword argument `prefix` has been removed. ' 'Use the full jinja2 environment name line_statem...
(self, filters=None, tests=None, globals={}, **kwargs)
6,515
bottle
render
null
def render(self, *args, **kwargs): for dictarg in args: kwargs.update(dictarg) _defaults = self.defaults.copy() _defaults.update(kwargs) return self.tpl.render(**_defaults)
(self, *args, **kwargs)
6,516
bottle
LocalRequest
A thread-local subclass of :class:`BaseRequest` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`request`). If accessed during a request/response cycle, this instance always refers to the *current* request (even on a mul...
class LocalRequest(BaseRequest): ''' A thread-local subclass of :class:`BaseRequest` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`request`). If accessed during a request/response cycle, this instance always refers to the ...
(environ=None)
6,536
bottle
LocalResponse
A thread-local subclass of :class:`BaseResponse` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`response`). Its attributes are used to build the HTTP response at the end of the request/response cycle.
class LocalResponse(BaseResponse): ''' A thread-local subclass of :class:`BaseResponse` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`response`). Its attributes are used to build the HTTP response at the end of the request...
(body='', status=None, headers=None, **more_headers)
6,553
bottle
MakoTemplate
null
class MakoTemplate(BaseTemplate): def prepare(self, **options): from mako.template import Template from mako.lookup import TemplateLookup options.update({'input_encoding':self.encoding}) options.setdefault('format_exceptions', bool(DEBUG)) lookup = TemplateLookup(directories=...
(source=None, name=None, lookup=[], encoding='utf8', **settings)
6,555
bottle
prepare
null
def prepare(self, **options): from mako.template import Template from mako.lookup import TemplateLookup options.update({'input_encoding':self.encoding}) options.setdefault('format_exceptions', bool(DEBUG)) lookup = TemplateLookup(directories=self.lookup, **options) if self.source: self.t...
(self, **options)
6,557
bottle
MeinheldServer
null
class MeinheldServer(ServerAdapter): def run(self, handler): from meinheld import server server.listen((self.host, self.port)) server.run(handler)
(host='127.0.0.1', port=8080, **options)
6,560
bottle
run
null
def run(self, handler): from meinheld import server server.listen((self.host, self.port)) server.run(handler)
(self, handler)
6,561
bottle
MultiDict
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.
class MultiDict(DictMixin): """ 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. """ def __init__(self, *a, **k): self.d...
(*a, **k)
6,589
bottle
PasteServer
null
class PasteServer(ServerAdapter): def run(self, handler): # pragma: no cover from paste import httpserver from paste.translogger import TransLogger handler = TransLogger(handler, setup_console_handler=(not self.quiet)) httpserver.serve(handler, host=self.host, port=str(self.port), ...
(host='127.0.0.1', port=8080, **options)
6,592
bottle
run
null
def run(self, handler): # pragma: no cover from paste import httpserver from paste.translogger import TransLogger handler = TransLogger(handler, setup_console_handler=(not self.quiet)) httpserver.serve(handler, host=self.host, port=str(self.port), **self.options)
(self, handler)
6,593
bottle
PluginError
null
class PluginError(BottleException): pass
null
6,613
bottle
ResourceManager
This class manages a list of search paths and helps to find and open application-bound resources (files). :param base: default value for :meth:`add_path` calls. :param opener: callable used to open resources. :param cachemode: controls which lookups are cached. One of 'all', ...
class ResourceManager(object): ''' This class manages a list of search paths and helps to find and open application-bound resources (files). :param base: default value for :meth:`add_path` calls. :param opener: callable used to open resources. :param cachemode: controls which lookup...
(base='./', opener=<built-in function open>, cachemode='all')
6,614
bottle
__init__
null
def __init__(self, base='./', opener=open, cachemode='all'): self.opener = open self.base = base self.cachemode = cachemode #: A list of search paths. See :meth:`add_path` for details. self.path = [] #: A cache for resolved paths. ``res.cache.clear()`` clears the cache. self.cache = {}
(self, base='./', opener=<built-in function open>, cachemode='all')
6,615
bottle
__iter__
Iterate over all existing files in all registered paths.
def __iter__(self): ''' Iterate over all existing files in all registered paths. ''' 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(ful...
(self)
6,616
bottle
add_path
Add a new path to the list of search paths. Return False if the path does not exist. :param 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...
def add_path(self, path, base=None, index=None, create=False): ''' Add a new path to the list of search paths. Return False if the path does not exist. :param path: The new search path. Relative paths are turned into an absolute and normalized form. If the path looks like a file ...
(self, path, base=None, index=None, create=False)
6,617
bottle
lookup
Search for a resource and return an absolute file path, or `None`. The :attr:`path` list is searched in order. The first match is returend. Symlinks are followed. The result is cached to speed up future lookups.
def lookup(self, name): ''' Search for a resource and return an absolute file path, or `None`. The :attr:`path` list is searched in order. The first match is returend. Symlinks are followed. The result is cached to speed up future lookups. ''' if name not in self.cache or DEBUG: ...
(self, name)
6,618
bottle
open
Find a resource and return a file object, or raise IOError.
def open(self, name, mode='r', *args, **kwargs): ''' Find a resource and return a file object, or raise IOError. ''' fname = self.lookup(name) if not fname: raise IOError("Resource %r not found." % name) return self.opener(fname, mode=mode, *args, **kwargs)
(self, name, mode='r', *args, **kwargs)
6,635
bottle
RocketServer
Untested.
class RocketServer(ServerAdapter): """ Untested. """ def run(self, handler): from rocket import Rocket server = Rocket((self.host, self.port), 'wsgi', { 'wsgi_app' : handler }) server.start()
(host='127.0.0.1', port=8080, **options)
6,638
bottle
run
null
def run(self, handler): from rocket import Rocket server = Rocket((self.host, self.port), 'wsgi', { 'wsgi_app' : handler }) server.start()
(self, handler)
6,639
bottle
Route
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.
class Route(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. ''' def __init__(self, app, rule, method, callbac...
(app, rule, method, callback, name=None, plugins=None, skiplist=None, **config)
6,640
bottle
__call__
null
def __call__(self, *a, **ka): depr("Some APIs changed to return Route() instances instead of"\ " callables. Make sure to use the Route.call method and not to"\ " call Route instances directly.") #0.12 return self.call(*a, **ka)
(self, *a, **ka)
6,641
bottle
__init__
null
def __init__(self, app, rule, method, callback, name=None, plugins=None, skiplist=None, **config): #: The application this route is installed to. self.app = app #: The path-rule string (e.g. ``/wiki/:page``). self.rule = rule #: The HTTP method as a string (e.g. ``GET``). self.metho...
(self, app, rule, method, callback, name=None, plugins=None, skiplist=None, **config)