_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q23800 | Provider._delete_record | train | def _delete_record(self, identifier=None, rtype=None, name=None, content=None):
"""Deletes an existing record"""
to_delete_ids = list()
if identifier:
to_delete_ids.append(identifier)
else:
for record in self._list_records(rtype=rtype, name=name, content=content):... | python | {
"resource": ""
} |
q23801 | Provider._create_request_record | train | def _create_request_record(self, identifier, rtype, name, content, ttl, priority): # pylint: disable=too-many-arguments
"""Creates record for Subreg API calls"""
record = collections.OrderedDict()
# Mandatory content
# Just for update - not for creation
if identifier is not No... | python | {
"resource": ""
} |
q23802 | Provider._create_response_record | train | def _create_response_record(self, response):
"""Creates record for lexicon API calls"""
record = dict()
record['id'] = response['id']
record['type'] = response['type']
record['name'] = self._full_name(response['name'])
if 'content' in response:
record['content... | python | {
"resource": ""
} |
q23803 | Provider._full_name | train | def _full_name(self, record_name):
"""Returns full domain name of a sub-domain name"""
# Handle None and empty strings
if not record_name: | python | {
"resource": ""
} |
q23804 | Provider._relative_name | train | def _relative_name(self, record_name):
"""Returns sub-domain of a domain name"""
# Handle None and empty strings as None
if not record_name:
return None
subdomain | python | {
"resource": ""
} |
q23805 | Provider._list_records_internal | train | def _list_records_internal(self, identifier=None, rtype=None, name=None, content=None):
"""Lists all records by the specified criteria"""
response = self._request_get_dns_zone()
if 'records' in response:
# Interpret empty string as None because zeep does so too
content_ch... | python | {
"resource": ""
} |
q23806 | Provider._guess_record | train | def _guess_record(self, rtype, name=None, content=None):
"""Tries to find existing unique record by type, name and content"""
records = self._list_records_internal(
identifier=None, rtype=rtype, name=name, content=content)
if len(records) == 1:
return records[0]
i... | python | {
"resource": ""
} |
q23807 | Provider._request_login | train | def _request_login(self, login, password):
"""Sends Login request"""
return self._request_internal("Login",
| python | {
"resource": ""
} |
q23808 | Provider._request_add_dns_record | train | def _request_add_dns_record(self, record):
"""Sends Add_DNS_Record request"""
return self._request_internal("Add_DNS_Record",
| python | {
"resource": ""
} |
q23809 | Provider._request_modify_dns_record | train | def _request_modify_dns_record(self, record):
"""Sends Modify_DNS_Record request"""
return self._request_internal("Modify_DNS_Record",
| python | {
"resource": ""
} |
q23810 | Provider._request_delete_dns_record_by_id | train | def _request_delete_dns_record_by_id(self, identifier):
"""Sends Delete_DNS_Record request"""
return self._request_internal("Delete_DNS_Record",
| python | {
"resource": ""
} |
q23811 | Provider._request_internal | train | def _request_internal(self, command, **kwargs):
"""Make request parse response"""
args = dict(kwargs)
if self.ssid:
args['ssid'] = self.ssid
method = getattr(self.api, command)
response = method(**args)
if response and 'status' in response:
if resp... | python | {
"resource": ""
} |
q23812 | Provider._authenticate | train | def _authenticate(self):
"""
The Namecheap API is a little difficult to work with.
Originally this method called PyNamecheap's `domains_getList`, which is
connected to an API endpoint that only lists domains registered under
the authenticating account. However, an authenticating ... | python | {
"resource": ""
} |
q23813 | Provider._convert_to_namecheap | train | def _convert_to_namecheap(self, record):
""" converts from lexicon format record to namecheap format record,
suitable to sending through the api to namecheap"""
name = record['name']
if name.endswith('.'):
| python | {
"resource": ""
} |
q23814 | Provider._convert_to_lexicon | train | def _convert_to_lexicon(self, record):
""" converts from namecheap raw record format to lexicon format record
"""
name = record['Name']
if self.domain not in name:
name = "{}.{}".format(name, self.domain)
processed_record = {
'type': record['Type'],
... | python | {
"resource": ""
} |
q23815 | Provider._authenticate | train | def _authenticate(self):
"""An innocent call to check that the credentials are okay."""
| python | {
"resource": ""
} |
q23816 | Provider._create_record | train | def _create_record(self, rtype, name, content):
"""Create record if doesnt already exist with same content"""
# check if record already exists
existing_records = self._list_records(rtype, name, content)
if len(existing_records) >= 1:
return True
record = {
... | python | {
"resource": ""
} |
q23817 | Provider._list_records | train | def _list_records(self, rtype=None, name=None, content=None):
"""List all records.
record_type, name and content are used to filter the records.
If possible it filters during the query, otherwise afterwards.
An empty list is returned if no records are found.
"""
filter_... | python | {
"resource": ""
} |
q23818 | Provider._delete_record | train | def _delete_record(self, identifier=None, rtype=None, name=None, content=None):
"""Delete an existing record.
If the record doesn't exist, does nothing.
"""
if not identifier:
records = self._list_records(rtype, name, content)
identifiers = [record["id"] for reco... | python | {
"resource": ""
} |
q23819 | provider_parser | train | def provider_parser(subparser):
"""Configure provider parser for auto provider"""
subparser.description = '''
Provider 'auto' enables the Lexicon provider auto-discovery.
Based on the nameservers declared for the given domain,
Lexicon will try to find the DNS provider holding the DNS zon... | python | {
"resource": ""
} |
q23820 | generate_base_provider_parser | train | def generate_base_provider_parser():
"""Function that generates the base provider to be used by all dns providers."""
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('action', help='specify the action to take', default='list',
choices=['create', 'list', 'update',... | python | {
"resource": ""
} |
q23821 | generate_cli_main_parser | train | def generate_cli_main_parser():
"""Using all providers available, generate a parser that will be used by Lexicon CLI"""
parser = argparse.ArgumentParser(
description='Create, Update, Delete, List DNS entries')
parser.add_argument('--version', help='show the current version of lexicon',
... | python | {
"resource": ""
} |
q23822 | Provider._create_record | train | def _create_record(self, rtype, name, content):
"""
Create a resource record. If a record already exists with the same
content, do nothing.
"""
result = False
name = self._relative_name(name)
ttl = None
| python | {
"resource": ""
} |
q23823 | Provider._list_records | train | def _list_records(self, rtype=None, name=None, content=None):
"""
Return a list of records matching the supplied params. If no params are
provided, then return all zone records. If no records are found, return
an empty list.
"""
if name:
name = self._relative_... | python | {
"resource": ""
} |
q23824 | Provider._update_record | train | def _update_record(self, identifier, rtype=None, name=None, content=None):
"""
Update a record. Returns `False` if no matching record is found.
"""
result = False
# TODO: some providers allow content-based updates without supplying an
# ID, and therefore `identifier` is ... | python | {
"resource": ""
} |
q23825 | set_random_state | train | def set_random_state(state):
"""Force-set the state of factory.fuzzy's random generator."""
randgen.state_set = True
| python | {
"resource": ""
} |
q23826 | reseed_random | train | def reseed_random(seed):
"""Reseed factory.fuzzy's random generator."""
r = random.Random(seed)
| python | {
"resource": ""
} |
q23827 | get_model | train | def get_model(app, model):
"""Wrapper around django's get_model."""
if 'get_model' not | python | {
"resource": ""
} |
q23828 | _lazy_load_get_model | train | def _lazy_load_get_model():
"""Lazy loading of get_model.
get_model loads django.conf.settings, which may fail if
the settings haven't been configured yet.
"""
if django is None:
def _get_model(app, model):
| python | {
"resource": ""
} |
q23829 | DjangoModelFactory._get_or_create | train | def _get_or_create(cls, model_class, *args, **kwargs):
"""Create an instance of the model through objects.get_or_create."""
manager = cls._get_manager(model_class)
assert 'defaults' not in cls._meta.django_get_or_create, (
"'defaults' is a reserved keyword for get_or_create "
... | python | {
"resource": ""
} |
q23830 | FileField.generate | train | def generate(self, step, params):
"""Fill in the field."""
# Recurse into a DictFactory: allows users to have some params depending
# on others.
| python | {
"resource": ""
} |
q23831 | import_object | train | def import_object(module_name, attribute_name):
"""Import an object from its absolute path.
Example:
>>> import_object('datetime', 'datetime')
| python | {
"resource": ""
} |
q23832 | sort_ordered_objects | train | def sort_ordered_objects(items, getter=lambda x: x):
"""Sort an iterable of OrderedBase instances.
Args:
items (iterable): the objects to sort
getter (callable or None): a function to extract the OrderedBase instance from an object.
Examples:
>>> sort_ordered_objects([x, y, z])
... | python | {
"resource": ""
} |
q23833 | resolve_attribute | train | def resolve_attribute(name, bases, default=None):
"""Find the first definition of an attribute according to MRO order."""
for base in bases:
| python | {
"resource": ""
} |
q23834 | use_strategy | train | def use_strategy(new_strategy):
"""Force the use of a different strategy.
This is an alternative to setting default_strategy in the class definition.
"""
def wrapped_class(klass):
| python | {
"resource": ""
} |
q23835 | FactoryOptions._build_default_options | train | def _build_default_options(self):
""""Provide the default value for all allowed fields.
Custom FactoryOptions classes should override this method
to update() its return value.
"""
return [
OptionDefault('model', None, | python | {
"resource": ""
} |
q23836 | FactoryOptions._get_counter_reference | train | def _get_counter_reference(self):
"""Identify which factory should be used for a shared counter."""
if (self.model is not None
and self.base_factory is not None
and self.base_factory._meta.model is not None
| python | {
"resource": ""
} |
q23837 | FactoryOptions._initialize_counter | train | def _initialize_counter(self):
"""Initialize our counter pointer.
If we're the top-level factory, instantiate a new counter
Otherwise, point to the top-level factory's counter.
"""
if self._counter is not None:
return
| python | {
"resource": ""
} |
q23838 | FactoryOptions._is_declaration | train | def _is_declaration(self, name, value):
"""Determines if a class attribute is a field value declaration.
Based on the name and value of the class attribute, return ``True`` if
it looks like a declaration of a default field value, ``False`` if it
is private (name starts with '_') or a cl... | python | {
"resource": ""
} |
q23839 | FactoryOptions._check_parameter_dependencies | train | def _check_parameter_dependencies(self, parameters):
"""Find out in what order parameters should be called."""
# Warning: parameters only provide reverse dependencies; we reverse them into standard dependencies.
# deep_revdeps: set of fields a field depend indirectly upon
deep_revdeps = ... | python | {
"resource": ""
} |
q23840 | BaseFactory.reset_sequence | train | def reset_sequence(cls, value=None, force=False):
"""Reset the sequence counter.
Args:
value (int or None): the new 'next' sequence value; if None,
recompute the next value from _setup_next_sequence().
force (bool): | python | {
"resource": ""
} |
q23841 | BaseFactory.attributes | train | def attributes(cls, create=False, extra=None):
"""Build a dict of attribute values, respecting declaration order.
The process is:
- Handle 'orderless' attributes, overriding defaults with provided
kwargs when applicable
- Handle ordered attributes, overriding them with provi... | python | {
"resource": ""
} |
q23842 | BaseFactory.declarations | train | def declarations(cls, extra_defs=None):
"""Retrieve a copy of the declared attributes.
Args:
extra_defs (dict): additional definitions to insert into the
retrieved DeclarationDict.
"""
warnings.warn(
"Factory.declarations is deprecated; use Factor... | python | {
"resource": ""
} |
q23843 | BaseFactory._generate | train | def _generate(cls, strategy, params):
"""generate the object.
Args:
params (dict): attributes to use for generating the object
strategy: the strategy to use
"""
if cls._meta.abstract:
raise errors.FactoryError(
"Cannot generate instanc... | python | {
"resource": ""
} |
q23844 | BaseFactory.build_batch | train | def build_batch(cls, size, **kwargs):
"""Build a batch of instances of the given class, with overriden attrs.
Args:
size (int): the number of instances to build
Returns:
| python | {
"resource": ""
} |
q23845 | BaseFactory.create_batch | train | def create_batch(cls, size, **kwargs):
"""Create a batch of instances of the given class, with overriden attrs.
Args:
size (int): the number of instances to create
Returns:
| python | {
"resource": ""
} |
q23846 | BaseFactory.stub_batch | train | def stub_batch(cls, size, **kwargs):
"""Stub a batch of instances of the given class, with overriden attrs.
Args:
size (int): the number of instances to stub
Returns:
| python | {
"resource": ""
} |
q23847 | make_factory | train | def make_factory(klass, **kwargs):
"""Create a new, simple factory for the given class."""
factory_name = '%sFactory' % klass.__name__
class Meta:
model = klass
kwargs['Meta'] = Meta
| python | {
"resource": ""
} |
q23848 | generate_batch | train | def generate_batch(klass, strategy, size, **kwargs):
"""Create a factory for the given class, and generate instances."""
| python | {
"resource": ""
} |
q23849 | simple_generate_batch | train | def simple_generate_batch(klass, create, size, **kwargs):
"""Create a factory for the given class, and simple_generate instances."""
| python | {
"resource": ""
} |
q23850 | deepgetattr | train | def deepgetattr(obj, name, default=_UNSPECIFIED):
"""Try to retrieve the given attribute of an object, digging on '.'.
This is an extended getattr, digging deeper if '.' is found.
Args:
obj (object): the object of which an attribute should be read
name (str): the name of an attribute to lo... | python | {
"resource": ""
} |
q23851 | ContainerAttribute.evaluate | train | def evaluate(self, instance, step, extra):
"""Evaluate the current ContainerAttribute.
Args:
obj (LazyStub): a lazy stub of the object being constructed, if
needed.
containers (list of LazyStub): a list of lazy stubs of factories
being evaluated i... | python | {
"resource": ""
} |
q23852 | DeclarationSet.join | train | def join(cls, root, subkey):
"""Rebuild a full declaration name from its components.
for every string x, we have `join(split(x)) == x`.
"""
| python | {
"resource": ""
} |
q23853 | StepBuilder.build | train | def build(self, parent_step=None, force_sequence=None):
"""Build a factory instance."""
# TODO: Handle "batch build" natively
pre, post = parse_declarations(
self.extras,
base_pre=self.factory_meta.pre_declarations,
base_post=self.factory_meta.post_declaration... | python | {
"resource": ""
} |
q23854 | StepBuilder.recurse | train | def recurse(self, factory_meta, extras):
"""Recurse into a sub-factory call."""
| python | {
"resource": ""
} |
q23855 | parse | train | def parse(code, mode='exec', **exception_kwargs):
"""Parse an expression into AST"""
try:
return _ast_util.parse(code, '<unknown>', mode)
except Exception:
raise exceptions.SyntaxException(
"(%s) %s (%r)" % (
| python | {
"resource": ""
} |
q23856 | tokenize | train | def tokenize(expr):
"""
Parse a string expression into a set of tokens that can be used as a path
into a Python datastructure.
"""
tokens = []
escape = False
cur_token = ''
for c in expr:
if escape == True:
cur_token += c
escape = False
else:
... | python | {
"resource": ""
} |
q23857 | compile | train | def compile(node,
uri,
filename=None,
default_filters=None,
buffer_filters=None,
imports=None,
future_imports=None,
source_encoding=None,
generate_magic_comment=True,
disable_u... | python | {
"resource": ""
} |
q23858 | mangle_mako_loop | train | def mangle_mako_loop(node, printer):
"""converts a for loop into a context manager wrapped around a for loop
when access to the `loop` variable has been detected in the for loop body
"""
loop_variable = LoopVariable()
node.accept_visitor(loop_variable)
if loop_variable.detected:
node.nod... | python | {
"resource": ""
} |
q23859 | _GenerateRenderMethod.write_render_callable | train | def write_render_callable(self, node, name, args, buffered, filtered,
cached):
"""write a top-level render callable.
this could be the main render() method or that of a top-level def."""
if self.in_def:
decorator = node.decorator
if decorator:
... | python | {
"resource": ""
} |
q23860 | _GenerateRenderMethod.write_namespaces | train | def write_namespaces(self, namespaces):
"""write the module-level namespace-generating callable."""
self.printer.writelines(
"def _mako_get_namespace(context, name):",
"try:",
"return context.namespaces[(__name__, name)]",
"except KeyError:... | python | {
"resource": ""
} |
q23861 | _GenerateRenderMethod.write_variable_declares | train | def write_variable_declares(self, identifiers, toplevel=False, limit=None):
"""write variable declarations at the top of a function.
the variable declarations are in the form of callable
definitions for defs and/or name lookup within the
function's context argument. the names declared a... | python | {
"resource": ""
} |
q23862 | _GenerateRenderMethod.write_def_decl | train | def write_def_decl(self, node, identifiers):
"""write a locally-available callable referencing a top-level def"""
funcname = node.funcname
namedecls = node.get_argument_expressions()
nameargs = node.get_argument_expressions(as_call=True)
if not self.in_def and (
... | python | {
"resource": ""
} |
q23863 | _GenerateRenderMethod.write_inline_def | train | def write_inline_def(self, node, identifiers, nested):
"""write a locally-available def callable inside an enclosing def."""
namedecls = node.get_argument_expressions()
decorator = node.decorator
if decorator:
self.printer.writeline(
"@runtime._decor... | python | {
"resource": ""
} |
q23864 | _GenerateRenderMethod.write_def_finish | train | def write_def_finish(self, node, buffered, filtered, cached,
callstack=True):
"""write the end section of a rendering function, either outermost or
inline.
this takes into account if the rendering function was filtered,
buffered, etc. and closes the corresponding try: block... | python | {
"resource": ""
} |
q23865 | _GenerateRenderMethod.write_cache_decorator | train | def write_cache_decorator(self, node_or_pagetag, name,
args, buffered, identifiers,
inline=False, toplevel=False):
"""write a post-function decorator to replace a rendering
callable with a cached version of itself."""
s... | python | {
"resource": ""
} |
q23866 | _GenerateRenderMethod.create_filter_callable | train | def create_filter_callable(self, args, target, is_expression):
"""write a filter-applying expression based on the filters
present in the given filter names, adjusting for the global
'default' filter aliases as needed."""
def locate_encode(name):
if re.match(r'decode\..+', na... | python | {
"resource": ""
} |
q23867 | _Identifiers.branch | train | def branch(self, node, **kwargs):
"""create a new Identifiers for a new Node, with
this Identifiers as the parent."""
| python | {
"resource": ""
} |
q23868 | _Identifiers.check_declared | train | def check_declared(self, node):
"""update the state of this Identifiers with the undeclared
and declared identifiers of the given node."""
for ident in node.undeclared_identifiers():
if ident != 'context' and\
| python | {
"resource": ""
} |
q23869 | HostsParser._parse_line_entry | train | def _parse_line_entry(self, line, type):
"""
Parse a section entry line into its components. In case of a 'vars'
section, the first field will be None. Otherwise, the first field will
be the unexpanded host or group name the variables apply to.
For example:
[producti... | python | {
"resource": ""
} |
q23870 | HostsParser._parse_vars | train | def _parse_vars(self, tokens):
"""
Given an iterable of tokens, returns variables and their values as a
dictionary.
For example:
['dtap=prod', 'comment=some comment']
Returns:
{'dtap': 'prod', 'comment': 'some comment'}
"""
key_values = {}... | python | {
"resource": ""
} |
q23871 | HostsParser._get_distinct_hostnames | train | def _get_distinct_hostnames(self):
"""
Return a set of distinct hostnames found in the entire inventory.
"""
hostnames = []
for section in self.sections:
| python | {
"resource": ""
} |
q23872 | HostsParser._apply_section | train | def _apply_section(self, section, hosts):
"""
Recursively find all the hosts that belong in or under a section and
add the section's group name and variables to every host.
"""
# Add the current group name to each host that this section covers.
if section['name'] is not N... | python | {
"resource": ""
} |
q23873 | HostsParser._apply_section_hosts | train | def _apply_section_hosts(self, section, hosts):
"""
Add the variables for each entry in a 'hosts' section to the hosts
belonging to that entry.
"""
for entry in section['entries']:
for hostname in self.expand_hostdef(entry['name']):
if hostname not in ... | python | {
"resource": ""
} |
q23874 | HostsParser._apply_section_children | train | def _apply_section_children(self, section, hosts):
"""
Add the variables for each entry in a 'children' section to the hosts
belonging to that entry.
"""
for entry in section['entries']:
for hostname in self._group_get_hostnames(entry['name']):
| python | {
"resource": ""
} |
q23875 | HostsParser._group_get_hostnames | train | def _group_get_hostnames(self, group_name):
"""
Recursively fetch a list of each unique hostname that belongs in or
under the group. This includes hosts in children groups.
"""
hostnames = []
hosts_section = self._get_section(group_name, 'hosts')
if hosts_section... | python | {
"resource": ""
} |
q23876 | HostsParser._get_section | train | def _get_section(self, name, type):
"""
Find and return a section with `name` and `type`
| python | {
"resource": ""
} |
q23877 | DynInvParser._get_host | train | def _get_host(self, hostname):
"""
Get an existing host or otherwise initialize a new empty one.
"""
if hostname not in self.hosts:
self.hosts[hostname] = {
| python | {
"resource": ""
} |
q23878 | DynInvParser._parse_meta | train | def _parse_meta(self, meta):
"""
Parse the _meta element from a dynamic host inventory output.
"""
for hostname, hostvars in meta.get('hostvars', {}).items():
| python | {
"resource": ""
} |
q23879 | dump | train | def dump(node):
"""
A very verbose representation of the node passed. This is useful for
debugging purposes.
"""
def _format(node):
if isinstance(node, AST):
return '%s(%s)' % (node.__class__.__name__,
', '.join('%s=%s' % (a, _format(b))
... | python | {
"resource": ""
} |
q23880 | fix_missing_locations | train | def fix_missing_locations(node):
"""
Some nodes require a line number and the column offset. Without that
information the compiler will abort the compilation. Because it can be
a dull task to add appropriate line numbers and column offsets when
adding new nodes this function can help. It copies t... | python | {
"resource": ""
} |
q23881 | increment_lineno | train | def increment_lineno(node, n=1):
"""
Increment the line numbers of all nodes by `n` if they have line number
attributes. This is useful to "move code" to a different location in a
file.
| python | {
"resource": ""
} |
q23882 | iter_fields | train | def iter_fields(node):
"""Iterate over all fields of a node, only yielding existing fields."""
# CPython 2.5 compat
if not hasattr(node, '_fields') or not node._fields:
return
| python | {
"resource": ""
} |
q23883 | iter_child_nodes | train | def iter_child_nodes(node):
"""Iterate over all child nodes or a node."""
for name, field in iter_fields(node):
if isinstance(field, AST): | python | {
"resource": ""
} |
q23884 | get_docstring | train | def get_docstring(node):
"""
Return the docstring for the given node or `None` if no docstring can be
found. If the node provided does not accept docstrings a `TypeError`
| python | {
"resource": ""
} |
q23885 | walk | train | def walk(node):
"""
Iterate over all nodes. This is useful if you only want to modify nodes in
place and don't care about the context or the order the nodes are returned.
"""
from collections | python | {
"resource": ""
} |
q23886 | Lexer.match_reg | train | def match_reg(self, reg):
"""match the given regular expression object to the current text
position.
if a match occurs, update the current text and line position.
"""
mp = self.match_position
match = reg.match(self.text, self.match_position)
if match:
... | python | {
"resource": ""
} |
q23887 | Lexer.match_comment | train | def match_comment(self):
"""matches the multiline version of a comment"""
match = self.match(r"<%doc>(.*?)</%doc>", re.S)
if match:
| python | {
"resource": ""
} |
q23888 | extract | train | def extract(fileobj, keywords, comment_tags, options):
"""Extract messages from Mako templates.
:param fileobj: the file-like object the messages should be extracted from
:param keywords: a list of keywords (i.e. function names) that should be
recognized as translation functions
| python | {
"resource": ""
} |
q23889 | ControlLine.is_ternary | train | def is_ternary(self, keyword):
"""return true if the given keyword is a ternary keyword
for this ControlLine"""
return keyword in {
'if':set(['else', 'elif']),
| python | {
"resource": ""
} |
q23890 | Cache.set | train | def set(self, key, value, **kw):
"""Place a value in the cache.
:param key: the value's key.
:param value: the value.
| python | {
"resource": ""
} |
q23891 | Cache.get | train | def get(self, key, **kw):
"""Retrieve a value from the cache.
:param key: the value's key.
:param \**kw: cache configuration arguments. The
backend is configured using these arguments upon first request.
| python | {
"resource": ""
} |
q23892 | Cache.invalidate | train | def invalidate(self, key, **kw):
"""Invalidate a value in the cache.
:param key: the value's key.
:param \**kw: cache configuration arguments. The
| python | {
"resource": ""
} |
q23893 | supports_caller | train | def supports_caller(func):
"""Apply a caller_stack compatibility decorator to a plain
Python function.
See the example in :ref:`namespaces_python_modules`.
"""
def wrap_stackframe(context, *args, **kwargs):
context.caller_stack._push_frame()
try:
| python | {
"resource": ""
} |
q23894 | capture | train | def capture(context, callable_, *args, **kwargs):
"""Execute the given template def, capturing the output into
a buffer.
See the example in :ref:`namespaces_python_modules`.
"""
if not compat.callable(callable_):
| python | {
"resource": ""
} |
q23895 | _include_file | train | def _include_file(context, uri, calling_uri, **kwargs):
"""locate the template from the given uri and include it in
the current output."""
template = _lookup_template(context, uri, calling_uri)
(callable_, ctx) = _populate_self_namespace(
| python | {
"resource": ""
} |
q23896 | _inherit_from | train | def _inherit_from(context, uri, calling_uri):
"""called by the _inherit method in template modules to set
up the inheritance chain at the start of a template's
execution."""
if uri is None:
return None
template = _lookup_template(context, uri, calling_uri)
self_ns = context['self']
... | python | {
"resource": ""
} |
q23897 | _render | train | def _render(template, callable_, args, data, as_unicode=False):
"""create a Context and return the string
output of the given template and template callable."""
if as_unicode:
buf = util.FastEncodingBuffer(as_unicode=True)
elif template.bytestring_passthrough:
buf = compat.StringIO()
... | python | {
"resource": ""
} |
q23898 | _exec_template | train | def _exec_template(callable_, context, args=None, kwargs=None):
"""execute a rendering callable given the callable, a
Context, and optional explicit arguments
the contextual Template will be located if it exists, and
the error handling options specified on that Template will
be interpreted here.
| python | {
"resource": ""
} |
q23899 | Context._push_writer | train | def _push_writer(self):
"""push a capturing buffer onto this Context and return
the new writer function."""
buf | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.