partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Identifiers.is_declared | Check if a name is declared in this or an outer scope. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def is_declared(self, name, local_only=False):
"""Check if a name is declared in this or an outer scope."""
if name in self.declared_locally or name in self.declared_parameter:
return True
if local_only:
return False
return name in self.declared | def is_declared(self, name, local_only=False):
"""Check if a name is declared in this or an outer scope."""
if name in self.declared_locally or name in self.declared_parameter:
return True
if local_only:
return False
return name in self.declared | [
"Check",
"if",
"a",
"name",
"is",
"declared",
"in",
"this",
"or",
"an",
"outer",
"scope",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L130-L136 | [
"def",
"is_declared",
"(",
"self",
",",
"name",
",",
"local_only",
"=",
"False",
")",
":",
"if",
"name",
"in",
"self",
".",
"declared_locally",
"or",
"name",
"in",
"self",
".",
"declared_parameter",
":",
"return",
"True",
"if",
"local_only",
":",
"return",... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Frame.copy | Create a copy of the current one. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def copy(self):
"""Create a copy of the current one."""
rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.identifiers = object.__new__(self.identifiers.__class__)
rv.identifiers.__dict__.update(self.identifiers.__dict__)
return rv | def copy(self):
"""Create a copy of the current one."""
rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.identifiers = object.__new__(self.identifiers.__class__)
rv.identifiers.__dict__.update(self.identifiers.__dict__)
return rv | [
"Create",
"a",
"copy",
"of",
"the",
"current",
"one",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L188-L194 | [
"def",
"copy",
"(",
"self",
")",
":",
"rv",
"=",
"object",
".",
"__new__",
"(",
"self",
".",
"__class__",
")",
"rv",
".",
"__dict__",
".",
"update",
"(",
"self",
".",
"__dict__",
")",
"rv",
".",
"identifiers",
"=",
"object",
".",
"__new__",
"(",
"s... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Frame.find_shadowed | Find all the shadowed names. extra is an iterable of variables
that may be defined with `add_special` which may occour scoped. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def find_shadowed(self, extra=()):
"""Find all the shadowed names. extra is an iterable of variables
that may be defined with `add_special` which may occour scoped.
"""
i = self.identifiers
return (i.declared | i.outer_undeclared) & \
(i.declared_locally | i.decla... | def find_shadowed(self, extra=()):
"""Find all the shadowed names. extra is an iterable of variables
that may be defined with `add_special` which may occour scoped.
"""
i = self.identifiers
return (i.declared | i.outer_undeclared) & \
(i.declared_locally | i.decla... | [
"Find",
"all",
"the",
"shadowed",
"names",
".",
"extra",
"is",
"an",
"iterable",
"of",
"variables",
"that",
"may",
"be",
"defined",
"with",
"add_special",
"which",
"may",
"occour",
"scoped",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L205-L212 | [
"def",
"find_shadowed",
"(",
"self",
",",
"extra",
"=",
"(",
")",
")",
":",
"i",
"=",
"self",
".",
"identifiers",
"return",
"(",
"i",
".",
"declared",
"|",
"i",
".",
"outer_undeclared",
")",
"&",
"(",
"i",
".",
"declared_locally",
"|",
"i",
".",
"d... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.blockvisit | Visit a list of nodes as block in a frame. If the current frame
is no buffer a dummy ``if 0: yield None`` is written automatically
unless the force_generator parameter is set to False. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def blockvisit(self, nodes, frame):
"""Visit a list of nodes as block in a frame. If the current frame
is no buffer a dummy ``if 0: yield None`` is written automatically
unless the force_generator parameter is set to False.
"""
if frame.buffer is None:
self.writeline... | def blockvisit(self, nodes, frame):
"""Visit a list of nodes as block in a frame. If the current frame
is no buffer a dummy ``if 0: yield None`` is written automatically
unless the force_generator parameter is set to False.
"""
if frame.buffer is None:
self.writeline... | [
"Visit",
"a",
"list",
"of",
"nodes",
"as",
"block",
"in",
"a",
"frame",
".",
"If",
"the",
"current",
"frame",
"is",
"no",
"buffer",
"a",
"dummy",
"if",
"0",
":",
"yield",
"None",
"is",
"written",
"automatically",
"unless",
"the",
"force_generator",
"para... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L482-L495 | [
"def",
"blockvisit",
"(",
"self",
",",
"nodes",
",",
"frame",
")",
":",
"if",
"frame",
".",
"buffer",
"is",
"None",
":",
"self",
".",
"writeline",
"(",
"'if 0: yield None'",
")",
"else",
":",
"self",
".",
"writeline",
"(",
"'pass'",
")",
"try",
":",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.pull_locals | Pull all the references identifiers into the local scope. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def pull_locals(self, frame):
"""Pull all the references identifiers into the local scope."""
for name in frame.identifiers.undeclared:
self.writeline('l_%s = context.resolve(%r)' % (name, name)) | def pull_locals(self, frame):
"""Pull all the references identifiers into the local scope."""
for name in frame.identifiers.undeclared:
self.writeline('l_%s = context.resolve(%r)' % (name, name)) | [
"Pull",
"all",
"the",
"references",
"identifiers",
"into",
"the",
"local",
"scope",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L577-L580 | [
"def",
"pull_locals",
"(",
"self",
",",
"frame",
")",
":",
"for",
"name",
"in",
"frame",
".",
"identifiers",
".",
"undeclared",
":",
"self",
".",
"writeline",
"(",
"'l_%s = context.resolve(%r)'",
"%",
"(",
"name",
",",
"name",
")",
")"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.unoptimize_scope | Disable Python optimizations for the frame. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def unoptimize_scope(self, frame):
"""Disable Python optimizations for the frame."""
# XXX: this is not that nice but it has no real overhead. It
# mainly works because python finds the locals before dead code
# is removed. If that breaks we have to add a dummy function
# that ... | def unoptimize_scope(self, frame):
"""Disable Python optimizations for the frame."""
# XXX: this is not that nice but it has no real overhead. It
# mainly works because python finds the locals before dead code
# is removed. If that breaks we have to add a dummy function
# that ... | [
"Disable",
"Python",
"optimizations",
"for",
"the",
"frame",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L595-L605 | [
"def",
"unoptimize_scope",
"(",
"self",
",",
"frame",
")",
":",
"# XXX: this is not that nice but it has no real overhead. It",
"# mainly works because python finds the locals before dead code",
"# is removed. If that breaks we have to add a dummy function",
"# that just accepts the argument... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.push_scope | This function returns all the shadowed variables in a dict
in the form name: alias and will write the required assignments
into the current scope. No indentation takes place.
This also predefines locally declared variables from the loop
body because under some circumstances it may be t... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def push_scope(self, frame, extra_vars=()):
"""This function returns all the shadowed variables in a dict
in the form name: alias and will write the required assignments
into the current scope. No indentation takes place.
This also predefines locally declared variables from the loop
... | def push_scope(self, frame, extra_vars=()):
"""This function returns all the shadowed variables in a dict
in the form name: alias and will write the required assignments
into the current scope. No indentation takes place.
This also predefines locally declared variables from the loop
... | [
"This",
"function",
"returns",
"all",
"the",
"shadowed",
"variables",
"in",
"a",
"dict",
"in",
"the",
"form",
"name",
":",
"alias",
"and",
"will",
"write",
"the",
"required",
"assignments",
"into",
"the",
"current",
"scope",
".",
"No",
"indentation",
"takes"... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L607-L627 | [
"def",
"push_scope",
"(",
"self",
",",
"frame",
",",
"extra_vars",
"=",
"(",
")",
")",
":",
"aliases",
"=",
"{",
"}",
"for",
"name",
"in",
"frame",
".",
"find_shadowed",
"(",
"extra_vars",
")",
":",
"aliases",
"[",
"name",
"]",
"=",
"ident",
"=",
"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.pop_scope | Restore all aliases and delete unused variables. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def pop_scope(self, aliases, frame):
"""Restore all aliases and delete unused variables."""
for name, alias in aliases.iteritems():
self.writeline('l_%s = %s' % (name, alias))
to_delete = set()
for name in frame.identifiers.declared_locally:
if name not in aliases... | def pop_scope(self, aliases, frame):
"""Restore all aliases and delete unused variables."""
for name, alias in aliases.iteritems():
self.writeline('l_%s = %s' % (name, alias))
to_delete = set()
for name in frame.identifiers.declared_locally:
if name not in aliases... | [
"Restore",
"all",
"aliases",
"and",
"delete",
"unused",
"variables",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L629-L641 | [
"def",
"pop_scope",
"(",
"self",
",",
"aliases",
",",
"frame",
")",
":",
"for",
"name",
",",
"alias",
"in",
"aliases",
".",
"iteritems",
"(",
")",
":",
"self",
".",
"writeline",
"(",
"'l_%s = %s'",
"%",
"(",
"name",
",",
"alias",
")",
")",
"to_delete... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.function_scoping | In Jinja a few statements require the help of anonymous
functions. Those are currently macros and call blocks and in
the future also recursive loops. As there is currently
technical limitation that doesn't allow reading and writing a
variable in a scope where the initial value is comin... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def function_scoping(self, node, frame, children=None,
find_special=True):
"""In Jinja a few statements require the help of anonymous
functions. Those are currently macros and call blocks and in
the future also recursive loops. As there is currently
technical l... | def function_scoping(self, node, frame, children=None,
find_special=True):
"""In Jinja a few statements require the help of anonymous
functions. Those are currently macros and call blocks and in
the future also recursive loops. As there is currently
technical l... | [
"In",
"Jinja",
"a",
"few",
"statements",
"require",
"the",
"help",
"of",
"anonymous",
"functions",
".",
"Those",
"are",
"currently",
"macros",
"and",
"call",
"blocks",
"and",
"in",
"the",
"future",
"also",
"recursive",
"loops",
".",
"As",
"there",
"is",
"c... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L643-L710 | [
"def",
"function_scoping",
"(",
"self",
",",
"node",
",",
"frame",
",",
"children",
"=",
"None",
",",
"find_special",
"=",
"True",
")",
":",
"# we have to iterate twice over it, make sure that works",
"if",
"children",
"is",
"None",
":",
"children",
"=",
"node",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.macro_body | Dump the function def of a macro or call block. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def macro_body(self, node, frame, children=None):
"""Dump the function def of a macro or call block."""
frame = self.function_scoping(node, frame, children)
# macros are delayed, they never require output checks
frame.require_output_check = False
args = frame.arguments
# ... | def macro_body(self, node, frame, children=None):
"""Dump the function def of a macro or call block."""
frame = self.function_scoping(node, frame, children)
# macros are delayed, they never require output checks
frame.require_output_check = False
args = frame.arguments
# ... | [
"Dump",
"the",
"function",
"def",
"of",
"a",
"macro",
"or",
"call",
"block",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L712-L734 | [
"def",
"macro_body",
"(",
"self",
",",
"node",
",",
"frame",
",",
"children",
"=",
"None",
")",
":",
"frame",
"=",
"self",
".",
"function_scoping",
"(",
"node",
",",
"frame",
",",
"children",
")",
"# macros are delayed, they never require output checks",
"frame"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.macro_def | Dump the macro definition for the def created by macro_body. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def macro_def(self, node, frame):
"""Dump the macro definition for the def created by macro_body."""
arg_tuple = ', '.join(repr(x.name) for x in node.args)
name = getattr(node, 'name', None)
if len(node.args) == 1:
arg_tuple += ','
self.write('Macro(environment, macro... | def macro_def(self, node, frame):
"""Dump the macro definition for the def created by macro_body."""
arg_tuple = ', '.join(repr(x.name) for x in node.args)
name = getattr(node, 'name', None)
if len(node.args) == 1:
arg_tuple += ','
self.write('Macro(environment, macro... | [
"Dump",
"the",
"macro",
"definition",
"for",
"the",
"def",
"created",
"by",
"macro_body",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L736-L751 | [
"def",
"macro_def",
"(",
"self",
",",
"node",
",",
"frame",
")",
":",
"arg_tuple",
"=",
"', '",
".",
"join",
"(",
"repr",
"(",
"x",
".",
"name",
")",
"for",
"x",
"in",
"node",
".",
"args",
")",
"name",
"=",
"getattr",
"(",
"node",
",",
"'name'",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.visit_Block | Call a block and register it for the template. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def visit_Block(self, node, frame):
"""Call a block and register it for the template."""
level = 1
if frame.toplevel:
# if we know that we are a child template, there is no need to
# check if we are one
if self.has_known_extends:
return
... | def visit_Block(self, node, frame):
"""Call a block and register it for the template."""
level = 1
if frame.toplevel:
# if we know that we are a child template, there is no need to
# check if we are one
if self.has_known_extends:
return
... | [
"Call",
"a",
"block",
"and",
"register",
"it",
"for",
"the",
"template",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L861-L878 | [
"def",
"visit_Block",
"(",
"self",
",",
"node",
",",
"frame",
")",
":",
"level",
"=",
"1",
"if",
"frame",
".",
"toplevel",
":",
"# if we know that we are a child template, there is no need to",
"# check if we are one",
"if",
"self",
".",
"has_known_extends",
":",
"r... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | CodeGenerator.visit_Import | Visit regular imports. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py | def visit_Import(self, node, frame):
"""Visit regular imports."""
if node.with_context:
self.unoptimize_scope(frame)
self.writeline('l_%s = ' % node.target, node)
if frame.toplevel:
self.write('context.vars[%r] = ' % node.target)
self.write('environment.ge... | def visit_Import(self, node, frame):
"""Visit regular imports."""
if node.with_context:
self.unoptimize_scope(frame)
self.writeline('l_%s = ' % node.target, node)
if frame.toplevel:
self.write('context.vars[%r] = ' % node.target)
self.write('environment.ge... | [
"Visit",
"regular",
"imports",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/compiler.py#L969-L985 | [
"def",
"visit_Import",
"(",
"self",
",",
"node",
",",
"frame",
")",
":",
"if",
"node",
".",
"with_context",
":",
"self",
".",
"unoptimize_scope",
"(",
"frame",
")",
"self",
".",
"writeline",
"(",
"'l_%s = '",
"%",
"node",
".",
"target",
",",
"node",
")... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | safe_range | A range that can't generate ranges with a length of more than
MAX_RANGE items. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/sandbox.py | def safe_range(*args):
"""A range that can't generate ranges with a length of more than
MAX_RANGE items.
"""
rng = xrange(*args)
if len(rng) > MAX_RANGE:
raise OverflowError('range too big, maximum size for range is %d' %
MAX_RANGE)
return rng | def safe_range(*args):
"""A range that can't generate ranges with a length of more than
MAX_RANGE items.
"""
rng = xrange(*args)
if len(rng) > MAX_RANGE:
raise OverflowError('range too big, maximum size for range is %d' %
MAX_RANGE)
return rng | [
"A",
"range",
"that",
"can",
"t",
"generate",
"ranges",
"with",
"a",
"length",
"of",
"more",
"than",
"MAX_RANGE",
"items",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/sandbox.py#L90-L98 | [
"def",
"safe_range",
"(",
"*",
"args",
")",
":",
"rng",
"=",
"xrange",
"(",
"*",
"args",
")",
"if",
"len",
"(",
"rng",
")",
">",
"MAX_RANGE",
":",
"raise",
"OverflowError",
"(",
"'range too big, maximum size for range is %d'",
"%",
"MAX_RANGE",
")",
"return"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | is_internal_attribute | Test if the attribute given is an internal python attribute. For
example this function returns `True` for the `func_code` attribute of
python objects. This is useful if the environment method
:meth:`~SandboxedEnvironment.is_safe_attribute` is overriden.
>>> from jinja2.sandbox import is_internal_attr... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/sandbox.py | def is_internal_attribute(obj, attr):
"""Test if the attribute given is an internal python attribute. For
example this function returns `True` for the `func_code` attribute of
python objects. This is useful if the environment method
:meth:`~SandboxedEnvironment.is_safe_attribute` is overriden.
>>... | def is_internal_attribute(obj, attr):
"""Test if the attribute given is an internal python attribute. For
example this function returns `True` for the `func_code` attribute of
python objects. This is useful if the environment method
:meth:`~SandboxedEnvironment.is_safe_attribute` is overriden.
>>... | [
"Test",
"if",
"the",
"attribute",
"given",
"is",
"an",
"internal",
"python",
"attribute",
".",
"For",
"example",
"this",
"function",
"returns",
"True",
"for",
"the",
"func_code",
"attribute",
"of",
"python",
"objects",
".",
"This",
"is",
"useful",
"if",
"the... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/sandbox.py#L113-L142 | [
"def",
"is_internal_attribute",
"(",
"obj",
",",
"attr",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"FunctionType",
")",
":",
"if",
"attr",
"in",
"UNSAFE_FUNCTION_ATTRIBUTES",
":",
"return",
"True",
"elif",
"isinstance",
"(",
"obj",
",",
"MethodType",
")... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | SandboxedEnvironment.getitem | Subscribe an object from sandboxed code. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/sandbox.py | def getitem(self, obj, argument):
"""Subscribe an object from sandboxed code."""
try:
return obj[argument]
except (TypeError, LookupError):
if isinstance(argument, basestring):
try:
attr = str(argument)
except:
... | def getitem(self, obj, argument):
"""Subscribe an object from sandboxed code."""
try:
return obj[argument]
except (TypeError, LookupError):
if isinstance(argument, basestring):
try:
attr = str(argument)
except:
... | [
"Subscribe",
"an",
"object",
"from",
"sandboxed",
"code",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/sandbox.py#L207-L226 | [
"def",
"getitem",
"(",
"self",
",",
"obj",
",",
"argument",
")",
":",
"try",
":",
"return",
"obj",
"[",
"argument",
"]",
"except",
"(",
"TypeError",
",",
"LookupError",
")",
":",
"if",
"isinstance",
"(",
"argument",
",",
"basestring",
")",
":",
"try",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | SandboxedEnvironment.call | Call an object from sandboxed code. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/sandbox.py | def call(__self, __context, __obj, *args, **kwargs):
"""Call an object from sandboxed code."""
# the double prefixes are to avoid double keyword argument
# errors when proxying the call.
if not __self.is_safe_callable(__obj):
raise SecurityError('%r is not safely callable' % ... | def call(__self, __context, __obj, *args, **kwargs):
"""Call an object from sandboxed code."""
# the double prefixes are to avoid double keyword argument
# errors when proxying the call.
if not __self.is_safe_callable(__obj):
raise SecurityError('%r is not safely callable' % ... | [
"Call",
"an",
"object",
"from",
"sandboxed",
"code",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/sandbox.py#L253-L259 | [
"def",
"call",
"(",
"__self",
",",
"__context",
",",
"__obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# the double prefixes are to avoid double keyword argument",
"# errors when proxying the call.",
"if",
"not",
"__self",
".",
"is_safe_callable",
"(",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | open_if_exists | Returns a file descriptor for the filename if that file exists,
otherwise `None`. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py | def open_if_exists(filename, mode='rb'):
"""Returns a file descriptor for the filename if that file exists,
otherwise `None`.
"""
try:
return open(filename, mode)
except IOError, e:
if e.errno not in (errno.ENOENT, errno.EISDIR):
raise | def open_if_exists(filename, mode='rb'):
"""Returns a file descriptor for the filename if that file exists,
otherwise `None`.
"""
try:
return open(filename, mode)
except IOError, e:
if e.errno not in (errno.ENOENT, errno.EISDIR):
raise | [
"Returns",
"a",
"file",
"descriptor",
"for",
"the",
"filename",
"if",
"that",
"file",
"exists",
"otherwise",
"None",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py#L219-L227 | [
"def",
"open_if_exists",
"(",
"filename",
",",
"mode",
"=",
"'rb'",
")",
":",
"try",
":",
"return",
"open",
"(",
"filename",
",",
"mode",
")",
"except",
"IOError",
",",
"e",
":",
"if",
"e",
".",
"errno",
"not",
"in",
"(",
"errno",
".",
"ENOENT",
",... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | object_type_repr | Returns the name of the object's type. For some recognized
singletons the name of the object is returned instead. (For
example for `None` and `Ellipsis`). | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py | def object_type_repr(obj):
"""Returns the name of the object's type. For some recognized
singletons the name of the object is returned instead. (For
example for `None` and `Ellipsis`).
"""
if obj is None:
return 'None'
elif obj is Ellipsis:
return 'Ellipsis'
if obj.__class__... | def object_type_repr(obj):
"""Returns the name of the object's type. For some recognized
singletons the name of the object is returned instead. (For
example for `None` and `Ellipsis`).
"""
if obj is None:
return 'None'
elif obj is Ellipsis:
return 'Ellipsis'
if obj.__class__... | [
"Returns",
"the",
"name",
"of",
"the",
"object",
"s",
"type",
".",
"For",
"some",
"recognized",
"singletons",
"the",
"name",
"of",
"the",
"object",
"is",
"returned",
"instead",
".",
"(",
"For",
"example",
"for",
"None",
"and",
"Ellipsis",
")",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py#L230-L243 | [
"def",
"object_type_repr",
"(",
"obj",
")",
":",
"if",
"obj",
"is",
"None",
":",
"return",
"'None'",
"elif",
"obj",
"is",
"Ellipsis",
":",
"return",
"'Ellipsis'",
"if",
"obj",
".",
"__class__",
".",
"__module__",
"==",
"'__builtin__'",
":",
"name",
"=",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | urlize | Converts any URLs in text into clickable links. Works on http://,
https:// and www. links. Links can have trailing punctuation (periods,
commas, close-parens) and leading punctuation (opening parens) and
it'll still do the right thing.
If trim_url_limit is not None, the URLs in link text will be limite... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py | def urlize(text, trim_url_limit=None, nofollow=False):
"""Converts any URLs in text into clickable links. Works on http://,
https:// and www. links. Links can have trailing punctuation (periods,
commas, close-parens) and leading punctuation (opening parens) and
it'll still do the right thing.
If tr... | def urlize(text, trim_url_limit=None, nofollow=False):
"""Converts any URLs in text into clickable links. Works on http://,
https:// and www. links. Links can have trailing punctuation (periods,
commas, close-parens) and leading punctuation (opening parens) and
it'll still do the right thing.
If tr... | [
"Converts",
"any",
"URLs",
"in",
"text",
"into",
"clickable",
"links",
".",
"Works",
"on",
"http",
":",
"//",
"https",
":",
"//",
"and",
"www",
".",
"links",
".",
"Links",
"can",
"have",
"trailing",
"punctuation",
"(",
"periods",
"commas",
"close",
"-",
... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py#L258-L299 | [
"def",
"urlize",
"(",
"text",
",",
"trim_url_limit",
"=",
"None",
",",
"nofollow",
"=",
"False",
")",
":",
"trim_url",
"=",
"lambda",
"x",
",",
"limit",
"=",
"trim_url_limit",
":",
"limit",
"is",
"not",
"None",
"and",
"(",
"x",
"[",
":",
"limit",
"]"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | generate_lorem_ipsum | Generate some lorem impsum for the template. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py | def generate_lorem_ipsum(n=5, html=True, min=20, max=100):
"""Generate some lorem impsum for the template."""
from jinja2.constants import LOREM_IPSUM_WORDS
from random import choice, randrange
words = LOREM_IPSUM_WORDS.split()
result = []
for _ in xrange(n):
next_capitalized = True
... | def generate_lorem_ipsum(n=5, html=True, min=20, max=100):
"""Generate some lorem impsum for the template."""
from jinja2.constants import LOREM_IPSUM_WORDS
from random import choice, randrange
words = LOREM_IPSUM_WORDS.split()
result = []
for _ in xrange(n):
next_capitalized = True
... | [
"Generate",
"some",
"lorem",
"impsum",
"for",
"the",
"template",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py#L302-L348 | [
"def",
"generate_lorem_ipsum",
"(",
"n",
"=",
"5",
",",
"html",
"=",
"True",
",",
"min",
"=",
"20",
",",
"max",
"=",
"100",
")",
":",
"from",
"jinja2",
".",
"constants",
"import",
"LOREM_IPSUM_WORDS",
"from",
"random",
"import",
"choice",
",",
"randrange... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Markup.unescape | r"""Unescape markup again into an unicode string. This also resolves
known HTML4 and XHTML entities:
>>> Markup("Main » <em>About</em>").unescape()
u'Main \xbb <em>About</em>' | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py | def unescape(self):
r"""Unescape markup again into an unicode string. This also resolves
known HTML4 and XHTML entities:
>>> Markup("Main » <em>About</em>").unescape()
u'Main \xbb <em>About</em>'
"""
from jinja2.constants import HTML_ENTITIES
def handle_ma... | def unescape(self):
r"""Unescape markup again into an unicode string. This also resolves
known HTML4 and XHTML entities:
>>> Markup("Main » <em>About</em>").unescape()
u'Main \xbb <em>About</em>'
"""
from jinja2.constants import HTML_ENTITIES
def handle_ma... | [
"r",
"Unescape",
"markup",
"again",
"into",
"an",
"unicode",
"string",
".",
"This",
"also",
"resolves",
"known",
"HTML4",
"and",
"XHTML",
"entities",
":"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py#L452-L472 | [
"def",
"unescape",
"(",
"self",
")",
":",
"from",
"jinja2",
".",
"constants",
"import",
"HTML_ENTITIES",
"def",
"handle_match",
"(",
"m",
")",
":",
"name",
"=",
"m",
".",
"group",
"(",
"1",
")",
"if",
"name",
"in",
"HTML_ENTITIES",
":",
"return",
"unic... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Markup.striptags | r"""Unescape markup into an unicode string and strip all tags. This
also resolves known HTML4 and XHTML entities. Whitespace is
normalized to one:
>>> Markup("Main » <em>About</em>").striptags()
u'Main \xbb About' | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py | def striptags(self):
r"""Unescape markup into an unicode string and strip all tags. This
also resolves known HTML4 and XHTML entities. Whitespace is
normalized to one:
>>> Markup("Main » <em>About</em>").striptags()
u'Main \xbb About'
"""
stripped = u' '... | def striptags(self):
r"""Unescape markup into an unicode string and strip all tags. This
also resolves known HTML4 and XHTML entities. Whitespace is
normalized to one:
>>> Markup("Main » <em>About</em>").striptags()
u'Main \xbb About'
"""
stripped = u' '... | [
"r",
"Unescape",
"markup",
"into",
"an",
"unicode",
"string",
"and",
"strip",
"all",
"tags",
".",
"This",
"also",
"resolves",
"known",
"HTML4",
"and",
"XHTML",
"entities",
".",
"Whitespace",
"is",
"normalized",
"to",
"one",
":"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py#L474-L483 | [
"def",
"striptags",
"(",
"self",
")",
":",
"stripped",
"=",
"u' '",
".",
"join",
"(",
"_striptags_re",
".",
"sub",
"(",
"''",
",",
"self",
")",
".",
"split",
"(",
")",
")",
"return",
"Markup",
"(",
"stripped",
")",
".",
"unescape",
"(",
")"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | LRUCache._remove | Python 2.4 compatibility. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py | def _remove(self, obj):
"""Python 2.4 compatibility."""
for idx, item in enumerate(self._queue):
if item == obj:
del self._queue[idx]
break | def _remove(self, obj):
"""Python 2.4 compatibility."""
for idx, item in enumerate(self._queue):
if item == obj:
del self._queue[idx]
break | [
"Python",
"2",
".",
"4",
"compatibility",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py#L572-L577 | [
"def",
"_remove",
"(",
"self",
",",
"obj",
")",
":",
"for",
"idx",
",",
"item",
"in",
"enumerate",
"(",
"self",
".",
"_queue",
")",
":",
"if",
"item",
"==",
"obj",
":",
"del",
"self",
".",
"_queue",
"[",
"idx",
"]",
"break"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Cycler.next | Goes one item ahead and returns it. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py | def next(self):
"""Goes one item ahead and returns it."""
rv = self.current
self.pos = (self.pos + 1) % len(self.items)
return rv | def next(self):
"""Goes one item ahead and returns it."""
rv = self.current
self.pos = (self.pos + 1) % len(self.items)
return rv | [
"Goes",
"one",
"item",
"ahead",
"and",
"returns",
"it",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/utils.py#L757-L761 | [
"def",
"next",
"(",
"self",
")",
":",
"rv",
"=",
"self",
".",
"current",
"self",
".",
"pos",
"=",
"(",
"self",
".",
"pos",
"+",
"1",
")",
"%",
"len",
"(",
"self",
".",
"items",
")",
"return",
"rv"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | get_lib_from | Scan directories recursively until find any file with the given
extension. The default extension to search is ``.so``. | pythonforandroid/recipes/libtorrent/__init__.py | def get_lib_from(search_directory, lib_extension='.so'):
'''Scan directories recursively until find any file with the given
extension. The default extension to search is ``.so``.'''
for root, dirs, files in walk(search_directory):
for file in files:
if file.endswith(lib_extension):
... | def get_lib_from(search_directory, lib_extension='.so'):
'''Scan directories recursively until find any file with the given
extension. The default extension to search is ``.so``.'''
for root, dirs, files in walk(search_directory):
for file in files:
if file.endswith(lib_extension):
... | [
"Scan",
"directories",
"recursively",
"until",
"find",
"any",
"file",
"with",
"the",
"given",
"extension",
".",
"The",
"default",
"extension",
"to",
"search",
"is",
".",
"so",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/recipes/libtorrent/__init__.py#L12-L21 | [
"def",
"get_lib_from",
"(",
"search_directory",
",",
"lib_extension",
"=",
"'.so'",
")",
":",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"walk",
"(",
"search_directory",
")",
":",
"for",
"file",
"in",
"files",
":",
"if",
"file",
".",
"endswith",
"("... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Parser.parse_set | Parse an assign statement. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/parser.py | def parse_set(self):
"""Parse an assign statement."""
lineno = next(self.stream).lineno
target = self.parse_assign_target()
self.stream.expect('assign')
expr = self.parse_tuple()
return nodes.Assign(target, expr, lineno=lineno) | def parse_set(self):
"""Parse an assign statement."""
lineno = next(self.stream).lineno
target = self.parse_assign_target()
self.stream.expect('assign')
expr = self.parse_tuple()
return nodes.Assign(target, expr, lineno=lineno) | [
"Parse",
"an",
"assign",
"statement",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/parser.py#L168-L174 | [
"def",
"parse_set",
"(",
"self",
")",
":",
"lineno",
"=",
"next",
"(",
"self",
".",
"stream",
")",
".",
"lineno",
"target",
"=",
"self",
".",
"parse_assign_target",
"(",
")",
"self",
".",
"stream",
".",
"expect",
"(",
"'assign'",
")",
"expr",
"=",
"s... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Parser.parse_assign_target | Parse an assignment target. As Jinja2 allows assignments to
tuples, this function can parse all allowed assignment targets. Per
default assignments to tuples are parsed, that can be disable however
by setting `with_tuple` to `False`. If only assignments to names are
wanted `name_only`... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/parser.py | def parse_assign_target(self, with_tuple=True, name_only=False,
extra_end_rules=None):
"""Parse an assignment target. As Jinja2 allows assignments to
tuples, this function can parse all allowed assignment targets. Per
default assignments to tuples are parsed, that c... | def parse_assign_target(self, with_tuple=True, name_only=False,
extra_end_rules=None):
"""Parse an assignment target. As Jinja2 allows assignments to
tuples, this function can parse all allowed assignment targets. Per
default assignments to tuples are parsed, that c... | [
"Parse",
"an",
"assignment",
"target",
".",
"As",
"Jinja2",
"allows",
"assignments",
"to",
"tuples",
"this",
"function",
"can",
"parse",
"all",
"allowed",
"assignment",
"targets",
".",
"Per",
"default",
"assignments",
"to",
"tuples",
"are",
"parsed",
"that",
"... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/parser.py#L356-L378 | [
"def",
"parse_assign_target",
"(",
"self",
",",
"with_tuple",
"=",
"True",
",",
"name_only",
"=",
"False",
",",
"extra_end_rules",
"=",
"None",
")",
":",
"if",
"name_only",
":",
"token",
"=",
"self",
".",
"stream",
".",
"expect",
"(",
"'name'",
")",
"tar... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Parser.parse_tuple | Works like `parse_expression` but if multiple expressions are
delimited by a comma a :class:`~jinja2.nodes.Tuple` node is created.
This method could also return a regular expression instead of a tuple
if no commas where found.
The default parsing mode is a full tuple. If `simplified` i... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/parser.py | def parse_tuple(self, simplified=False, with_condexpr=True,
extra_end_rules=None, explicit_parentheses=False):
"""Works like `parse_expression` but if multiple expressions are
delimited by a comma a :class:`~jinja2.nodes.Tuple` node is created.
This method could also return a... | def parse_tuple(self, simplified=False, with_condexpr=True,
extra_end_rules=None, explicit_parentheses=False):
"""Works like `parse_expression` but if multiple expressions are
delimited by a comma a :class:`~jinja2.nodes.Tuple` node is created.
This method could also return a... | [
"Works",
"like",
"parse_expression",
"but",
"if",
"multiple",
"expressions",
"are",
"delimited",
"by",
"a",
"comma",
"a",
":",
"class",
":",
"~jinja2",
".",
"nodes",
".",
"Tuple",
"node",
"is",
"created",
".",
"This",
"method",
"could",
"also",
"return",
"... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/parser.py#L577-L630 | [
"def",
"parse_tuple",
"(",
"self",
",",
"simplified",
"=",
"False",
",",
"with_condexpr",
"=",
"True",
",",
"extra_end_rules",
"=",
"None",
",",
"explicit_parentheses",
"=",
"False",
")",
":",
"lineno",
"=",
"self",
".",
"stream",
".",
"current",
".",
"lin... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Distribution.get_distribution | Takes information about the distribution, and decides what kind of
distribution it will be.
If parameters conflict (e.g. a dist with that name already
exists, but doesn't have the right set of recipes),
an error is thrown.
Parameters
----------
name : str
... | pythonforandroid/distribution.py | def get_distribution(cls, ctx, name=None, recipes=[],
ndk_api=None,
force_build=False,
extra_dist_dirs=[],
require_perfect_match=False,
allow_replace_dist=True):
'''Takes information abou... | def get_distribution(cls, ctx, name=None, recipes=[],
ndk_api=None,
force_build=False,
extra_dist_dirs=[],
require_perfect_match=False,
allow_replace_dist=True):
'''Takes information abou... | [
"Takes",
"information",
"about",
"the",
"distribution",
"and",
"decides",
"what",
"kind",
"of",
"distribution",
"it",
"will",
"be",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/distribution.py#L45-L159 | [
"def",
"get_distribution",
"(",
"cls",
",",
"ctx",
",",
"name",
"=",
"None",
",",
"recipes",
"=",
"[",
"]",
",",
"ndk_api",
"=",
"None",
",",
"force_build",
"=",
"False",
",",
"extra_dist_dirs",
"=",
"[",
"]",
",",
"require_perfect_match",
"=",
"False",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Distribution.get_distributions | Returns all the distributions found locally. | pythonforandroid/distribution.py | def get_distributions(cls, ctx, extra_dist_dirs=[]):
'''Returns all the distributions found locally.'''
if extra_dist_dirs:
raise BuildInterruptingException(
'extra_dist_dirs argument to get_distributions '
'is not yet implemented')
dist_dir = ctx.dist... | def get_distributions(cls, ctx, extra_dist_dirs=[]):
'''Returns all the distributions found locally.'''
if extra_dist_dirs:
raise BuildInterruptingException(
'extra_dist_dirs argument to get_distributions '
'is not yet implemented')
dist_dir = ctx.dist... | [
"Returns",
"all",
"the",
"distributions",
"found",
"locally",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/distribution.py#L168-L204 | [
"def",
"get_distributions",
"(",
"cls",
",",
"ctx",
",",
"extra_dist_dirs",
"=",
"[",
"]",
")",
":",
"if",
"extra_dist_dirs",
":",
"raise",
"BuildInterruptingException",
"(",
"'extra_dist_dirs argument to get_distributions '",
"'is not yet implemented'",
")",
"dist_dir",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Distribution.save_info | Save information about the distribution in its dist_dir. | pythonforandroid/distribution.py | def save_info(self, dirn):
'''
Save information about the distribution in its dist_dir.
'''
with current_directory(dirn):
info('Saving distribution info')
with open('dist_info.json', 'w') as fileh:
json.dump({'dist_name': self.ctx.dist_name,
... | def save_info(self, dirn):
'''
Save information about the distribution in its dist_dir.
'''
with current_directory(dirn):
info('Saving distribution info')
with open('dist_info.json', 'w') as fileh:
json.dump({'dist_name': self.ctx.dist_name,
... | [
"Save",
"information",
"about",
"the",
"distribution",
"in",
"its",
"dist_dir",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/distribution.py#L206-L221 | [
"def",
"save_info",
"(",
"self",
",",
"dirn",
")",
":",
"with",
"current_directory",
"(",
"dirn",
")",
":",
"info",
"(",
"'Saving distribution info'",
")",
"with",
"open",
"(",
"'dist_info.json'",
",",
"'w'",
")",
"as",
"fileh",
":",
"json",
".",
"dump",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Bucket.load_bytecode | Loads bytecode from a file or file like object. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/bccache.py | def load_bytecode(self, f):
"""Loads bytecode from a file or file like object."""
# make sure the magic header is correct
magic = f.read(len(bc_magic))
if magic != bc_magic:
self.reset()
return
# the source code of the file changed, we need to reload
... | def load_bytecode(self, f):
"""Loads bytecode from a file or file like object."""
# make sure the magic header is correct
magic = f.read(len(bc_magic))
if magic != bc_magic:
self.reset()
return
# the source code of the file changed, we need to reload
... | [
"Loads",
"bytecode",
"from",
"a",
"file",
"or",
"file",
"like",
"object",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/bccache.py#L53-L70 | [
"def",
"load_bytecode",
"(",
"self",
",",
"f",
")",
":",
"# make sure the magic header is correct",
"magic",
"=",
"f",
".",
"read",
"(",
"len",
"(",
"bc_magic",
")",
")",
"if",
"magic",
"!=",
"bc_magic",
":",
"self",
".",
"reset",
"(",
")",
"return",
"# ... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Bucket.write_bytecode | Dump the bytecode into the file or file like object passed. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/bccache.py | def write_bytecode(self, f):
"""Dump the bytecode into the file or file like object passed."""
if self.code is None:
raise TypeError('can\'t write empty bucket')
f.write(bc_magic)
pickle.dump(self.checksum, f, 2)
if isinstance(f, file):
marshal.dump(self.c... | def write_bytecode(self, f):
"""Dump the bytecode into the file or file like object passed."""
if self.code is None:
raise TypeError('can\'t write empty bucket')
f.write(bc_magic)
pickle.dump(self.checksum, f, 2)
if isinstance(f, file):
marshal.dump(self.c... | [
"Dump",
"the",
"bytecode",
"into",
"the",
"file",
"or",
"file",
"like",
"object",
"passed",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/bccache.py#L72-L81 | [
"def",
"write_bytecode",
"(",
"self",
",",
"f",
")",
":",
"if",
"self",
".",
"code",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"'can\\'t write empty bucket'",
")",
"f",
".",
"write",
"(",
"bc_magic",
")",
"pickle",
".",
"dump",
"(",
"self",
".",
"c... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Psycopg2Recipe.install_python_package | Automate the installation of a Python package (or a cython
package where the cython components are pre-built). | pythonforandroid/recipes/psycopg2/__init__.py | def install_python_package(self, arch, name=None, env=None, is_dir=True):
'''Automate the installation of a Python package (or a cython
package where the cython components are pre-built).'''
if env is None:
env = self.get_recipe_env(arch)
with current_directory(self.get_buil... | def install_python_package(self, arch, name=None, env=None, is_dir=True):
'''Automate the installation of a Python package (or a cython
package where the cython components are pre-built).'''
if env is None:
env = self.get_recipe_env(arch)
with current_directory(self.get_buil... | [
"Automate",
"the",
"installation",
"of",
"a",
"Python",
"package",
"(",
"or",
"a",
"cython",
"package",
"where",
"the",
"cython",
"components",
"are",
"pre",
"-",
"built",
")",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/recipes/psycopg2/__init__.py#L34-L47 | [
"def",
"install_python_package",
"(",
"self",
",",
"arch",
",",
"name",
"=",
"None",
",",
"env",
"=",
"None",
",",
"is_dir",
"=",
"True",
")",
":",
"if",
"env",
"is",
"None",
":",
"env",
"=",
"self",
".",
"get_recipe_env",
"(",
"arch",
")",
"with",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | translate_exception | If passed an exc_info it will automatically rewrite the exceptions
all the way down to the correct line numbers and frames. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/debug.py | def translate_exception(exc_info, initial_skip=0):
"""If passed an exc_info it will automatically rewrite the exceptions
all the way down to the correct line numbers and frames.
"""
tb = exc_info[2]
frames = []
# skip some internal frames if wanted
for x in xrange(initial_skip):
if ... | def translate_exception(exc_info, initial_skip=0):
"""If passed an exc_info it will automatically rewrite the exceptions
all the way down to the correct line numbers and frames.
"""
tb = exc_info[2]
frames = []
# skip some internal frames if wanted
for x in xrange(initial_skip):
if ... | [
"If",
"passed",
"an",
"exc_info",
"it",
"will",
"automatically",
"rewrite",
"the",
"exceptions",
"all",
"the",
"way",
"down",
"to",
"the",
"correct",
"line",
"numbers",
"and",
"frames",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/debug.py#L123-L167 | [
"def",
"translate_exception",
"(",
"exc_info",
",",
"initial_skip",
"=",
"0",
")",
":",
"tb",
"=",
"exc_info",
"[",
"2",
"]",
"frames",
"=",
"[",
"]",
"# skip some internal frames if wanted",
"for",
"x",
"in",
"xrange",
"(",
"initial_skip",
")",
":",
"if",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | fake_exc_info | Helper for `translate_exception`. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/debug.py | def fake_exc_info(exc_info, filename, lineno):
"""Helper for `translate_exception`."""
exc_type, exc_value, tb = exc_info
# figure the real context out
if tb is not None:
real_locals = tb.tb_frame.f_locals.copy()
ctx = real_locals.get('context')
if ctx:
locals = ctx.... | def fake_exc_info(exc_info, filename, lineno):
"""Helper for `translate_exception`."""
exc_type, exc_value, tb = exc_info
# figure the real context out
if tb is not None:
real_locals = tb.tb_frame.f_locals.copy()
ctx = real_locals.get('context')
if ctx:
locals = ctx.... | [
"Helper",
"for",
"translate_exception",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/debug.py#L170-L236 | [
"def",
"fake_exc_info",
"(",
"exc_info",
",",
"filename",
",",
"lineno",
")",
":",
"exc_type",
",",
"exc_value",
",",
"tb",
"=",
"exc_info",
"# figure the real context out",
"if",
"tb",
"is",
"not",
"None",
":",
"real_locals",
"=",
"tb",
".",
"tb_frame",
"."... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | _init_ugly_crap | This function implements a few ugly things so that we can patch the
traceback objects. The function returned allows resetting `tb_next` on
any python traceback object. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/debug.py | def _init_ugly_crap():
"""This function implements a few ugly things so that we can patch the
traceback objects. The function returned allows resetting `tb_next` on
any python traceback object.
"""
import ctypes
from types import TracebackType
# figure out side of _Py_ssize_t
if hasatt... | def _init_ugly_crap():
"""This function implements a few ugly things so that we can patch the
traceback objects. The function returned allows resetting `tb_next` on
any python traceback object.
"""
import ctypes
from types import TracebackType
# figure out side of _Py_ssize_t
if hasatt... | [
"This",
"function",
"implements",
"a",
"few",
"ugly",
"things",
"so",
"that",
"we",
"can",
"patch",
"the",
"traceback",
"objects",
".",
"The",
"function",
"returned",
"allows",
"resetting",
"tb_next",
"on",
"any",
"python",
"traceback",
"object",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/debug.py#L239-L297 | [
"def",
"_init_ugly_crap",
"(",
")",
":",
"import",
"ctypes",
"from",
"types",
"import",
"TracebackType",
"# figure out side of _Py_ssize_t",
"if",
"hasattr",
"(",
"ctypes",
".",
"pythonapi",
",",
"'Py_InitModule4_64'",
")",
":",
"_Py_ssize_t",
"=",
"ctypes",
".",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | ProcessedTraceback.chain_frames | Chains the frames. Requires ctypes or the speedups extension. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/debug.py | def chain_frames(self):
"""Chains the frames. Requires ctypes or the speedups extension."""
prev_tb = None
for tb in self.frames:
if prev_tb is not None:
prev_tb.tb_next = tb
prev_tb = tb
prev_tb.tb_next = None | def chain_frames(self):
"""Chains the frames. Requires ctypes or the speedups extension."""
prev_tb = None
for tb in self.frames:
if prev_tb is not None:
prev_tb.tb_next = tb
prev_tb = tb
prev_tb.tb_next = None | [
"Chains",
"the",
"frames",
".",
"Requires",
"ctypes",
"or",
"the",
"speedups",
"extension",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/debug.py#L62-L69 | [
"def",
"chain_frames",
"(",
"self",
")",
":",
"prev_tb",
"=",
"None",
"for",
"tb",
"in",
"self",
".",
"frames",
":",
"if",
"prev_tb",
"is",
"not",
"None",
":",
"prev_tb",
".",
"tb_next",
"=",
"tb",
"prev_tb",
"=",
"tb",
"prev_tb",
".",
"tb_next",
"="... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | compile_rules | Compiles all the rules from the environment into a list of rules. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py | def compile_rules(environment):
"""Compiles all the rules from the environment into a list of rules."""
e = re.escape
rules = [
(len(environment.comment_start_string), 'comment',
e(environment.comment_start_string)),
(len(environment.block_start_string), 'block',
e(environm... | def compile_rules(environment):
"""Compiles all the rules from the environment into a list of rules."""
e = re.escape
rules = [
(len(environment.comment_start_string), 'comment',
e(environment.comment_start_string)),
(len(environment.block_start_string), 'block',
e(environm... | [
"Compiles",
"all",
"the",
"rules",
"from",
"the",
"environment",
"into",
"a",
"list",
"of",
"rules",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py#L186-L206 | [
"def",
"compile_rules",
"(",
"environment",
")",
":",
"e",
"=",
"re",
".",
"escape",
"rules",
"=",
"[",
"(",
"len",
"(",
"environment",
".",
"comment_start_string",
")",
",",
"'comment'",
",",
"e",
"(",
"environment",
".",
"comment_start_string",
")",
")",... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | TokenStream.look | Look at the next token. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py | def look(self):
"""Look at the next token."""
old_token = next(self)
result = self.current
self.push(result)
self.current = old_token
return result | def look(self):
"""Look at the next token."""
old_token = next(self)
result = self.current
self.push(result)
self.current = old_token
return result | [
"Look",
"at",
"the",
"next",
"token",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py#L312-L318 | [
"def",
"look",
"(",
"self",
")",
":",
"old_token",
"=",
"next",
"(",
"self",
")",
"result",
"=",
"self",
".",
"current",
"self",
".",
"push",
"(",
"result",
")",
"self",
".",
"current",
"=",
"old_token",
"return",
"result"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | TokenStream.next | Go one token ahead and return the old one | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py | def next(self):
"""Go one token ahead and return the old one"""
rv = self.current
if self._pushed:
self.current = self._pushed.popleft()
elif self.current.type is not TOKEN_EOF:
try:
self.current = self._next()
except StopIteration:
... | def next(self):
"""Go one token ahead and return the old one"""
rv = self.current
if self._pushed:
self.current = self._pushed.popleft()
elif self.current.type is not TOKEN_EOF:
try:
self.current = self._next()
except StopIteration:
... | [
"Go",
"one",
"token",
"ahead",
"and",
"return",
"the",
"old",
"one"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py#L336-L346 | [
"def",
"next",
"(",
"self",
")",
":",
"rv",
"=",
"self",
".",
"current",
"if",
"self",
".",
"_pushed",
":",
"self",
".",
"current",
"=",
"self",
".",
"_pushed",
".",
"popleft",
"(",
")",
"elif",
"self",
".",
"current",
".",
"type",
"is",
"not",
"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | TokenStream.close | Close the stream. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py | def close(self):
"""Close the stream."""
self.current = Token(self.current.lineno, TOKEN_EOF, '')
self._next = None
self.closed = True | def close(self):
"""Close the stream."""
self.current = Token(self.current.lineno, TOKEN_EOF, '')
self._next = None
self.closed = True | [
"Close",
"the",
"stream",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py#L348-L352 | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"current",
"=",
"Token",
"(",
"self",
".",
"current",
".",
"lineno",
",",
"TOKEN_EOF",
",",
"''",
")",
"self",
".",
"_next",
"=",
"None",
"self",
".",
"closed",
"=",
"True"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | TokenStream.expect | Expect a given token type and return it. This accepts the same
argument as :meth:`jinja2.lexer.Token.test`. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py | def expect(self, expr):
"""Expect a given token type and return it. This accepts the same
argument as :meth:`jinja2.lexer.Token.test`.
"""
if not self.current.test(expr):
expr = describe_token_expr(expr)
if self.current.type is TOKEN_EOF:
raise Te... | def expect(self, expr):
"""Expect a given token type and return it. This accepts the same
argument as :meth:`jinja2.lexer.Token.test`.
"""
if not self.current.test(expr):
expr = describe_token_expr(expr)
if self.current.type is TOKEN_EOF:
raise Te... | [
"Expect",
"a",
"given",
"token",
"type",
"and",
"return",
"it",
".",
"This",
"accepts",
"the",
"same",
"argument",
"as",
":",
"meth",
":",
"jinja2",
".",
"lexer",
".",
"Token",
".",
"test",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py#L354-L372 | [
"def",
"expect",
"(",
"self",
",",
"expr",
")",
":",
"if",
"not",
"self",
".",
"current",
".",
"test",
"(",
"expr",
")",
":",
"expr",
"=",
"describe_token_expr",
"(",
"expr",
")",
"if",
"self",
".",
"current",
".",
"type",
"is",
"TOKEN_EOF",
":",
"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Lexer.tokeniter | This method tokenizes the text and returns the tokens in a
generator. Use this method if you just want to tokenize a template. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py | def tokeniter(self, source, name, filename=None, state=None):
"""This method tokenizes the text and returns the tokens in a
generator. Use this method if you just want to tokenize a template.
"""
source = '\n'.join(unicode(source).splitlines())
pos = 0
lineno = 1
... | def tokeniter(self, source, name, filename=None, state=None):
"""This method tokenizes the text and returns the tokens in a
generator. Use this method if you just want to tokenize a template.
"""
source = '\n'.join(unicode(source).splitlines())
pos = 0
lineno = 1
... | [
"This",
"method",
"tokenizes",
"the",
"text",
"and",
"returns",
"the",
"tokens",
"in",
"a",
"generator",
".",
"Use",
"this",
"method",
"if",
"you",
"just",
"want",
"to",
"tokenize",
"a",
"template",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/lexer.py#L547-L680 | [
"def",
"tokeniter",
"(",
"self",
",",
"source",
",",
"name",
",",
"filename",
"=",
"None",
",",
"state",
"=",
"None",
")",
":",
"source",
"=",
"'\\n'",
".",
"join",
"(",
"unicode",
"(",
"source",
")",
".",
"splitlines",
"(",
")",
")",
"pos",
"=",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | ShapelyRecipe.get_recipe_env | Add libgeos headers to path | pythonforandroid/recipes/shapely/__init__.py | def get_recipe_env(self, arch, with_flags_in_cc=True):
""" Add libgeos headers to path """
env = super(ShapelyRecipe, self).get_recipe_env(arch, with_flags_in_cc)
libgeos_dir = Recipe.get_recipe('libgeos', self.ctx).get_build_dir(arch.arch)
env['CFLAGS'] += " -I{}/dist/include".format(li... | def get_recipe_env(self, arch, with_flags_in_cc=True):
""" Add libgeos headers to path """
env = super(ShapelyRecipe, self).get_recipe_env(arch, with_flags_in_cc)
libgeos_dir = Recipe.get_recipe('libgeos', self.ctx).get_build_dir(arch.arch)
env['CFLAGS'] += " -I{}/dist/include".format(li... | [
"Add",
"libgeos",
"headers",
"to",
"path"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/recipes/shapely/__init__.py#L14-L19 | [
"def",
"get_recipe_env",
"(",
"self",
",",
"arch",
",",
"with_flags_in_cc",
"=",
"True",
")",
":",
"env",
"=",
"super",
"(",
"ShapelyRecipe",
",",
"self",
")",
".",
"get_recipe_env",
"(",
"arch",
",",
"with_flags_in_cc",
")",
"libgeos_dir",
"=",
"Recipe",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | read_ndk_version | Read the NDK version from the NDK dir, if possible | pythonforandroid/recommendations.py | def read_ndk_version(ndk_dir):
"""Read the NDK version from the NDK dir, if possible"""
try:
with open(join(ndk_dir, 'source.properties')) as fileh:
ndk_data = fileh.read()
except IOError:
info('Could not determine NDK version, no source.properties '
'in the NDK dir'... | def read_ndk_version(ndk_dir):
"""Read the NDK version from the NDK dir, if possible"""
try:
with open(join(ndk_dir, 'source.properties')) as fileh:
ndk_data = fileh.read()
except IOError:
info('Could not determine NDK version, no source.properties '
'in the NDK dir'... | [
"Read",
"the",
"NDK",
"version",
"from",
"the",
"NDK",
"dir",
"if",
"possible"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/recommendations.py#L38-L59 | [
"def",
"read_ndk_version",
"(",
"ndk_dir",
")",
":",
"try",
":",
"with",
"open",
"(",
"join",
"(",
"ndk_dir",
",",
"'source.properties'",
")",
")",
"as",
"fileh",
":",
"ndk_data",
"=",
"fileh",
".",
"read",
"(",
")",
"except",
"IOError",
":",
"info",
"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | check_target_api | Warn if the user's target API is less than the current minimum
recommendation | pythonforandroid/recommendations.py | def check_target_api(api, arch):
"""Warn if the user's target API is less than the current minimum
recommendation
"""
if api >= ARMEABI_MAX_TARGET_API and arch == 'armeabi':
raise BuildInterruptingException(
'Asked to build for armeabi architecture with API '
'{}, but AP... | def check_target_api(api, arch):
"""Warn if the user's target API is less than the current minimum
recommendation
"""
if api >= ARMEABI_MAX_TARGET_API and arch == 'armeabi':
raise BuildInterruptingException(
'Asked to build for armeabi architecture with API '
'{}, but AP... | [
"Warn",
"if",
"the",
"user",
"s",
"target",
"API",
"is",
"less",
"than",
"the",
"current",
"minimum",
"recommendation"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/recommendations.py#L75-L89 | [
"def",
"check_target_api",
"(",
"api",
",",
"arch",
")",
":",
"if",
"api",
">=",
"ARMEABI_MAX_TARGET_API",
"and",
"arch",
"==",
"'armeabi'",
":",
"raise",
"BuildInterruptingException",
"(",
"'Asked to build for armeabi architecture with API '",
"'{}, but API {} or greater d... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | check_ndk_api | Warn if the user's NDK is too high or low. | pythonforandroid/recommendations.py | def check_ndk_api(ndk_api, android_api):
"""Warn if the user's NDK is too high or low."""
if ndk_api > android_api:
raise BuildInterruptingException(
'Target NDK API is {}, higher than the target Android API {}.'.format(
ndk_api, android_api),
instructions=('The N... | def check_ndk_api(ndk_api, android_api):
"""Warn if the user's NDK is too high or low."""
if ndk_api > android_api:
raise BuildInterruptingException(
'Target NDK API is {}, higher than the target Android API {}.'.format(
ndk_api, android_api),
instructions=('The N... | [
"Warn",
"if",
"the",
"user",
"s",
"NDK",
"is",
"too",
"high",
"or",
"low",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/recommendations.py#L97-L107 | [
"def",
"check_ndk_api",
"(",
"ndk_api",
",",
"android_api",
")",
":",
"if",
"ndk_api",
">",
"android_api",
":",
"raise",
"BuildInterruptingException",
"(",
"'Target NDK API is {}, higher than the target Android API {}.'",
".",
"format",
"(",
"ndk_api",
",",
"android_api",... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Optimizer.visit_If | Eliminate dead code. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/optimizer.py | def visit_If(self, node):
"""Eliminate dead code."""
# do not optimize ifs that have a block inside so that it doesn't
# break super().
if node.find(nodes.Block) is not None:
return self.generic_visit(node)
try:
val = self.visit(node.test).as_const()
... | def visit_If(self, node):
"""Eliminate dead code."""
# do not optimize ifs that have a block inside so that it doesn't
# break super().
if node.find(nodes.Block) is not None:
return self.generic_visit(node)
try:
val = self.visit(node.test).as_const()
... | [
"Eliminate",
"dead",
"code",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/optimizer.py#L35-L52 | [
"def",
"visit_If",
"(",
"self",
",",
"node",
")",
":",
"# do not optimize ifs that have a block inside so that it doesn't",
"# break super().",
"if",
"node",
".",
"find",
"(",
"nodes",
".",
"Block",
")",
"is",
"not",
"None",
":",
"return",
"self",
".",
"generic_vi... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Optimizer.fold | Do constant folding. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/optimizer.py | def fold(self, node):
"""Do constant folding."""
node = self.generic_visit(node)
try:
return nodes.Const.from_untrusted(node.as_const(),
lineno=node.lineno,
environment=self.environment)
... | def fold(self, node):
"""Do constant folding."""
node = self.generic_visit(node)
try:
return nodes.Const.from_untrusted(node.as_const(),
lineno=node.lineno,
environment=self.environment)
... | [
"Do",
"constant",
"folding",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/optimizer.py#L54-L62 | [
"def",
"fold",
"(",
"self",
",",
"node",
")",
":",
"node",
"=",
"self",
".",
"generic_visit",
"(",
"node",
")",
"try",
":",
"return",
"nodes",
".",
"Const",
".",
"from_untrusted",
"(",
"node",
".",
"as_const",
"(",
")",
",",
"lineno",
"=",
"node",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_forceescape | Enforce HTML escaping. This will probably double escape variables. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_forceescape(value):
"""Enforce HTML escaping. This will probably double escape variables."""
if hasattr(value, '__html__'):
value = value.__html__()
return escape(unicode(value)) | def do_forceescape(value):
"""Enforce HTML escaping. This will probably double escape variables."""
if hasattr(value, '__html__'):
value = value.__html__()
return escape(unicode(value)) | [
"Enforce",
"HTML",
"escaping",
".",
"This",
"will",
"probably",
"double",
"escape",
"variables",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L51-L55 | [
"def",
"do_forceescape",
"(",
"value",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'__html__'",
")",
":",
"value",
"=",
"value",
".",
"__html__",
"(",
")",
"return",
"escape",
"(",
"unicode",
"(",
"value",
")",
")"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_replace | Return a copy of the value with all occurrences of a substring
replaced with a new one. The first argument is the substring
that should be replaced, the second is the replacement string.
If the optional third argument ``count`` is given, only the first
``count`` occurrences are replaced:
.. sourcec... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_replace(eval_ctx, s, old, new, count=None):
"""Return a copy of the value with all occurrences of a substring
replaced with a new one. The first argument is the substring
that should be replaced, the second is the replacement string.
If the optional third argument ``count`` is given, only the fir... | def do_replace(eval_ctx, s, old, new, count=None):
"""Return a copy of the value with all occurrences of a substring
replaced with a new one. The first argument is the substring
that should be replaced, the second is the replacement string.
If the optional third argument ``count`` is given, only the fir... | [
"Return",
"a",
"copy",
"of",
"the",
"value",
"with",
"all",
"occurrences",
"of",
"a",
"substring",
"replaced",
"with",
"a",
"new",
"one",
".",
"The",
"first",
"argument",
"is",
"the",
"substring",
"that",
"should",
"be",
"replaced",
"the",
"second",
"is",
... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L59-L83 | [
"def",
"do_replace",
"(",
"eval_ctx",
",",
"s",
",",
"old",
",",
"new",
",",
"count",
"=",
"None",
")",
":",
"if",
"count",
"is",
"None",
":",
"count",
"=",
"-",
"1",
"if",
"not",
"eval_ctx",
".",
"autoescape",
":",
"return",
"unicode",
"(",
"s",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_xmlattr | Create an SGML/XML attribute string based on the items in a dict.
All values that are neither `none` nor `undefined` are automatically
escaped:
.. sourcecode:: html+jinja
<ul{{ {'class': 'my_list', 'missing': none,
'id': 'list-%d'|format(variable)}|xmlattr }}>
...
<... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_xmlattr(_eval_ctx, d, autospace=True):
"""Create an SGML/XML attribute string based on the items in a dict.
All values that are neither `none` nor `undefined` are automatically
escaped:
.. sourcecode:: html+jinja
<ul{{ {'class': 'my_list', 'missing': none,
'id': 'list-%d... | def do_xmlattr(_eval_ctx, d, autospace=True):
"""Create an SGML/XML attribute string based on the items in a dict.
All values that are neither `none` nor `undefined` are automatically
escaped:
.. sourcecode:: html+jinja
<ul{{ {'class': 'my_list', 'missing': none,
'id': 'list-%d... | [
"Create",
"an",
"SGML",
"/",
"XML",
"attribute",
"string",
"based",
"on",
"the",
"items",
"in",
"a",
"dict",
".",
"All",
"values",
"that",
"are",
"neither",
"none",
"nor",
"undefined",
"are",
"automatically",
"escaped",
":"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L97-L129 | [
"def",
"do_xmlattr",
"(",
"_eval_ctx",
",",
"d",
",",
"autospace",
"=",
"True",
")",
":",
"rv",
"=",
"u' '",
".",
"join",
"(",
"u'%s=\"%s\"'",
"%",
"(",
"escape",
"(",
"key",
")",
",",
"escape",
"(",
"value",
")",
")",
"for",
"key",
",",
"value",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_sort | Sort an iterable. If the iterable is made of strings the second
parameter can be used to control the case sensitiveness of the
comparison which is disabled by default.
.. sourcecode:: jinja
{% for item in iterable|sort %}
...
{% endfor %} | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_sort(value, case_sensitive=False):
"""Sort an iterable. If the iterable is made of strings the second
parameter can be used to control the case sensitiveness of the
comparison which is disabled by default.
.. sourcecode:: jinja
{% for item in iterable|sort %}
...
{%... | def do_sort(value, case_sensitive=False):
"""Sort an iterable. If the iterable is made of strings the second
parameter can be used to control the case sensitiveness of the
comparison which is disabled by default.
.. sourcecode:: jinja
{% for item in iterable|sort %}
...
{%... | [
"Sort",
"an",
"iterable",
".",
"If",
"the",
"iterable",
"is",
"made",
"of",
"strings",
"the",
"second",
"parameter",
"can",
"be",
"used",
"to",
"control",
"the",
"case",
"sensitiveness",
"of",
"the",
"comparison",
"which",
"is",
"disabled",
"by",
"default",
... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L179-L197 | [
"def",
"do_sort",
"(",
"value",
",",
"case_sensitive",
"=",
"False",
")",
":",
"if",
"not",
"case_sensitive",
":",
"def",
"sort_func",
"(",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"basestring",
")",
":",
"item",
"=",
"item",
".",
"lower... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_default | If the value is undefined it will return the passed default value,
otherwise the value of the variable:
.. sourcecode:: jinja
{{ my_variable|default('my_variable is not defined') }}
This will output the value of ``my_variable`` if the variable was
defined, otherwise ``'my_variable is not defi... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_default(value, default_value=u'', boolean=False):
"""If the value is undefined it will return the passed default value,
otherwise the value of the variable:
.. sourcecode:: jinja
{{ my_variable|default('my_variable is not defined') }}
This will output the value of ``my_variable`` if th... | def do_default(value, default_value=u'', boolean=False):
"""If the value is undefined it will return the passed default value,
otherwise the value of the variable:
.. sourcecode:: jinja
{{ my_variable|default('my_variable is not defined') }}
This will output the value of ``my_variable`` if th... | [
"If",
"the",
"value",
"is",
"undefined",
"it",
"will",
"return",
"the",
"passed",
"default",
"value",
"otherwise",
"the",
"value",
"of",
"the",
"variable",
":"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L200-L219 | [
"def",
"do_default",
"(",
"value",
",",
"default_value",
"=",
"u''",
",",
"boolean",
"=",
"False",
")",
":",
"if",
"(",
"boolean",
"and",
"not",
"value",
")",
"or",
"isinstance",
"(",
"value",
",",
"Undefined",
")",
":",
"return",
"default_value",
"retur... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_join | Return a string which is the concatenation of the strings in the
sequence. The separator between elements is an empty string per
default, you can define it with the optional parameter:
.. sourcecode:: jinja
{{ [1, 2, 3]|join('|') }}
-> 1|2|3
{{ [1, 2, 3]|join }}
->... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_join(eval_ctx, value, d=u''):
"""Return a string which is the concatenation of the strings in the
sequence. The separator between elements is an empty string per
default, you can define it with the optional parameter:
.. sourcecode:: jinja
{{ [1, 2, 3]|join('|') }}
-> 1|2|3
... | def do_join(eval_ctx, value, d=u''):
"""Return a string which is the concatenation of the strings in the
sequence. The separator between elements is an empty string per
default, you can define it with the optional parameter:
.. sourcecode:: jinja
{{ [1, 2, 3]|join('|') }}
-> 1|2|3
... | [
"Return",
"a",
"string",
"which",
"is",
"the",
"concatenation",
"of",
"the",
"strings",
"in",
"the",
"sequence",
".",
"The",
"separator",
"between",
"elements",
"is",
"an",
"empty",
"string",
"per",
"default",
"you",
"can",
"define",
"it",
"with",
"the",
"... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L223-L257 | [
"def",
"do_join",
"(",
"eval_ctx",
",",
"value",
",",
"d",
"=",
"u''",
")",
":",
"# no automatic escaping? joining is a lot eaiser then",
"if",
"not",
"eval_ctx",
".",
"autoescape",
":",
"return",
"unicode",
"(",
"d",
")",
".",
"join",
"(",
"imap",
"(",
"un... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_filesizeformat | Format the value like a 'human-readable' file size (i.e. 13 KB,
4.1 MB, 102 bytes, etc). Per default decimal prefixes are used (mega,
giga, etc.), if the second parameter is set to `True` the binary
prefixes are used (mebi, gibi). | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_filesizeformat(value, binary=False):
"""Format the value like a 'human-readable' file size (i.e. 13 KB,
4.1 MB, 102 bytes, etc). Per default decimal prefixes are used (mega,
giga, etc.), if the second parameter is set to `True` the binary
prefixes are used (mebi, gibi).
"""
bytes = float... | def do_filesizeformat(value, binary=False):
"""Format the value like a 'human-readable' file size (i.e. 13 KB,
4.1 MB, 102 bytes, etc). Per default decimal prefixes are used (mega,
giga, etc.), if the second parameter is set to `True` the binary
prefixes are used (mebi, gibi).
"""
bytes = float... | [
"Format",
"the",
"value",
"like",
"a",
"human",
"-",
"readable",
"file",
"size",
"(",
"i",
".",
"e",
".",
"13",
"KB",
"4",
".",
"1",
"MB",
"102",
"bytes",
"etc",
")",
".",
"Per",
"default",
"decimal",
"prefixes",
"are",
"used",
"(",
"mega",
"giga",... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L292-L307 | [
"def",
"do_filesizeformat",
"(",
"value",
",",
"binary",
"=",
"False",
")",
":",
"bytes",
"=",
"float",
"(",
"value",
")",
"base",
"=",
"binary",
"and",
"1024",
"or",
"1000",
"middle",
"=",
"binary",
"and",
"'i'",
"or",
"''",
"if",
"bytes",
"<",
"bas... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_urlize | Converts URLs in plain text into clickable links.
If you pass the filter an additional integer it will shorten the urls
to that number. Also a third argument exists that makes the urls
"nofollow":
.. sourcecode:: jinja
{{ mytext|urlize(40, true) }}
links are shortened to 40 chars ... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_urlize(eval_ctx, value, trim_url_limit=None, nofollow=False):
"""Converts URLs in plain text into clickable links.
If you pass the filter an additional integer it will shorten the urls
to that number. Also a third argument exists that makes the urls
"nofollow":
.. sourcecode:: jinja
... | def do_urlize(eval_ctx, value, trim_url_limit=None, nofollow=False):
"""Converts URLs in plain text into clickable links.
If you pass the filter an additional integer it will shorten the urls
to that number. Also a third argument exists that makes the urls
"nofollow":
.. sourcecode:: jinja
... | [
"Converts",
"URLs",
"in",
"plain",
"text",
"into",
"clickable",
"links",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L320-L335 | [
"def",
"do_urlize",
"(",
"eval_ctx",
",",
"value",
",",
"trim_url_limit",
"=",
"None",
",",
"nofollow",
"=",
"False",
")",
":",
"rv",
"=",
"urlize",
"(",
"value",
",",
"trim_url_limit",
",",
"nofollow",
")",
"if",
"eval_ctx",
".",
"autoescape",
":",
"rv"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_indent | Return a copy of the passed string, each line indented by
4 spaces. The first line is not indented. If you want to
change the number of spaces or indent the first line too
you can pass additional parameters to the filter:
.. sourcecode:: jinja
{{ mytext|indent(2, true) }}
indent by... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_indent(s, width=4, indentfirst=False):
"""Return a copy of the passed string, each line indented by
4 spaces. The first line is not indented. If you want to
change the number of spaces or indent the first line too
you can pass additional parameters to the filter:
.. sourcecode:: jinja
... | def do_indent(s, width=4, indentfirst=False):
"""Return a copy of the passed string, each line indented by
4 spaces. The first line is not indented. If you want to
change the number of spaces or indent the first line too
you can pass additional parameters to the filter:
.. sourcecode:: jinja
... | [
"Return",
"a",
"copy",
"of",
"the",
"passed",
"string",
"each",
"line",
"indented",
"by",
"4",
"spaces",
".",
"The",
"first",
"line",
"is",
"not",
"indented",
".",
"If",
"you",
"want",
"to",
"change",
"the",
"number",
"of",
"spaces",
"or",
"indent",
"t... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L338-L353 | [
"def",
"do_indent",
"(",
"s",
",",
"width",
"=",
"4",
",",
"indentfirst",
"=",
"False",
")",
":",
"indention",
"=",
"u' '",
"*",
"width",
"rv",
"=",
"(",
"u'\\n'",
"+",
"indention",
")",
".",
"join",
"(",
"s",
".",
"splitlines",
"(",
")",
")",
"i... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_truncate | Return a truncated copy of the string. The length is specified
with the first parameter which defaults to ``255``. If the second
parameter is ``true`` the filter will cut the text at length. Otherwise
it will try to save the last word. If the text was in fact
truncated it will append an ellipsis sign (`... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_truncate(s, length=255, killwords=False, end='...'):
"""Return a truncated copy of the string. The length is specified
with the first parameter which defaults to ``255``. If the second
parameter is ``true`` the filter will cut the text at length. Otherwise
it will try to save the last word. If th... | def do_truncate(s, length=255, killwords=False, end='...'):
"""Return a truncated copy of the string. The length is specified
with the first parameter which defaults to ``255``. If the second
parameter is ``true`` the filter will cut the text at length. Otherwise
it will try to save the last word. If th... | [
"Return",
"a",
"truncated",
"copy",
"of",
"the",
"string",
".",
"The",
"length",
"is",
"specified",
"with",
"the",
"first",
"parameter",
"which",
"defaults",
"to",
"255",
".",
"If",
"the",
"second",
"parameter",
"is",
"true",
"the",
"filter",
"will",
"cut"... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L356-L384 | [
"def",
"do_truncate",
"(",
"s",
",",
"length",
"=",
"255",
",",
"killwords",
"=",
"False",
",",
"end",
"=",
"'...'",
")",
":",
"if",
"len",
"(",
"s",
")",
"<=",
"length",
":",
"return",
"s",
"elif",
"killwords",
":",
"return",
"s",
"[",
":",
"len... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_wordwrap | Return a copy of the string passed to the filter wrapped after
``79`` characters. You can override this default using the first
parameter. If you set the second parameter to `false` Jinja will not
split words apart if they are longer than `width`. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_wordwrap(s, width=79, break_long_words=True):
"""
Return a copy of the string passed to the filter wrapped after
``79`` characters. You can override this default using the first
parameter. If you set the second parameter to `false` Jinja will not
split words apart if they are longer than `w... | def do_wordwrap(s, width=79, break_long_words=True):
"""
Return a copy of the string passed to the filter wrapped after
``79`` characters. You can override this default using the first
parameter. If you set the second parameter to `false` Jinja will not
split words apart if they are longer than `w... | [
"Return",
"a",
"copy",
"of",
"the",
"string",
"passed",
"to",
"the",
"filter",
"wrapped",
"after",
"79",
"characters",
".",
"You",
"can",
"override",
"this",
"default",
"using",
"the",
"first",
"parameter",
".",
"If",
"you",
"set",
"the",
"second",
"parame... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L387-L397 | [
"def",
"do_wordwrap",
"(",
"s",
",",
"width",
"=",
"79",
",",
"break_long_words",
"=",
"True",
")",
":",
"import",
"textwrap",
"return",
"u'\\n'",
".",
"join",
"(",
"textwrap",
".",
"wrap",
"(",
"s",
",",
"width",
"=",
"width",
",",
"expand_tabs",
"=",... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_int | Convert the value into an integer. If the
conversion doesn't work it will return ``0``. You can
override this default using the first parameter. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_int(value, default=0):
"""Convert the value into an integer. If the
conversion doesn't work it will return ``0``. You can
override this default using the first parameter.
"""
try:
return int(value)
except (TypeError, ValueError):
# this quirk is necessary so that "42.23"|i... | def do_int(value, default=0):
"""Convert the value into an integer. If the
conversion doesn't work it will return ``0``. You can
override this default using the first parameter.
"""
try:
return int(value)
except (TypeError, ValueError):
# this quirk is necessary so that "42.23"|i... | [
"Convert",
"the",
"value",
"into",
"an",
"integer",
".",
"If",
"the",
"conversion",
"doesn",
"t",
"work",
"it",
"will",
"return",
"0",
".",
"You",
"can",
"override",
"this",
"default",
"using",
"the",
"first",
"parameter",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L405-L417 | [
"def",
"do_int",
"(",
"value",
",",
"default",
"=",
"0",
")",
":",
"try",
":",
"return",
"int",
"(",
"value",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"# this quirk is necessary so that \"42.23\"|int gives 42.",
"try",
":",
"return",
"int"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_striptags | Strip SGML/XML tags and replace adjacent whitespace by one space. | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_striptags(value):
"""Strip SGML/XML tags and replace adjacent whitespace by one space.
"""
if hasattr(value, '__html__'):
value = value.__html__()
return Markup(unicode(value)).striptags() | def do_striptags(value):
"""Strip SGML/XML tags and replace adjacent whitespace by one space.
"""
if hasattr(value, '__html__'):
value = value.__html__()
return Markup(unicode(value)).striptags() | [
"Strip",
"SGML",
"/",
"XML",
"tags",
"and",
"replace",
"adjacent",
"whitespace",
"by",
"one",
"space",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L451-L456 | [
"def",
"do_striptags",
"(",
"value",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'__html__'",
")",
":",
"value",
"=",
"value",
".",
"__html__",
"(",
")",
"return",
"Markup",
"(",
"unicode",
"(",
"value",
")",
")",
".",
"striptags",
"(",
")"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | do_groupby | Group a sequence of objects by a common attribute.
If you for example have a list of dicts or objects that represent persons
with `gender`, `first_name` and `last_name` attributes and you want to
group all users by genders you can do something like the following
snippet:
.. sourcecode:: html+jinja... | pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py | def do_groupby(environment, value, attribute):
"""Group a sequence of objects by a common attribute.
If you for example have a list of dicts or objects that represent persons
with `gender`, `first_name` and `last_name` attributes and you want to
group all users by genders you can do something like the ... | def do_groupby(environment, value, attribute):
"""Group a sequence of objects by a common attribute.
If you for example have a list of dicts or objects that represent persons
with `gender`, `first_name` and `last_name` attributes and you want to
group all users by genders you can do something like the ... | [
"Group",
"a",
"sequence",
"of",
"objects",
"by",
"a",
"common",
"attribute",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L575-L610 | [
"def",
"do_groupby",
"(",
"environment",
",",
"value",
",",
"attribute",
")",
":",
"expr",
"=",
"lambda",
"x",
":",
"environment",
".",
"getitem",
"(",
"x",
",",
"attribute",
")",
"return",
"sorted",
"(",
"map",
"(",
"_GroupTuple",
",",
"groupby",
"(",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | extract_metainfo_files_from_package | Extracts metdata files from the given package to the given folder,
which may be referenced in any way that is permitted in
a requirements.txt file or install_requires=[] listing.
Current supported metadata files that will be extracted:
- pytoml.yml (only if package wasn't obtained as ... | pythonforandroid/pythonpackage.py | def extract_metainfo_files_from_package(
package,
output_folder,
debug=False
):
""" Extracts metdata files from the given package to the given folder,
which may be referenced in any way that is permitted in
a requirements.txt file or install_requires=[] listing.
... | def extract_metainfo_files_from_package(
package,
output_folder,
debug=False
):
""" Extracts metdata files from the given package to the given folder,
which may be referenced in any way that is permitted in
a requirements.txt file or install_requires=[] listing.
... | [
"Extracts",
"metdata",
"files",
"from",
"the",
"given",
"package",
"to",
"the",
"given",
"folder",
"which",
"may",
"be",
"referenced",
"in",
"any",
"way",
"that",
"is",
"permitted",
"in",
"a",
"requirements",
".",
"txt",
"file",
"or",
"install_requires",
"="... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/pythonpackage.py#L74-L143 | [
"def",
"extract_metainfo_files_from_package",
"(",
"package",
",",
"output_folder",
",",
"debug",
"=",
"False",
")",
":",
"if",
"package",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"package cannot be None\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"e... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | _get_system_python_executable | Returns the path the system-wide python binary.
(In case we're running in a virtualenv or venv) | pythonforandroid/pythonpackage.py | def _get_system_python_executable():
""" Returns the path the system-wide python binary.
(In case we're running in a virtualenv or venv)
"""
# This function is required by get_package_as_folder() to work
# inside a virtualenv, since venv creation will fail with
# the virtualenv's local pytho... | def _get_system_python_executable():
""" Returns the path the system-wide python binary.
(In case we're running in a virtualenv or venv)
"""
# This function is required by get_package_as_folder() to work
# inside a virtualenv, since venv creation will fail with
# the virtualenv's local pytho... | [
"Returns",
"the",
"path",
"the",
"system",
"-",
"wide",
"python",
"binary",
".",
"(",
"In",
"case",
"we",
"re",
"running",
"in",
"a",
"virtualenv",
"or",
"venv",
")"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/pythonpackage.py#L146-L231 | [
"def",
"_get_system_python_executable",
"(",
")",
":",
"# This function is required by get_package_as_folder() to work",
"# inside a virtualenv, since venv creation will fail with",
"# the virtualenv's local python binary.",
"# (venv/virtualenv incompatibility)",
"# Abort if not in virtualenv or v... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | get_package_as_folder | This function downloads the given package / dependency and extracts
the raw contents into a folder.
Afterwards, it returns a tuple with the type of distribution obtained,
and the temporary folder it extracted to. It is the caller's
responsibility to delete the returned temp folder after... | pythonforandroid/pythonpackage.py | def get_package_as_folder(dependency):
""" This function downloads the given package / dependency and extracts
the raw contents into a folder.
Afterwards, it returns a tuple with the type of distribution obtained,
and the temporary folder it extracted to. It is the caller's
responsi... | def get_package_as_folder(dependency):
""" This function downloads the given package / dependency and extracts
the raw contents into a folder.
Afterwards, it returns a tuple with the type of distribution obtained,
and the temporary folder it extracted to. It is the caller's
responsi... | [
"This",
"function",
"downloads",
"the",
"given",
"package",
"/",
"dependency",
"and",
"extracts",
"the",
"raw",
"contents",
"into",
"a",
"folder",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/pythonpackage.py#L234-L386 | [
"def",
"get_package_as_folder",
"(",
"dependency",
")",
":",
"venv_parent",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"\"pythonpackage-venv-\"",
")",
"try",
":",
"# Create a venv to install into:",
"try",
":",
"if",
"int",
"(",
"sys",
".",
"version",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | parse_as_folder_reference | See if a dependency reference refers to a folder path.
If it does, return the folder path (which parses and
resolves file:// urls in the process).
If it doesn't, return None. | pythonforandroid/pythonpackage.py | def parse_as_folder_reference(dep):
""" See if a dependency reference refers to a folder path.
If it does, return the folder path (which parses and
resolves file:// urls in the process).
If it doesn't, return None.
"""
# Special case: pep508 urls
if dep.find("@") > 0 and (
... | def parse_as_folder_reference(dep):
""" See if a dependency reference refers to a folder path.
If it does, return the folder path (which parses and
resolves file:// urls in the process).
If it doesn't, return None.
"""
# Special case: pep508 urls
if dep.find("@") > 0 and (
... | [
"See",
"if",
"a",
"dependency",
"reference",
"refers",
"to",
"a",
"folder",
"path",
".",
"If",
"it",
"does",
"return",
"the",
"folder",
"path",
"(",
"which",
"parses",
"and",
"resolves",
"file",
":",
"//",
"urls",
"in",
"the",
"process",
")",
".",
"If"... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/pythonpackage.py#L479-L501 | [
"def",
"parse_as_folder_reference",
"(",
"dep",
")",
":",
"# Special case: pep508 urls",
"if",
"dep",
".",
"find",
"(",
"\"@\"",
")",
">",
"0",
"and",
"(",
"(",
"dep",
".",
"find",
"(",
"\"@\"",
")",
"<",
"dep",
".",
"find",
"(",
"\"/\"",
")",
"or",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | _extract_info_from_package | Internal function to extract metainfo from a package.
Currently supported info types:
- name
- dependencies (a list of dependencies) | pythonforandroid/pythonpackage.py | def _extract_info_from_package(dependency,
extract_type=None,
debug=False,
include_build_requirements=False
):
""" Internal function to extract metainfo from a package.
Currently suppo... | def _extract_info_from_package(dependency,
extract_type=None,
debug=False,
include_build_requirements=False
):
""" Internal function to extract metainfo from a package.
Currently suppo... | [
"Internal",
"function",
"to",
"extract",
"metainfo",
"from",
"a",
"package",
".",
"Currently",
"supported",
"info",
"types",
":"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/pythonpackage.py#L504-L554 | [
"def",
"_extract_info_from_package",
"(",
"dependency",
",",
"extract_type",
"=",
"None",
",",
"debug",
"=",
"False",
",",
"include_build_requirements",
"=",
"False",
")",
":",
"output_folder",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"\"pythonpackage-... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | get_package_dependencies | Obtain the dependencies from a package. Please note this
function is possibly SLOW, especially if you enable
the recursive mode. | pythonforandroid/pythonpackage.py | def get_package_dependencies(package,
recursive=False,
verbose=False,
include_build_requirements=False):
""" Obtain the dependencies from a package. Please note this
function is possibly SLOW, especially if you enable
... | def get_package_dependencies(package,
recursive=False,
verbose=False,
include_build_requirements=False):
""" Obtain the dependencies from a package. Please note this
function is possibly SLOW, especially if you enable
... | [
"Obtain",
"the",
"dependencies",
"from",
"a",
"package",
".",
"Please",
"note",
"this",
"function",
"is",
"possibly",
"SLOW",
"especially",
"if",
"you",
"enable",
"the",
"recursive",
"mode",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/pythonpackage.py#L578-L653 | [
"def",
"get_package_dependencies",
"(",
"package",
",",
"recursive",
"=",
"False",
",",
"verbose",
"=",
"False",
",",
"include_build_requirements",
"=",
"False",
")",
":",
"packages_processed",
"=",
"set",
"(",
")",
"package_queue",
"=",
"[",
"package",
"]",
"... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | get_dep_names_of_package | Gets the dependencies from the package in the given folder,
then attempts to deduce the actual package name resulting
from each dependency line, stripping away everything else. | pythonforandroid/pythonpackage.py | def get_dep_names_of_package(
package,
keep_version_pins=False,
recursive=False,
verbose=False,
include_build_requirements=False
):
""" Gets the dependencies from the package in the given folder,
then attempts to deduce the actual package name resulting
... | def get_dep_names_of_package(
package,
keep_version_pins=False,
recursive=False,
verbose=False,
include_build_requirements=False
):
""" Gets the dependencies from the package in the given folder,
then attempts to deduce the actual package name resulting
... | [
"Gets",
"the",
"dependencies",
"from",
"the",
"package",
"in",
"the",
"given",
"folder",
"then",
"attempts",
"to",
"deduce",
"the",
"actual",
"package",
"name",
"resulting",
"from",
"each",
"dependency",
"line",
"stripping",
"away",
"everything",
"else",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/pythonpackage.py#L656-L693 | [
"def",
"get_dep_names_of_package",
"(",
"package",
",",
"keep_version_pins",
"=",
"False",
",",
"recursive",
"=",
"False",
",",
"verbose",
"=",
"False",
",",
"include_build_requirements",
"=",
"False",
")",
":",
"# First, obtain the dependencies:",
"dependencies",
"="... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | run_pymodules_install | This function will take care of all non-recipe things, by:
1. Processing them from --requirements (the modules argument)
and installing them
2. Installing the user project/app itself via setup.py if
ignore_setup_py=True | pythonforandroid/build.py | def run_pymodules_install(ctx, modules, project_dir, ignore_setup_py=False):
""" This function will take care of all non-recipe things, by:
1. Processing them from --requirements (the modules argument)
and installing them
2. Installing the user project/app itself via setup.py if
... | def run_pymodules_install(ctx, modules, project_dir, ignore_setup_py=False):
""" This function will take care of all non-recipe things, by:
1. Processing them from --requirements (the modules argument)
and installing them
2. Installing the user project/app itself via setup.py if
... | [
"This",
"function",
"will",
"take",
"care",
"of",
"all",
"non",
"-",
"recipe",
"things",
"by",
":"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/build.py#L596-L806 | [
"def",
"run_pymodules_install",
"(",
"ctx",
",",
"modules",
",",
"project_dir",
",",
"ignore_setup_py",
"=",
"False",
")",
":",
"info",
"(",
"'*** PYTHON PACKAGE / PROJECT INSTALL STAGE ***'",
")",
"modules",
"=",
"list",
"(",
"filter",
"(",
"ctx",
".",
"not_has_p... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Context.setup_dirs | Calculates all the storage and build dirs, and makes sure
the directories exist where necessary. | pythonforandroid/build.py | def setup_dirs(self, storage_dir):
'''Calculates all the storage and build dirs, and makes sure
the directories exist where necessary.'''
self.storage_dir = expanduser(storage_dir)
if ' ' in self.storage_dir:
raise ValueError('storage dir path cannot contain spaces, please '
... | def setup_dirs(self, storage_dir):
'''Calculates all the storage and build dirs, and makes sure
the directories exist where necessary.'''
self.storage_dir = expanduser(storage_dir)
if ' ' in self.storage_dir:
raise ValueError('storage dir path cannot contain spaces, please '
... | [
"Calculates",
"all",
"the",
"storage",
"and",
"build",
"dirs",
"and",
"makes",
"sure",
"the",
"directories",
"exist",
"where",
"necessary",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/build.py#L107-L115 | [
"def",
"setup_dirs",
"(",
"self",
",",
"storage_dir",
")",
":",
"self",
".",
"storage_dir",
"=",
"expanduser",
"(",
"storage_dir",
")",
"if",
"' '",
"in",
"self",
".",
"storage_dir",
":",
"raise",
"ValueError",
"(",
"'storage dir path cannot contain spaces, please... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Context.prepare_build_environment | Checks that build dependencies exist and sets internal variables
for the Android SDK etc.
..warning:: This *must* be called before trying any build stuff | pythonforandroid/build.py | def prepare_build_environment(self,
user_sdk_dir,
user_ndk_dir,
user_android_api,
user_ndk_api):
'''Checks that build dependencies exist and sets internal variables
for... | def prepare_build_environment(self,
user_sdk_dir,
user_ndk_dir,
user_android_api,
user_ndk_api):
'''Checks that build dependencies exist and sets internal variables
for... | [
"Checks",
"that",
"build",
"dependencies",
"exist",
"and",
"sets",
"internal",
"variables",
"for",
"the",
"Android",
"SDK",
"etc",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/build.py#L176-L409 | [
"def",
"prepare_build_environment",
"(",
"self",
",",
"user_sdk_dir",
",",
"user_ndk_dir",
",",
"user_android_api",
",",
"user_ndk_api",
")",
":",
"self",
".",
"ensure_dirs",
"(",
")",
"if",
"self",
".",
"_build_env_prepared",
":",
"return",
"ok",
"=",
"True",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Context.get_site_packages_dir | Returns the location of site-packages in the python-install build
dir. | pythonforandroid/build.py | def get_site_packages_dir(self, arch=None):
'''Returns the location of site-packages in the python-install build
dir.
'''
if self.python_recipe.name == 'python2legacy':
return join(self.get_python_install_dir(),
'lib', 'python2.7', 'site-packages')
... | def get_site_packages_dir(self, arch=None):
'''Returns the location of site-packages in the python-install build
dir.
'''
if self.python_recipe.name == 'python2legacy':
return join(self.get_python_install_dir(),
'lib', 'python2.7', 'site-packages')
... | [
"Returns",
"the",
"location",
"of",
"site",
"-",
"packages",
"in",
"the",
"python",
"-",
"install",
"build",
"dir",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/build.py#L470-L477 | [
"def",
"get_site_packages_dir",
"(",
"self",
",",
"arch",
"=",
"None",
")",
":",
"if",
"self",
".",
"python_recipe",
".",
"name",
"==",
"'python2legacy'",
":",
"return",
"join",
"(",
"self",
".",
"get_python_install_dir",
"(",
")",
",",
"'lib'",
",",
"'pyt... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | Context.get_libs_dir | The libs dir for a given arch. | pythonforandroid/build.py | def get_libs_dir(self, arch):
'''The libs dir for a given arch.'''
ensure_dir(join(self.libs_dir, arch))
return join(self.libs_dir, arch) | def get_libs_dir(self, arch):
'''The libs dir for a given arch.'''
ensure_dir(join(self.libs_dir, arch))
return join(self.libs_dir, arch) | [
"The",
"libs",
"dir",
"for",
"a",
"given",
"arch",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/build.py#L479-L482 | [
"def",
"get_libs_dir",
"(",
"self",
",",
"arch",
")",
":",
"ensure_dir",
"(",
"join",
"(",
"self",
".",
"libs_dir",
",",
"arch",
")",
")",
"return",
"join",
"(",
"self",
".",
"libs_dir",
",",
"arch",
")"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | shorten_string | make limited length string in form:
"the string is very lo...(and 15 more)" | pythonforandroid/logger.py | def shorten_string(string, max_width):
''' make limited length string in form:
"the string is very lo...(and 15 more)"
'''
string_len = len(string)
if string_len <= max_width:
return string
visible = max_width - 16 - int(log10(string_len))
# expected suffix len "...(and XXXXX more)... | def shorten_string(string, max_width):
''' make limited length string in form:
"the string is very lo...(and 15 more)"
'''
string_len = len(string)
if string_len <= max_width:
return string
visible = max_width - 16 - int(log10(string_len))
# expected suffix len "...(and XXXXX more)... | [
"make",
"limited",
"length",
"string",
"in",
"form",
":",
"the",
"string",
"is",
"very",
"lo",
"...",
"(",
"and",
"15",
"more",
")"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/logger.py#L106-L120 | [
"def",
"shorten_string",
"(",
"string",
",",
"max_width",
")",
":",
"string_len",
"=",
"len",
"(",
"string",
")",
"if",
"string_len",
"<=",
"max_width",
":",
"return",
"string",
"visible",
"=",
"max_width",
"-",
"16",
"-",
"int",
"(",
"log10",
"(",
"stri... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | shprint | Runs the command (which should be an sh.Command instance), while
logging the output. | pythonforandroid/logger.py | def shprint(command, *args, **kwargs):
'''Runs the command (which should be an sh.Command instance), while
logging the output.'''
kwargs["_iter"] = True
kwargs["_out_bufsize"] = 1
kwargs["_err_to_out"] = True
kwargs["_bg"] = True
is_critical = kwargs.pop('_critical', False)
tail_n = kwar... | def shprint(command, *args, **kwargs):
'''Runs the command (which should be an sh.Command instance), while
logging the output.'''
kwargs["_iter"] = True
kwargs["_out_bufsize"] = 1
kwargs["_err_to_out"] = True
kwargs["_bg"] = True
is_critical = kwargs.pop('_critical', False)
tail_n = kwar... | [
"Runs",
"the",
"command",
"(",
"which",
"should",
"be",
"an",
"sh",
".",
"Command",
"instance",
")",
"while",
"logging",
"the",
"output",
"."
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/logger.py#L142-L243 | [
"def",
"shprint",
"(",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"_iter\"",
"]",
"=",
"True",
"kwargs",
"[",
"\"_out_bufsize\"",
"]",
"=",
"1",
"kwargs",
"[",
"\"_err_to_out\"",
"]",
"=",
"True",
"kwargs",
"[",
... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | _ActionsContainer.add_argument | add_argument(dest, ..., name=value, ...)
add_argument(option_string, option_string, ..., name=value, ...) | pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py | def add_argument(self, *args, **kwargs):
"""
add_argument(dest, ..., name=value, ...)
add_argument(option_string, option_string, ..., name=value, ...)
"""
# if no positional args are supplied or only one is supplied and
# it doesn't look like an option string, par... | def add_argument(self, *args, **kwargs):
"""
add_argument(dest, ..., name=value, ...)
add_argument(option_string, option_string, ..., name=value, ...)
"""
# if no positional args are supplied or only one is supplied and
# it doesn't look like an option string, par... | [
"add_argument",
"(",
"dest",
"...",
"name",
"=",
"value",
"...",
")",
"add_argument",
"(",
"option_string",
"option_string",
"...",
"name",
"=",
"value",
"...",
")"
] | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py#L1276-L1314 | [
"def",
"add_argument",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# if no positional args are supplied or only one is supplied and\r",
"# it doesn't look like an option string, parse a positional\r",
"# argument\r",
"chars",
"=",
"self",
".",
"prefix_c... | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | ArgumentParser.error | error(message: string)
Prints a usage message incorporating the message to stderr and
exits.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception. | pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py | def error(self, message):
"""error(message: string)
Prints a usage message incorporating the message to stderr and
exits.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
"""
self.print_usage(_sys.... | def error(self, message):
"""error(message: string)
Prints a usage message incorporating the message to stderr and
exits.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
"""
self.print_usage(_sys.... | [
"error",
"(",
"message",
":",
"string",
")",
"Prints",
"a",
"usage",
"message",
"incorporating",
"the",
"message",
"to",
"stderr",
"and",
"exits",
".",
"If",
"you",
"override",
"this",
"in",
"a",
"subclass",
"it",
"should",
"not",
"return",
"--",
"it",
"... | kivy/python-for-android | python | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py#L2348-L2358 | [
"def",
"error",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"print_usage",
"(",
"_sys",
".",
"stderr",
")",
"self",
".",
"exit",
"(",
"2",
",",
"_",
"(",
"'%s: error: %s\\n'",
")",
"%",
"(",
"self",
".",
"prog",
",",
"message",
")",
")"
] | 8e0e8056bc22e4d5bd3398a6b0301f38ff167933 |
train | isexception | Given an object, return a boolean indicating whether it is an instance
or subclass of :py:class:`Exception`. | records.py | def isexception(obj):
"""Given an object, return a boolean indicating whether it is an instance
or subclass of :py:class:`Exception`.
"""
if isinstance(obj, Exception):
return True
if isclass(obj) and issubclass(obj, Exception):
return True
return False | def isexception(obj):
"""Given an object, return a boolean indicating whether it is an instance
or subclass of :py:class:`Exception`.
"""
if isinstance(obj, Exception):
return True
if isclass(obj) and issubclass(obj, Exception):
return True
return False | [
"Given",
"an",
"object",
"return",
"a",
"boolean",
"indicating",
"whether",
"it",
"is",
"an",
"instance",
"or",
"subclass",
"of",
":",
"py",
":",
"class",
":",
"Exception",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L16-L24 | [
"def",
"isexception",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"Exception",
")",
":",
"return",
"True",
"if",
"isclass",
"(",
"obj",
")",
"and",
"issubclass",
"(",
"obj",
",",
"Exception",
")",
":",
"return",
"True",
"return",
"False"... | ecd857266c5e7830d657cbe0196816314790563b |
train | _reduce_datetimes | Receives a row, converts datetimes to strings. | records.py | def _reduce_datetimes(row):
"""Receives a row, converts datetimes to strings."""
row = list(row)
for i in range(len(row)):
if hasattr(row[i], 'isoformat'):
row[i] = row[i].isoformat()
return tuple(row) | def _reduce_datetimes(row):
"""Receives a row, converts datetimes to strings."""
row = list(row)
for i in range(len(row)):
if hasattr(row[i], 'isoformat'):
row[i] = row[i].isoformat()
return tuple(row) | [
"Receives",
"a",
"row",
"converts",
"datetimes",
"to",
"strings",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L424-L432 | [
"def",
"_reduce_datetimes",
"(",
"row",
")",
":",
"row",
"=",
"list",
"(",
"row",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"row",
")",
")",
":",
"if",
"hasattr",
"(",
"row",
"[",
"i",
"]",
",",
"'isoformat'",
")",
":",
"row",
"[",
"i",
... | ecd857266c5e7830d657cbe0196816314790563b |
train | Record.as_dict | Returns the row as a dictionary, as ordered. | records.py | def as_dict(self, ordered=False):
"""Returns the row as a dictionary, as ordered."""
items = zip(self.keys(), self.values())
return OrderedDict(items) if ordered else dict(items) | def as_dict(self, ordered=False):
"""Returns the row as a dictionary, as ordered."""
items = zip(self.keys(), self.values())
return OrderedDict(items) if ordered else dict(items) | [
"Returns",
"the",
"row",
"as",
"a",
"dictionary",
"as",
"ordered",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L81-L85 | [
"def",
"as_dict",
"(",
"self",
",",
"ordered",
"=",
"False",
")",
":",
"items",
"=",
"zip",
"(",
"self",
".",
"keys",
"(",
")",
",",
"self",
".",
"values",
"(",
")",
")",
"return",
"OrderedDict",
"(",
"items",
")",
"if",
"ordered",
"else",
"dict",
... | ecd857266c5e7830d657cbe0196816314790563b |
train | Record.dataset | A Tablib Dataset containing the row. | records.py | def dataset(self):
"""A Tablib Dataset containing the row."""
data = tablib.Dataset()
data.headers = self.keys()
row = _reduce_datetimes(self.values())
data.append(row)
return data | def dataset(self):
"""A Tablib Dataset containing the row."""
data = tablib.Dataset()
data.headers = self.keys()
row = _reduce_datetimes(self.values())
data.append(row)
return data | [
"A",
"Tablib",
"Dataset",
"containing",
"the",
"row",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L88-L96 | [
"def",
"dataset",
"(",
"self",
")",
":",
"data",
"=",
"tablib",
".",
"Dataset",
"(",
")",
"data",
".",
"headers",
"=",
"self",
".",
"keys",
"(",
")",
"row",
"=",
"_reduce_datetimes",
"(",
"self",
".",
"values",
"(",
")",
")",
"data",
".",
"append",... | ecd857266c5e7830d657cbe0196816314790563b |
train | RecordCollection.dataset | A Tablib Dataset representation of the RecordCollection. | records.py | def dataset(self):
"""A Tablib Dataset representation of the RecordCollection."""
# Create a new Tablib Dataset.
data = tablib.Dataset()
# If the RecordCollection is empty, just return the empty set
# Check number of rows by typecasting to list
if len(list(self)) == 0:
... | def dataset(self):
"""A Tablib Dataset representation of the RecordCollection."""
# Create a new Tablib Dataset.
data = tablib.Dataset()
# If the RecordCollection is empty, just return the empty set
# Check number of rows by typecasting to list
if len(list(self)) == 0:
... | [
"A",
"Tablib",
"Dataset",
"representation",
"of",
"the",
"RecordCollection",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L170-L188 | [
"def",
"dataset",
"(",
"self",
")",
":",
"# Create a new Tablib Dataset.",
"data",
"=",
"tablib",
".",
"Dataset",
"(",
")",
"# If the RecordCollection is empty, just return the empty set",
"# Check number of rows by typecasting to list",
"if",
"len",
"(",
"list",
"(",
"self... | ecd857266c5e7830d657cbe0196816314790563b |
train | RecordCollection.all | Returns a list of all rows for the RecordCollection. If they haven't
been fetched yet, consume the iterator and cache the results. | records.py | def all(self, as_dict=False, as_ordereddict=False):
"""Returns a list of all rows for the RecordCollection. If they haven't
been fetched yet, consume the iterator and cache the results."""
# By calling list it calls the __iter__ method
rows = list(self)
if as_dict:
... | def all(self, as_dict=False, as_ordereddict=False):
"""Returns a list of all rows for the RecordCollection. If they haven't
been fetched yet, consume the iterator and cache the results."""
# By calling list it calls the __iter__ method
rows = list(self)
if as_dict:
... | [
"Returns",
"a",
"list",
"of",
"all",
"rows",
"for",
"the",
"RecordCollection",
".",
"If",
"they",
"haven",
"t",
"been",
"fetched",
"yet",
"consume",
"the",
"iterator",
"and",
"cache",
"the",
"results",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L190-L202 | [
"def",
"all",
"(",
"self",
",",
"as_dict",
"=",
"False",
",",
"as_ordereddict",
"=",
"False",
")",
":",
"# By calling list it calls the __iter__ method",
"rows",
"=",
"list",
"(",
"self",
")",
"if",
"as_dict",
":",
"return",
"[",
"r",
".",
"as_dict",
"(",
... | ecd857266c5e7830d657cbe0196816314790563b |
train | RecordCollection.first | Returns a single record for the RecordCollection, or `default`. If
`default` is an instance or subclass of Exception, then raise it
instead of returning it. | records.py | def first(self, default=None, as_dict=False, as_ordereddict=False):
"""Returns a single record for the RecordCollection, or `default`. If
`default` is an instance or subclass of Exception, then raise it
instead of returning it."""
# Try to get a record, or return/raise default.
... | def first(self, default=None, as_dict=False, as_ordereddict=False):
"""Returns a single record for the RecordCollection, or `default`. If
`default` is an instance or subclass of Exception, then raise it
instead of returning it."""
# Try to get a record, or return/raise default.
... | [
"Returns",
"a",
"single",
"record",
"for",
"the",
"RecordCollection",
"or",
"default",
".",
"If",
"default",
"is",
"an",
"instance",
"or",
"subclass",
"of",
"Exception",
"then",
"raise",
"it",
"instead",
"of",
"returning",
"it",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L207-L226 | [
"def",
"first",
"(",
"self",
",",
"default",
"=",
"None",
",",
"as_dict",
"=",
"False",
",",
"as_ordereddict",
"=",
"False",
")",
":",
"# Try to get a record, or return/raise default.",
"try",
":",
"record",
"=",
"self",
"[",
"0",
"]",
"except",
"IndexError",
... | ecd857266c5e7830d657cbe0196816314790563b |
train | RecordCollection.one | Returns a single record for the RecordCollection, ensuring that it
is the only record, or returns `default`. If `default` is an instance
or subclass of Exception, then raise it instead of returning it. | records.py | def one(self, default=None, as_dict=False, as_ordereddict=False):
"""Returns a single record for the RecordCollection, ensuring that it
is the only record, or returns `default`. If `default` is an instance
or subclass of Exception, then raise it instead of returning it."""
# Ensure that... | def one(self, default=None, as_dict=False, as_ordereddict=False):
"""Returns a single record for the RecordCollection, ensuring that it
is the only record, or returns `default`. If `default` is an instance
or subclass of Exception, then raise it instead of returning it."""
# Ensure that... | [
"Returns",
"a",
"single",
"record",
"for",
"the",
"RecordCollection",
"ensuring",
"that",
"it",
"is",
"the",
"only",
"record",
"or",
"returns",
"default",
".",
"If",
"default",
"is",
"an",
"instance",
"or",
"subclass",
"of",
"Exception",
"then",
"raise",
"it... | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L228-L241 | [
"def",
"one",
"(",
"self",
",",
"default",
"=",
"None",
",",
"as_dict",
"=",
"False",
",",
"as_ordereddict",
"=",
"False",
")",
":",
"# Ensure that we don't have more than one row.",
"try",
":",
"self",
"[",
"1",
"]",
"except",
"IndexError",
":",
"return",
"... | ecd857266c5e7830d657cbe0196816314790563b |
train | Database.get_connection | Get a connection to this Database. Connections are retrieved from a
pool. | records.py | def get_connection(self):
"""Get a connection to this Database. Connections are retrieved from a
pool.
"""
if not self.open:
raise exc.ResourceClosedError('Database closed.')
return Connection(self._engine.connect()) | def get_connection(self):
"""Get a connection to this Database. Connections are retrieved from a
pool.
"""
if not self.open:
raise exc.ResourceClosedError('Database closed.')
return Connection(self._engine.connect()) | [
"Get",
"a",
"connection",
"to",
"this",
"Database",
".",
"Connections",
"are",
"retrieved",
"from",
"a",
"pool",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L285-L292 | [
"def",
"get_connection",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"open",
":",
"raise",
"exc",
".",
"ResourceClosedError",
"(",
"'Database closed.'",
")",
"return",
"Connection",
"(",
"self",
".",
"_engine",
".",
"connect",
"(",
")",
")"
] | ecd857266c5e7830d657cbe0196816314790563b |
train | Database.query | Executes the given SQL query against the Database. Parameters can,
optionally, be provided. Returns a RecordCollection, which can be
iterated over to get result rows as dictionaries. | records.py | def query(self, query, fetchall=False, **params):
"""Executes the given SQL query against the Database. Parameters can,
optionally, be provided. Returns a RecordCollection, which can be
iterated over to get result rows as dictionaries.
"""
with self.get_connection() as conn:
... | def query(self, query, fetchall=False, **params):
"""Executes the given SQL query against the Database. Parameters can,
optionally, be provided. Returns a RecordCollection, which can be
iterated over to get result rows as dictionaries.
"""
with self.get_connection() as conn:
... | [
"Executes",
"the",
"given",
"SQL",
"query",
"against",
"the",
"Database",
".",
"Parameters",
"can",
"optionally",
"be",
"provided",
".",
"Returns",
"a",
"RecordCollection",
"which",
"can",
"be",
"iterated",
"over",
"to",
"get",
"result",
"rows",
"as",
"diction... | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L294-L300 | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"fetchall",
"=",
"False",
",",
"*",
"*",
"params",
")",
":",
"with",
"self",
".",
"get_connection",
"(",
")",
"as",
"conn",
":",
"return",
"conn",
".",
"query",
"(",
"query",
",",
"fetchall",
",",
"*"... | ecd857266c5e7830d657cbe0196816314790563b |
train | Database.bulk_query | Bulk insert or update. | records.py | def bulk_query(self, query, *multiparams):
"""Bulk insert or update."""
with self.get_connection() as conn:
conn.bulk_query(query, *multiparams) | def bulk_query(self, query, *multiparams):
"""Bulk insert or update."""
with self.get_connection() as conn:
conn.bulk_query(query, *multiparams) | [
"Bulk",
"insert",
"or",
"update",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L302-L306 | [
"def",
"bulk_query",
"(",
"self",
",",
"query",
",",
"*",
"multiparams",
")",
":",
"with",
"self",
".",
"get_connection",
"(",
")",
"as",
"conn",
":",
"conn",
".",
"bulk_query",
"(",
"query",
",",
"*",
"multiparams",
")"
] | ecd857266c5e7830d657cbe0196816314790563b |
train | Database.query_file | Like Database.query, but takes a filename to load a query from. | records.py | def query_file(self, path, fetchall=False, **params):
"""Like Database.query, but takes a filename to load a query from."""
with self.get_connection() as conn:
return conn.query_file(path, fetchall, **params) | def query_file(self, path, fetchall=False, **params):
"""Like Database.query, but takes a filename to load a query from."""
with self.get_connection() as conn:
return conn.query_file(path, fetchall, **params) | [
"Like",
"Database",
".",
"query",
"but",
"takes",
"a",
"filename",
"to",
"load",
"a",
"query",
"from",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L308-L312 | [
"def",
"query_file",
"(",
"self",
",",
"path",
",",
"fetchall",
"=",
"False",
",",
"*",
"*",
"params",
")",
":",
"with",
"self",
".",
"get_connection",
"(",
")",
"as",
"conn",
":",
"return",
"conn",
".",
"query_file",
"(",
"path",
",",
"fetchall",
",... | ecd857266c5e7830d657cbe0196816314790563b |
train | Database.bulk_query_file | Like Database.bulk_query, but takes a filename to load a query from. | records.py | def bulk_query_file(self, path, *multiparams):
"""Like Database.bulk_query, but takes a filename to load a query from."""
with self.get_connection() as conn:
conn.bulk_query_file(path, *multiparams) | def bulk_query_file(self, path, *multiparams):
"""Like Database.bulk_query, but takes a filename to load a query from."""
with self.get_connection() as conn:
conn.bulk_query_file(path, *multiparams) | [
"Like",
"Database",
".",
"bulk_query",
"but",
"takes",
"a",
"filename",
"to",
"load",
"a",
"query",
"from",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L314-L318 | [
"def",
"bulk_query_file",
"(",
"self",
",",
"path",
",",
"*",
"multiparams",
")",
":",
"with",
"self",
".",
"get_connection",
"(",
")",
"as",
"conn",
":",
"conn",
".",
"bulk_query_file",
"(",
"path",
",",
"*",
"multiparams",
")"
] | ecd857266c5e7830d657cbe0196816314790563b |
train | Database.transaction | A context manager for executing a transaction on this Database. | records.py | def transaction(self):
"""A context manager for executing a transaction on this Database."""
conn = self.get_connection()
tx = conn.transaction()
try:
yield conn
tx.commit()
except:
tx.rollback()
finally:
conn.close() | def transaction(self):
"""A context manager for executing a transaction on this Database."""
conn = self.get_connection()
tx = conn.transaction()
try:
yield conn
tx.commit()
except:
tx.rollback()
finally:
conn.close() | [
"A",
"context",
"manager",
"for",
"executing",
"a",
"transaction",
"on",
"this",
"Database",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L321-L332 | [
"def",
"transaction",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"get_connection",
"(",
")",
"tx",
"=",
"conn",
".",
"transaction",
"(",
")",
"try",
":",
"yield",
"conn",
"tx",
".",
"commit",
"(",
")",
"except",
":",
"tx",
".",
"rollback",
"(... | ecd857266c5e7830d657cbe0196816314790563b |
train | Connection.query | Executes the given SQL query against the connected Database.
Parameters can, optionally, be provided. Returns a RecordCollection,
which can be iterated over to get result rows as dictionaries. | records.py | def query(self, query, fetchall=False, **params):
"""Executes the given SQL query against the connected Database.
Parameters can, optionally, be provided. Returns a RecordCollection,
which can be iterated over to get result rows as dictionaries.
"""
# Execute the given query.
... | def query(self, query, fetchall=False, **params):
"""Executes the given SQL query against the connected Database.
Parameters can, optionally, be provided. Returns a RecordCollection,
which can be iterated over to get result rows as dictionaries.
"""
# Execute the given query.
... | [
"Executes",
"the",
"given",
"SQL",
"query",
"against",
"the",
"connected",
"Database",
".",
"Parameters",
"can",
"optionally",
"be",
"provided",
".",
"Returns",
"a",
"RecordCollection",
"which",
"can",
"be",
"iterated",
"over",
"to",
"get",
"result",
"rows",
"... | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L355-L374 | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"fetchall",
"=",
"False",
",",
"*",
"*",
"params",
")",
":",
"# Execute the given query.",
"cursor",
"=",
"self",
".",
"_conn",
".",
"execute",
"(",
"text",
"(",
"query",
")",
",",
"*",
"*",
"params",
"... | ecd857266c5e7830d657cbe0196816314790563b |
train | Connection.bulk_query | Bulk insert or update. | records.py | def bulk_query(self, query, *multiparams):
"""Bulk insert or update."""
self._conn.execute(text(query), *multiparams) | def bulk_query(self, query, *multiparams):
"""Bulk insert or update."""
self._conn.execute(text(query), *multiparams) | [
"Bulk",
"insert",
"or",
"update",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L376-L379 | [
"def",
"bulk_query",
"(",
"self",
",",
"query",
",",
"*",
"multiparams",
")",
":",
"self",
".",
"_conn",
".",
"execute",
"(",
"text",
"(",
"query",
")",
",",
"*",
"multiparams",
")"
] | ecd857266c5e7830d657cbe0196816314790563b |
train | Connection.query_file | Like Connection.query, but takes a filename to load a query from. | records.py | def query_file(self, path, fetchall=False, **params):
"""Like Connection.query, but takes a filename to load a query from."""
# If path doesn't exists
if not os.path.exists(path):
raise IOError("File '{}' not found!".format(path))
# If it's a directory
if os.path.is... | def query_file(self, path, fetchall=False, **params):
"""Like Connection.query, but takes a filename to load a query from."""
# If path doesn't exists
if not os.path.exists(path):
raise IOError("File '{}' not found!".format(path))
# If it's a directory
if os.path.is... | [
"Like",
"Connection",
".",
"query",
"but",
"takes",
"a",
"filename",
"to",
"load",
"a",
"query",
"from",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L381-L397 | [
"def",
"query_file",
"(",
"self",
",",
"path",
",",
"fetchall",
"=",
"False",
",",
"*",
"*",
"params",
")",
":",
"# If path doesn't exists",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"raise",
"IOError",
"(",
"\"File '{}' not f... | ecd857266c5e7830d657cbe0196816314790563b |
train | Connection.bulk_query_file | Like Connection.bulk_query, but takes a filename to load a query
from. | records.py | def bulk_query_file(self, path, *multiparams):
"""Like Connection.bulk_query, but takes a filename to load a query
from.
"""
# If path doesn't exists
if not os.path.exists(path):
raise IOError("File '{}'' not found!".format(path))
# If it's a directory
... | def bulk_query_file(self, path, *multiparams):
"""Like Connection.bulk_query, but takes a filename to load a query
from.
"""
# If path doesn't exists
if not os.path.exists(path):
raise IOError("File '{}'' not found!".format(path))
# If it's a directory
... | [
"Like",
"Connection",
".",
"bulk_query",
"but",
"takes",
"a",
"filename",
"to",
"load",
"a",
"query",
"from",
"."
] | kennethreitz/records | python | https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L399-L416 | [
"def",
"bulk_query_file",
"(",
"self",
",",
"path",
",",
"*",
"multiparams",
")",
":",
"# If path doesn't exists",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"raise",
"IOError",
"(",
"\"File '{}'' not found!\"",
".",
"format",
"(",... | ecd857266c5e7830d657cbe0196816314790563b |
train | extractWithoutOrder | Select the best match in a list or dictionary of choices.
Find best matches in a list or dictionary of choices, return a
generator of tuples containing the match and its score. If a dictionary
is used, also returns the key for each match.
Arguments:
query: An object representing the thing we w... | fuzzywuzzy/process.py | def extractWithoutOrder(query, choices, processor=default_processor, scorer=default_scorer, score_cutoff=0):
"""Select the best match in a list or dictionary of choices.
Find best matches in a list or dictionary of choices, return a
generator of tuples containing the match and its score. If a dictionary
... | def extractWithoutOrder(query, choices, processor=default_processor, scorer=default_scorer, score_cutoff=0):
"""Select the best match in a list or dictionary of choices.
Find best matches in a list or dictionary of choices, return a
generator of tuples containing the match and its score. If a dictionary
... | [
"Select",
"the",
"best",
"match",
"in",
"a",
"list",
"or",
"dictionary",
"of",
"choices",
"."
] | seatgeek/fuzzywuzzy | python | https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L16-L119 | [
"def",
"extractWithoutOrder",
"(",
"query",
",",
"choices",
",",
"processor",
"=",
"default_processor",
",",
"scorer",
"=",
"default_scorer",
",",
"score_cutoff",
"=",
"0",
")",
":",
"# Catch generators without lengths",
"def",
"no_process",
"(",
"x",
")",
":",
... | 778162c5a73256745eb6ae22f925bc2dbcf7c894 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.