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,233 | bottle | get | Equals :meth:`route`. | def get(self, path=None, method='GET', **options):
""" Equals :meth:`route`. """
return self.route(path, method, **options)
| (self, path=None, method='GET', **options) |
6,234 | bottle | get_url | Return a string that matches a named route | def get_url(self, routename, **kargs):
""" Return a string that matches a named route """
scriptname = request.environ.get('SCRIPT_NAME', '').strip('/') + '/'
location = self.router.build(routename, **kargs).lstrip('/')
return urljoin(urljoin('/', scriptname), location)
| (self, routename, **kargs) |
6,235 | bottle | hook | Return a decorator that attaches a callback to a hook. See
:meth:`add_hook` for details. | def hook(self, name):
""" Return a decorator that attaches a callback to a hook. See
:meth:`add_hook` for details."""
def decorator(func):
self.add_hook(name, func)
return func
return decorator
| (self, name) |
6,236 | bottle | install | 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.
| def install(self, plugin):
''' 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.
'''
if hasattr(plugin, 'setup'): plugin.setup(self)
if not calla... | (self, plugin) |
6,237 | bottle | match | 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. | def match(self, environ):
""" 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."""
return self.router.match(environ)
| (self, environ) |
6,238 | bottle | merge | 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. | def merge(self, routes):
''' 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. '''
if isinstance(routes, Bottle):
routes = ... | (self, routes) |
6,239 | bottle | mount | Mount an application (:class:`Bottle` or plain WSGI) to a specific
URL prefix. Example::
root_app.mount('/admin/', admin_app)
:param prefix: path prefix or `mount-point`. If it ends in a slash,
that slash is mandatory.
:param app: an instance of :cl... | def mount(self, prefix, app, **options):
''' Mount an application (:class:`Bottle` or plain WSGI) to a specific
URL prefix. Example::
root_app.mount('/admin/', admin_app)
:param prefix: path prefix or `mount-point`. If it ends in a slash,
that slash is mandatory.
:par... | (self, prefix, app, **options) |
6,240 | bottle | post | Equals :meth:`route` with a ``POST`` method parameter. | def post(self, path=None, method='POST', **options):
""" Equals :meth:`route` with a ``POST`` method parameter. """
return self.route(path, method, **options)
| (self, path=None, method='POST', **options) |
6,241 | bottle | put | Equals :meth:`route` with a ``PUT`` method parameter. | def put(self, path=None, method='PUT', **options):
""" Equals :meth:`route` with a ``PUT`` method parameter. """
return self.route(path, method, **options)
| (self, path=None, method='PUT', **options) |
6,242 | bottle | remove_hook | Remove a callback from a hook. | def remove_hook(self, name, func):
''' Remove a callback from a hook. '''
if name in self._hooks and func in self._hooks[name]:
self._hooks[name].remove(func)
return True
| (self, name, func) |
6,243 | bottle | reset | 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. | def reset(self, route=None):
''' 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. '''
if route is None: routes = self.routes
elif isinstance(route, Route): routes = [route]
else: routes = [sel... | (self, route=None) |
6,244 | bottle | route | 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 :class:`Router` for syntax
details.
:param path: Request path ... | def route(self, path=None, method='GET', callback=None, name=None,
apply=None, skip=None, **config):
""" 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 w... | (self, path=None, method='GET', callback=None, name=None, apply=None, skip=None, **config) |
6,245 | bottle | run | Calls :func:`run` with the same parameters. | def run(self, **kwargs):
''' Calls :func:`run` with the same parameters. '''
run(self, **kwargs)
| (self, **kwargs) |
6,246 | bottle | trigger_hook | Trigger a hook and return a list of results. | def trigger_hook(self, __name, *args, **kwargs):
''' Trigger a hook and return a list of results. '''
return [hook(*args, **kwargs) for hook in self._hooks[__name][:]]
| (self, _Bottle__name, *args, **kwargs) |
6,247 | bottle | uninstall | 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. | def uninstall(self, plugin):
''' 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.... | (self, plugin) |
6,248 | bottle | wsgi | The bottle WSGI-interface. | def wsgi(self, environ, start_response):
""" The bottle WSGI-interface. """
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... | (self, environ, start_response) |
6,249 | bottle | BottleException | A base class for exceptions used by bottle. | class BottleException(Exception):
""" A base class for exceptions used by bottle. """
pass
| null |
6,250 | _io | BytesIO | Buffered I/O implementation using an in-memory bytes buffer. | from _io import BytesIO
| (initial_bytes=b'') |
6,251 | bottle | CGIServer | null | class CGIServer(ServerAdapter):
quiet = True
def run(self, handler): # pragma: no cover
from wsgiref.handlers import CGIHandler
def fixed_environ(environ, start_response):
environ.setdefault('PATH_INFO', '')
return handler(environ, start_response)
CGIHandler().run... | (host='127.0.0.1', port=8080, **options) |
6,254 | bottle | run | null | def run(self, handler): # pragma: no cover
from wsgiref.handlers import CGIHandler
def fixed_environ(environ, start_response):
environ.setdefault('PATH_INFO', '')
return handler(environ, start_response)
CGIHandler().run(fixed_environ)
| (self, handler) |
6,255 | bottle | CheetahTemplate | null | class CheetahTemplate(BaseTemplate):
def prepare(self, **options):
from Cheetah.Template import Template
self.context = threading.local()
self.context.vars = {}
options['searchList'] = [self.context.vars]
if self.source:
self.tpl = Template(source=self.source, **o... | (source=None, name=None, lookup=[], encoding='utf8', **settings) |
6,257 | bottle | prepare | null | def prepare(self, **options):
from Cheetah.Template import Template
self.context = threading.local()
self.context.vars = {}
options['searchList'] = [self.context.vars]
if self.source:
self.tpl = Template(source=self.source, **options)
else:
self.tpl = Template(file=self.filename,... | (self, **options) |
6,258 | bottle | render | null | def render(self, *args, **kwargs):
for dictarg in args: kwargs.update(dictarg)
self.context.vars.update(self.defaults)
self.context.vars.update(kwargs)
out = str(self.tpl)
self.context.vars.clear()
return out
| (self, *args, **kwargs) |
6,259 | bottle | CherootServer | null | class CherootServer(ServerAdapter):
def run(self, handler): # pragma: no cover
from cheroot import wsgi
from cheroot.ssl import builtin
self.options['bind_addr'] = (self.host, self.port)
self.options['wsgi_app'] = handler
certfile = self.options.pop('certfile', None)
... | (host='127.0.0.1', port=8080, **options) |
6,262 | bottle | run | null | def run(self, handler): # pragma: no cover
from cheroot import wsgi
from cheroot.ssl import builtin
self.options['bind_addr'] = (self.host, self.port)
self.options['wsgi_app'] = handler
certfile = self.options.pop('certfile', None)
keyfile = self.options.pop('keyfile', None)
chainfile = self... | (self, handler) |
6,263 | bottle | CherryPyServer | null | class CherryPyServer(ServerAdapter):
def run(self, handler): # pragma: no cover
depr("The wsgi server part of cherrypy was split into a new "
"project called 'cheroot'. Use the 'cheroot' server "
"adapter instead of cherrypy.")
from cherrypy import wsgiserver # This will fa... | (host='127.0.0.1', port=8080, **options) |
6,266 | bottle | run | null | def run(self, handler): # pragma: no cover
depr("The wsgi server part of cherrypy was split into a new "
"project called 'cheroot'. Use the 'cheroot' server "
"adapter instead of cherrypy.")
from cherrypy import wsgiserver # This will fail for CherryPy >= 9
self.options['bind_addr'] = (sel... | (self, handler) |
6,267 | bottle | ConfigDict | A dict-like configuration storage with additional support for
namespaces, validators, meta-data, on_change listeners and more.
This storage is optimized for fast read access. Retrieving a key
or using non-altering dict methods (e.g. `dict.get()`) has no overhead
compared to a native di... | class ConfigDict(dict):
''' A dict-like configuration storage with additional support for
namespaces, validators, meta-data, on_change listeners and more.
This storage is optimized for fast read access. Retrieving a key
or using non-altering dict methods (e.g. `dict.get()`) has no overhead
... | (*a, **ka) |
6,268 | bottle | __call__ | null | def __call__(self, *a, **ka):
depr('Calling ConfDict is deprecated. Use the update() method.') #0.12
self.update(*a, **ka)
return self
| (self, *a, **ka) |
6,269 | bottle | __delattr__ | null | def __delattr__(self, key):
if key in self:
val = self.pop(key)
if isinstance(val, self.Namespace):
prefix = key + '.'
for key in self:
if key.startswith(prefix):
del self[prefix+key]
| (self, key) |
6,270 | bottle | __delitem__ | null | def __delitem__(self, key):
dict.__delitem__(self, key)
| (self, key) |
6,271 | bottle | __getattr__ | null | def __getattr__(self, key):
depr('Attribute access is deprecated.') #0.12
if key not in self and key[0].isupper():
self[key] = self.Namespace(self, key)
if key not in self and key.startswith('__'):
raise AttributeError(key)
return self.get(key)
| (self, key) |
6,272 | bottle | __init__ | null | def __init__(self, *a, **ka):
self._meta = {}
self._on_change = lambda name, value: None
if a or ka:
depr('Constructor does no longer accept parameters.') #0.12
self.update(*a, **ka)
| (self, *a, **ka) |
6,273 | bottle | __setattr__ | null | def __setattr__(self, key, value):
if key in self.__slots__:
return dict.__setattr__(self, key, value)
depr('Attribute assignment is deprecated.') #0.12
if hasattr(dict, key):
raise AttributeError('Read-only attribute.')
if key in self and self[key] and isinstance(self[key], self.Namespa... | (self, key, value) |
6,274 | bottle | __setitem__ | null | def __setitem__(self, key, value):
if not isinstance(key, basestring):
raise TypeError('Key has type %r (not a string)' % type(key))
value = self.meta_get(key, 'filter', lambda x: x)(value)
if key in self and self[key] is value:
return
self._on_change(key, value)
dict.__setitem__(sel... | (self, key, value) |
6,275 | bottle | clear | null | def clear(self):
for key in self:
del self[key]
| (self) |
6,276 | bottle | load_config | Load values from an *.ini style config file.
If the config file contains sections, their names are used as
namespaces for the values within. The two special sections
``DEFAULT`` and ``bottle`` refer to the root namespace (no prefix).
| def load_config(self, filename):
''' Load values from an *.ini style config file.
If the config file contains sections, their names are used as
namespaces for the values within. The two special sections
``DEFAULT`` and ``bottle`` refer to the root namespace (no prefix).
'''
conf = Co... | (self, filename) |
6,277 | bottle | load_dict | Import values from a dictionary structure. Nesting can be used to
represent namespaces.
>>> ConfigDict().load_dict({'name': {'space': {'key': 'value'}}})
{'name.space.key': 'value'}
| def load_dict(self, source, namespace='', make_namespaces=False):
''' Import values from a dictionary structure. Nesting can be used to
represent namespaces.
>>> ConfigDict().load_dict({'name': {'space': {'key': 'value'}}})
{'name.space.key': 'value'}
'''
stack = [(namespace, source)... | (self, source, namespace='', make_namespaces=False) |
6,278 | bottle | meta_get | Return the value of a meta field for a key. | def meta_get(self, key, metafield, default=None):
''' Return the value of a meta field for a key. '''
return self._meta.get(key, {}).get(metafield, default)
| (self, key, metafield, default=None) |
6,279 | bottle | meta_list | Return an iterable of meta field names defined for a key. | def meta_list(self, key):
''' Return an iterable of meta field names defined for a key. '''
return self._meta.get(key, {}).keys()
| (self, key) |
6,280 | bottle | meta_set | Set the meta field for a key to a new value. This triggers the
on-change handler for existing keys. | def meta_set(self, key, metafield, value):
''' Set the meta field for a key to a new value. This triggers the
on-change handler for existing keys. '''
self._meta.setdefault(key, {})[metafield] = value
if key in self:
self[key] = self[key]
| (self, key, metafield, value) |
6,281 | bottle | setdefault | null | def setdefault(self, key, value):
if key not in self:
self[key] = value
return self[key]
| (self, key, value) |
6,282 | bottle | update | If the first parameter is a string, all keys are prefixed with this
namespace. Apart from that it works just as the usual dict.update().
Example: ``update('some.namespace', key='value')`` | def update(self, *a, **ka):
''' If the first parameter is a string, all keys are prefixed with this
namespace. Apart from that it works just as the usual dict.update().
Example: ``update('some.namespace', key='value')`` '''
prefix = ''
if a and isinstance(a[0], basestring):
prefix = ... | (self, *a, **ka) |
6,283 | configparser | ConfigParser | ConfigParser implementing interpolation. | class ConfigParser(RawConfigParser):
"""ConfigParser implementing interpolation."""
_DEFAULT_INTERPOLATION = BasicInterpolation()
def set(self, section, option, value=None):
"""Set an option. Extends RawConfigParser.set by validating type and
interpolation syntax on the value."""
... | (defaults=None, dict_type=<class 'dict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object at 0x7f454e629be0>, converters=<object object at 0x7f454e629be0>) |
6,284 | configparser | __contains__ | null | def __contains__(self, key):
return key == self.default_section or self.has_section(key)
| (self, key) |
6,285 | configparser | __delitem__ | null | def __delitem__(self, key):
if key == self.default_section:
raise ValueError("Cannot remove the default section.")
if not self.has_section(key):
raise KeyError(key)
self.remove_section(key)
| (self, key) |
6,287 | configparser | __getitem__ | null | def __getitem__(self, key):
if key != self.default_section and not self.has_section(key):
raise KeyError(key)
return self._proxies[key]
| (self, key) |
6,288 | configparser | __init__ | null | def __init__(self, defaults=None, dict_type=_default_dict,
allow_no_value=False, *, delimiters=('=', ':'),
comment_prefixes=('#', ';'), inline_comment_prefixes=None,
strict=True, empty_lines_in_values=True,
default_section=DEFAULTSECT,
interpolation=_UNSE... | (self, defaults=None, dict_type=<class 'dict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object at 0x7f454e629be0>, converters=<object object at 0x7f454e629be0>) |
6,289 | configparser | __iter__ | null | def __iter__(self):
# XXX does it break when underlying container state changed?
return itertools.chain((self.default_section,), self._sections.keys())
| (self) |
6,290 | configparser | __len__ | null | def __len__(self):
return len(self._sections) + 1 # the default section
| (self) |
6,291 | configparser | __setitem__ | null | def __setitem__(self, key, value):
# To conform with the mapping protocol, overwrites existing values in
# the section.
if key in self and self[key] is value:
return
# XXX this is not atomic if read_dict fails at any point. Then again,
# no update method in configparser is atomic in this imp... | (self, key, value) |
6,292 | configparser | _convert_to_boolean | Return a boolean value translating from other types if necessary.
| def _convert_to_boolean(self, value):
"""Return a boolean value translating from other types if necessary.
"""
if value.lower() not in self.BOOLEAN_STATES:
raise ValueError('Not a boolean: %s' % value)
return self.BOOLEAN_STATES[value.lower()]
| (self, value) |
6,293 | configparser | _get | null | def _get(self, section, conv, option, **kwargs):
return conv(self.get(section, option, **kwargs))
| (self, section, conv, option, **kwargs) |
6,294 | configparser | _get_conv | null | def _get_conv(self, section, option, conv, *, raw=False, vars=None,
fallback=_UNSET, **kwargs):
try:
return self._get(section, conv, option, raw=raw, vars=vars,
**kwargs)
except (NoSectionError, NoOptionError):
if fallback is _UNSET:
raise
... | (self, section, option, conv, *, raw=False, vars=None, fallback=<object object at 0x7f454e629be0>, **kwargs) |
6,295 | configparser | _handle_error | null | def _handle_error(self, exc, fpname, lineno, line):
if not exc:
exc = ParsingError(fpname)
exc.append(lineno, repr(line))
return exc
| (self, exc, fpname, lineno, line) |
6,296 | configparser | _join_multiline_values | null | def _join_multiline_values(self):
defaults = self.default_section, self._defaults
all_sections = itertools.chain((defaults,),
self._sections.items())
for section, options in all_sections:
for name, val in options.items():
if isinstance(val, list):
... | (self) |
6,297 | configparser | _read | Parse a sectioned configuration file.
Each section in a configuration file contains a header, indicated by
a name in square brackets (`[]`), plus key/value options, indicated by
`name` and `value` delimited with a specific substring (`=` or `:` by
default).
Values can span mult... | def _read(self, fp, fpname):
"""Parse a sectioned configuration file.
Each section in a configuration file contains a header, indicated by
a name in square brackets (`[]`), plus key/value options, indicated by
`name` and `value` delimited with a specific substring (`=` or `:` by
default).
Values... | (self, fp, fpname) |
6,298 | configparser | _read_defaults | Reads the defaults passed in the initializer, implicitly converting
values to strings like the rest of the API.
Does not perform interpolation for backwards compatibility.
| def _read_defaults(self, defaults):
"""Reads the defaults passed in the initializer, implicitly converting
values to strings like the rest of the API.
Does not perform interpolation for backwards compatibility.
"""
try:
hold_interpolation = self._interpolation
self._interpolation = I... | (self, defaults) |
6,299 | configparser | _unify_values | Create a sequence of lookups with 'vars' taking priority over
the 'section' which takes priority over the DEFAULTSECT.
| def _unify_values(self, section, vars):
"""Create a sequence of lookups with 'vars' taking priority over
the 'section' which takes priority over the DEFAULTSECT.
"""
sectiondict = {}
try:
sectiondict = self._sections[section]
except KeyError:
if section != self.default_section:
... | (self, section, vars) |
6,300 | configparser | _validate_value_types | Raises a TypeError for non-string values.
The only legal non-string value if we allow valueless
options is None, so we need to check if the value is a
string if:
- we do not allow valueless options, or
- we allow valueless options but the value is not None
For compatibi... | def _validate_value_types(self, *, section="", option="", value=""):
"""Raises a TypeError for non-string values.
The only legal non-string value if we allow valueless
options is None, so we need to check if the value is a
string if:
- we do not allow valueless options, or
- we allow valueless o... | (self, *, section='', option='', value='') |
6,301 | configparser | _write_section | Write a single section to the specified `fp`. | def _write_section(self, fp, section_name, section_items, delimiter):
"""Write a single section to the specified `fp`."""
fp.write("[{}]\n".format(section_name))
for key, value in section_items:
value = self._interpolation.before_write(self, section_name, key,
... | (self, fp, section_name, section_items, delimiter) |
6,302 | configparser | add_section | Create a new section in the configuration. Extends
RawConfigParser.add_section by validating if the section name is
a string. | def add_section(self, section):
"""Create a new section in the configuration. Extends
RawConfigParser.add_section by validating if the section name is
a string."""
self._validate_value_types(section=section)
super().add_section(section)
| (self, section) |
6,304 | configparser | defaults | null | def defaults(self):
return self._defaults
| (self) |
6,305 | configparser | get | Get an option value for a given section.
If `vars` is provided, it must be a dictionary. The option is looked up
in `vars` (if provided), `section`, and in `DEFAULTSECT` in that order.
If the key is not found and `fallback` is provided, it is used as
a fallback value. `None` can be prov... | def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
"""Get an option value for a given section.
If `vars` is provided, it must be a dictionary. The option is looked up
in `vars` (if provided), `section`, and in `DEFAULTSECT` in that order.
If the key is not found and `fallback` is ... | (self, section, option, *, raw=False, vars=None, fallback=<object object at 0x7f454e629be0>) |
6,306 | configparser | getboolean | null | def getboolean(self, section, option, *, raw=False, vars=None,
fallback=_UNSET, **kwargs):
return self._get_conv(section, option, self._convert_to_boolean,
raw=raw, vars=vars, fallback=fallback, **kwargs)
| (self, section, option, *, raw=False, vars=None, fallback=<object object at 0x7f454e629be0>, **kwargs) |
6,307 | configparser | getfloat | null | def getfloat(self, section, option, *, raw=False, vars=None,
fallback=_UNSET, **kwargs):
return self._get_conv(section, option, float, raw=raw, vars=vars,
fallback=fallback, **kwargs)
| (self, section, option, *, raw=False, vars=None, fallback=<object object at 0x7f454e629be0>, **kwargs) |
6,308 | configparser | getint | null | def getint(self, section, option, *, raw=False, vars=None,
fallback=_UNSET, **kwargs):
return self._get_conv(section, option, int, raw=raw, vars=vars,
fallback=fallback, **kwargs)
| (self, section, option, *, raw=False, vars=None, fallback=<object object at 0x7f454e629be0>, **kwargs) |
6,309 | configparser | has_option | Check for the existence of a given option in a given section.
If the specified `section` is None or an empty string, DEFAULT is
assumed. If the specified `section` does not exist, returns False. | def has_option(self, section, option):
"""Check for the existence of a given option in a given section.
If the specified `section` is None or an empty string, DEFAULT is
assumed. If the specified `section` does not exist, returns False."""
if not section or section == self.default_section:
optio... | (self, section, option) |
6,310 | configparser | has_section | Indicate whether the named section is present in the configuration.
The DEFAULT section is not acknowledged.
| def has_section(self, section):
"""Indicate whether the named section is present in the configuration.
The DEFAULT section is not acknowledged.
"""
return section in self._sections
| (self, section) |
6,311 | configparser | items | Return a list of (name, value) tuples for each option in a section.
All % interpolations are expanded in the return values, based on the
defaults passed into the constructor, unless the optional argument
`raw` is true. Additional substitutions may be provided using the
`vars` argument,... | def items(self, section=_UNSET, raw=False, vars=None):
"""Return a list of (name, value) tuples for each option in a section.
All % interpolations are expanded in the return values, based on the
defaults passed into the constructor, unless the optional argument
`raw` is true. Additional substitutions m... | (self, section=<object object at 0x7f454e629be0>, raw=False, vars=None) |
6,313 | configparser | options | Return a list of option names for the given section name. | def options(self, section):
"""Return a list of option names for the given section name."""
try:
opts = self._sections[section].copy()
except KeyError:
raise NoSectionError(section) from None
opts.update(self._defaults)
return list(opts.keys())
| (self, section) |
6,314 | configparser | optionxform | null | def optionxform(self, optionstr):
return optionstr.lower()
| (self, optionstr) |
6,316 | configparser | popitem | Remove a section from the parser and return it as
a (section_name, section_proxy) tuple. If no section is present, raise
KeyError.
The section DEFAULT is never returned because it cannot be removed.
| def popitem(self):
"""Remove a section from the parser and return it as
a (section_name, section_proxy) tuple. If no section is present, raise
KeyError.
The section DEFAULT is never returned because it cannot be removed.
"""
for key in self.sections():
value = self[key]
del self[... | (self) |
6,317 | configparser | read | Read and parse a filename or an iterable of filenames.
Files that cannot be opened are silently ignored; this is
designed so that you can specify an iterable of potential
configuration file locations (e.g. current directory, user's
home directory, systemwide directory), and all existing... | def read(self, filenames, encoding=None):
"""Read and parse a filename or an iterable of filenames.
Files that cannot be opened are silently ignored; this is
designed so that you can specify an iterable of potential
configuration file locations (e.g. current directory, user's
home directory, systemw... | (self, filenames, encoding=None) |
6,318 | configparser | read_dict | Read configuration from a dictionary.
Keys are section names, values are dictionaries with keys and values
that should be present in the section. If the used dictionary type
preserves order, sections and their keys will be added in order.
All types held in the dictionary are converted ... | def read_dict(self, dictionary, source='<dict>'):
"""Read configuration from a dictionary.
Keys are section names, values are dictionaries with keys and values
that should be present in the section. If the used dictionary type
preserves order, sections and their keys will be added in order.
All type... | (self, dictionary, source='<dict>') |
6,319 | configparser | read_file | Like read() but the argument must be a file-like object.
The `f` argument must be iterable, returning one line at a time.
Optional second argument is the `source` specifying the name of the
file being read. If not given, it is taken from f.name. If `f` has no
`name` attribute, `<???>` i... | def read_file(self, f, source=None):
"""Like read() but the argument must be a file-like object.
The `f` argument must be iterable, returning one line at a time.
Optional second argument is the `source` specifying the name of the
file being read. If not given, it is taken from f.name. If `f` has no
... | (self, f, source=None) |
6,320 | configparser | read_string | Read configuration from a given string. | def read_string(self, string, source='<string>'):
"""Read configuration from a given string."""
sfile = io.StringIO(string)
self.read_file(sfile, source)
| (self, string, source='<string>') |
6,321 | configparser | readfp | Deprecated, use read_file instead. | def readfp(self, fp, filename=None):
"""Deprecated, use read_file instead."""
warnings.warn(
"This method will be removed in Python 3.12. "
"Use 'parser.read_file()' instead.",
DeprecationWarning, stacklevel=2
)
self.read_file(fp, source=filename)
| (self, fp, filename=None) |
6,322 | configparser | remove_option | Remove an option. | def remove_option(self, section, option):
"""Remove an option."""
if not section or section == self.default_section:
sectdict = self._defaults
else:
try:
sectdict = self._sections[section]
except KeyError:
raise NoSectionError(section) from None
option = s... | (self, section, option) |
6,323 | configparser | remove_section | Remove a file section. | def remove_section(self, section):
"""Remove a file section."""
existed = section in self._sections
if existed:
del self._sections[section]
del self._proxies[section]
return existed
| (self, section) |
6,324 | configparser | sections | Return a list of section names, excluding [DEFAULT] | def sections(self):
"""Return a list of section names, excluding [DEFAULT]"""
# self._sections will never have [DEFAULT] in it
return list(self._sections.keys())
| (self) |
6,325 | configparser | set | Set an option. Extends RawConfigParser.set by validating type and
interpolation syntax on the value. | def set(self, section, option, value=None):
"""Set an option. Extends RawConfigParser.set by validating type and
interpolation syntax on the value."""
self._validate_value_types(option=option, value=value)
super().set(section, option, value)
| (self, section, option, value=None) |
6,329 | configparser | write | Write an .ini-format representation of the configuration state.
If `space_around_delimiters` is True (the default), delimiters
between keys and values are surrounded by spaces.
Please note that comments in the original configuration file are not
preserved when writing the configuration... | def write(self, fp, space_around_delimiters=True):
"""Write an .ini-format representation of the configuration state.
If `space_around_delimiters` is True (the default), delimiters
between keys and values are surrounded by spaces.
Please note that comments in the original configuration file are not
... | (self, fp, space_around_delimiters=True) |
6,330 | collections.abc | MutableMapping | A MutableMapping is a generic container for associating
key/value pairs.
This class provides concrete generic implementations of all
methods except for __getitem__, __setitem__, __delitem__,
__iter__, and __len__.
| from collections.abc import MutableMapping
| () |
6,347 | bottle | DictProperty | Property that maps to a key in a local dict-like attribute. | class DictProperty(object):
''' Property that maps to a key in a local dict-like attribute. '''
def __init__(self, attr, key=None, read_only=False):
self.attr, self.key, self.read_only = attr, key, read_only
def __call__(self, func):
functools.update_wrapper(self, func, updated=[])
... | (attr, key=None, read_only=False) |
6,348 | bottle | __call__ | null | def __call__(self, func):
functools.update_wrapper(self, func, updated=[])
self.getter, self.key = func, self.key or func.__name__
return self
| (self, func) |
6,349 | bottle | __delete__ | null | def __delete__(self, obj):
if self.read_only: raise AttributeError("Read-Only property.")
del getattr(obj, self.attr)[self.key]
| (self, obj) |
6,350 | bottle | __get__ | null | def __get__(self, obj, cls):
if obj is None: return self
key, storage = self.key, getattr(obj, self.attr)
if key not in storage: storage[key] = self.getter(obj)
return storage[key]
| (self, obj, cls) |
6,351 | bottle | __init__ | null | def __init__(self, attr, key=None, read_only=False):
self.attr, self.key, self.read_only = attr, key, read_only
| (self, attr, key=None, read_only=False) |
6,352 | bottle | __set__ | null | def __set__(self, obj, value):
if self.read_only: raise AttributeError("Read-Only property.")
getattr(obj, self.attr)[self.key] = value
| (self, obj, value) |
6,353 | bottle | DieselServer | Untested. | class DieselServer(ServerAdapter):
""" Untested. """
def run(self, handler):
from diesel.protocols.wsgi import WSGIApplication
app = WSGIApplication(handler, port=self.port)
app.run()
| (host='127.0.0.1', port=8080, **options) |
6,356 | bottle | run | null | def run(self, handler):
from diesel.protocols.wsgi import WSGIApplication
app = WSGIApplication(handler, port=self.port)
app.run()
| (self, handler) |
6,357 | bottle | EventletServer | Untested | class EventletServer(ServerAdapter):
""" Untested """
def run(self, handler):
from eventlet import wsgi, listen
try:
wsgi.server(listen((self.host, self.port)), handler,
log_output=(not self.quiet))
except TypeError:
# Fallback, if we have ... | (host='127.0.0.1', port=8080, **options) |
6,360 | bottle | run | null | def run(self, handler):
from eventlet import wsgi, listen
try:
wsgi.server(listen((self.host, self.port)), handler,
log_output=(not self.quiet))
except TypeError:
# Fallback, if we have old version of eventlet
wsgi.server(listen((self.host, self.port)), handler)
| (self, handler) |
6,361 | bottle | FapwsServer | Extremely fast webserver using libev. See https://github.com/william-os4y/fapws3 | class FapwsServer(ServerAdapter):
""" Extremely fast webserver using libev. See https://github.com/william-os4y/fapws3 """
def run(self, handler): # pragma: no cover
import fapws._evwsgi as evwsgi
from fapws import base, config
port = self.port
if float(config.SERVER_IDENT[-2:]) ... | (host='127.0.0.1', port=8080, **options) |
6,364 | bottle | run | null | def run(self, handler): # pragma: no cover
import fapws._evwsgi as evwsgi
from fapws import base, config
port = self.port
if float(config.SERVER_IDENT[-2:]) > 0.4:
# fapws3 silently changed its API in 0.5
port = str(port)
evwsgi.start(self.host, port)
# fapws3 never releases the ... | (self, handler) |
6,365 | bottle | FileCheckerThread | Interrupt main-thread as soon as a changed module file is detected,
the lockfile gets deleted or gets to old. | class FileCheckerThread(threading.Thread):
''' Interrupt main-thread as soon as a changed module file is detected,
the lockfile gets deleted or gets to old. '''
def __init__(self, lockfile, interval):
threading.Thread.__init__(self)
self.lockfile, self.interval = lockfile, interval
... | (lockfile, interval) |
6,366 | bottle | __enter__ | null | def __enter__(self):
self.start()
| (self) |
6,367 | bottle | __exit__ | null | def __exit__(self, exc_type, exc_val, exc_tb):
if not self.status: self.status = 'exit' # silent exit
self.join()
return exc_type is not None and issubclass(exc_type, KeyboardInterrupt)
| (self, exc_type, exc_val, exc_tb) |
6,368 | bottle | __init__ | null | def __init__(self, lockfile, interval):
threading.Thread.__init__(self)
self.lockfile, self.interval = lockfile, interval
#: Is one of 'reload', 'error' or 'exit'
self.status = None
| (self, lockfile, interval) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.