repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
ionelmc/python-cogen | cogen/core/schedulers.py | Scheduler.process_op | def process_op(self, op, coro):
"Process a (op, coro) pair and return another pair. Handles exceptions."
if op is None:
if self.active:
self.active.append((op, coro))
else:
return op, coro
else:
try:
res... | python | def process_op(self, op, coro):
"Process a (op, coro) pair and return another pair. Handles exceptions."
if op is None:
if self.active:
self.active.append((op, coro))
else:
return op, coro
else:
try:
res... | [
"def",
"process_op",
"(",
"self",
",",
"op",
",",
"coro",
")",
":",
"if",
"op",
"is",
"None",
":",
"if",
"self",
".",
"active",
":",
"self",
".",
"active",
".",
"append",
"(",
"(",
"op",
",",
"coro",
")",
")",
"else",
":",
"return",
"op",
",",
... | Process a (op, coro) pair and return another pair. Handles exceptions. | [
"Process",
"a",
"(",
"op",
"coro",
")",
"pair",
"and",
"return",
"another",
"pair",
".",
"Handles",
"exceptions",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/schedulers.py#L162-L176 |
ionelmc/python-cogen | cogen/core/schedulers.py | Scheduler.iter_run | def iter_run(self):
"""
The actual processing for the main loop is here.
Running the main loop as a generator (where a iteration is a full
sched, proactor and timers/timeouts run) is usefull for interleaving
the main loop with other applications that have a blocking main l... | python | def iter_run(self):
"""
The actual processing for the main loop is here.
Running the main loop as a generator (where a iteration is a full
sched, proactor and timers/timeouts run) is usefull for interleaving
the main loop with other applications that have a blocking main l... | [
"def",
"iter_run",
"(",
"self",
")",
":",
"self",
".",
"running",
"=",
"True",
"urgent",
"=",
"None",
"while",
"self",
".",
"running",
"and",
"(",
"self",
".",
"active",
"or",
"self",
".",
"proactor",
"or",
"self",
".",
"timeouts",
"or",
"urgent",
")... | The actual processing for the main loop is here.
Running the main loop as a generator (where a iteration is a full
sched, proactor and timers/timeouts run) is usefull for interleaving
the main loop with other applications that have a blocking main loop and
require cogen to run in t... | [
"The",
"actual",
"processing",
"for",
"the",
"main",
"loop",
"is",
"here",
".",
"Running",
"the",
"main",
"loop",
"as",
"a",
"generator",
"(",
"where",
"a",
"iteration",
"is",
"a",
"full",
"sched",
"proactor",
"and",
"timers",
"/",
"timeouts",
"run",
")"... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/schedulers.py#L178-L212 |
ionelmc/python-cogen | cogen/core/schedulers.py | Scheduler.cleanup | def cleanup(self):
"""Used internally.
Cleans up the sched references in the proactor. If you use this don't use
it while the :class:`Scheduler` (:func:`run`) is still running.
"""
if hasattr(self, 'proactor'):
if hasattr(self.proactor, 'scheduler'):
... | python | def cleanup(self):
"""Used internally.
Cleans up the sched references in the proactor. If you use this don't use
it while the :class:`Scheduler` (:func:`run`) is still running.
"""
if hasattr(self, 'proactor'):
if hasattr(self.proactor, 'scheduler'):
... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'proactor'",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"proactor",
",",
"'scheduler'",
")",
":",
"del",
"self",
".",
"proactor",
".",
"scheduler",
"if",
"hasattr",
"(",
"... | Used internally.
Cleans up the sched references in the proactor. If you use this don't use
it while the :class:`Scheduler` (:func:`run`) is still running. | [
"Used",
"internally",
".",
"Cleans",
"up",
"the",
"sched",
"references",
"in",
"the",
"proactor",
".",
"If",
"you",
"use",
"this",
"don",
"t",
"use",
"it",
"while",
"the",
":",
"class",
":",
"Scheduler",
"(",
":",
"func",
":",
"run",
")",
"is",
"stil... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/schedulers.py#L228-L239 |
seibert-media/Highton | highton/call_mixins/create_note_call_mixin.py | CreateNoteCallMixin.add_note | def add_note(self, body):
"""
Create a Note to current object
:param body: the body of the note
:type body: str
:return: newly created Note
:rtype: Tag
"""
from highton.models.note import Note
created_id = self._post_request(
endpoint=... | python | def add_note(self, body):
"""
Create a Note to current object
:param body: the body of the note
:type body: str
:return: newly created Note
:rtype: Tag
"""
from highton.models.note import Note
created_id = self._post_request(
endpoint=... | [
"def",
"add_note",
"(",
"self",
",",
"body",
")",
":",
"from",
"highton",
".",
"models",
".",
"note",
"import",
"Note",
"created_id",
"=",
"self",
".",
"_post_request",
"(",
"endpoint",
"=",
"self",
".",
"ENDPOINT",
"+",
"'/'",
"+",
"str",
"(",
"self",... | Create a Note to current object
:param body: the body of the note
:type body: str
:return: newly created Note
:rtype: Tag | [
"Create",
"a",
"Note",
"to",
"current",
"object"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/call_mixins/create_note_call_mixin.py#L11-L27 |
shimpe/pyvectortween | vectortween/TimeConversion.py | TimeConversion.hms2frame | def hms2frame(hms, fps):
"""
:param hms: a string, e.g. "01:23:15" for one hour, 23 minutes 15 seconds
:param fps: framerate
:return: frame number
"""
import time
t = time.strptime(hms, "%H:%M:%S")
return (t.tm_hour * 60 * 60 + t.tm_min * 60 + t.tm_sec) ... | python | def hms2frame(hms, fps):
"""
:param hms: a string, e.g. "01:23:15" for one hour, 23 minutes 15 seconds
:param fps: framerate
:return: frame number
"""
import time
t = time.strptime(hms, "%H:%M:%S")
return (t.tm_hour * 60 * 60 + t.tm_min * 60 + t.tm_sec) ... | [
"def",
"hms2frame",
"(",
"hms",
",",
"fps",
")",
":",
"import",
"time",
"t",
"=",
"time",
".",
"strptime",
"(",
"hms",
",",
"\"%H:%M:%S\"",
")",
"return",
"(",
"t",
".",
"tm_hour",
"*",
"60",
"*",
"60",
"+",
"t",
".",
"tm_min",
"*",
"60",
"+",
... | :param hms: a string, e.g. "01:23:15" for one hour, 23 minutes 15 seconds
:param fps: framerate
:return: frame number | [
":",
"param",
"hms",
":",
"a",
"string",
"e",
".",
"g",
".",
"01",
":",
"23",
":",
"15",
"for",
"one",
"hour",
"23",
"minutes",
"15",
"seconds",
":",
"param",
"fps",
":",
"framerate",
":",
"return",
":",
"frame",
"number"
] | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/TimeConversion.py#L19-L27 |
seibert-media/Highton | highton/call_mixins/list_email_call_mixin.py | ListEmailCallMixin.list_emails | def list_emails(self, page=0, since=None):
"""
Get the emails of current object
:param page: the page starting at 0
:type since: int
:param since: get all notes since a datetime
:type since: datetime.datetime
:return: the emails
:rtype: list
"""
... | python | def list_emails(self, page=0, since=None):
"""
Get the emails of current object
:param page: the page starting at 0
:type since: int
:param since: get all notes since a datetime
:type since: datetime.datetime
:return: the emails
:rtype: list
"""
... | [
"def",
"list_emails",
"(",
"self",
",",
"page",
"=",
"0",
",",
"since",
"=",
"None",
")",
":",
"from",
"highton",
".",
"models",
".",
"email",
"import",
"Email",
"params",
"=",
"{",
"'n'",
":",
"int",
"(",
"page",
")",
"*",
"self",
".",
"EMAILS_OFF... | Get the emails of current object
:param page: the page starting at 0
:type since: int
:param since: get all notes since a datetime
:type since: datetime.datetime
:return: the emails
:rtype: list | [
"Get",
"the",
"emails",
"of",
"current",
"object"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/call_mixins/list_email_call_mixin.py#L14-L41 |
shimpe/pyvectortween | vectortween/Tween.py | Tween.tween | def tween(self, t):
"""
t is number between 0 and 1 to indicate how far the tween has progressed
"""
if t is None:
return None
if self.method in self.method_to_tween:
return self.method_to_tween[self.method](t)
elif self.method in self.method_1par... | python | def tween(self, t):
"""
t is number between 0 and 1 to indicate how far the tween has progressed
"""
if t is None:
return None
if self.method in self.method_to_tween:
return self.method_to_tween[self.method](t)
elif self.method in self.method_1par... | [
"def",
"tween",
"(",
"self",
",",
"t",
")",
":",
"if",
"t",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"method",
"in",
"self",
".",
"method_to_tween",
":",
"return",
"self",
".",
"method_to_tween",
"[",
"self",
".",
"method",
"]",
"(",
... | t is number between 0 and 1 to indicate how far the tween has progressed | [
"t",
"is",
"number",
"between",
"0",
"and",
"1",
"to",
"indicate",
"how",
"far",
"the",
"tween",
"has",
"progressed"
] | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/Tween.py#L72-L86 |
shimpe/pyvectortween | vectortween/Tween.py | Tween.tween2 | def tween2(self, val, frm, to):
"""
linearly maps val between frm and to to a number between 0 and 1
"""
return self.tween(Mapping.linlin(val, frm, to, 0, 1)) | python | def tween2(self, val, frm, to):
"""
linearly maps val between frm and to to a number between 0 and 1
"""
return self.tween(Mapping.linlin(val, frm, to, 0, 1)) | [
"def",
"tween2",
"(",
"self",
",",
"val",
",",
"frm",
",",
"to",
")",
":",
"return",
"self",
".",
"tween",
"(",
"Mapping",
".",
"linlin",
"(",
"val",
",",
"frm",
",",
"to",
",",
"0",
",",
"1",
")",
")"
] | linearly maps val between frm and to to a number between 0 and 1 | [
"linearly",
"maps",
"val",
"between",
"frm",
"and",
"to",
"to",
"a",
"number",
"between",
"0",
"and",
"1"
] | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/Tween.py#L88-L92 |
sprymix/metamagic.json | metamagic/json/encoder.py | Encoder._encode_str | def _encode_str(self, obj, escape_quotes=True):
"""Return an ASCII-only JSON representation of a Python string"""
def replace(match):
s = match.group(0)
try:
if escape_quotes:
return ESCAPE_DCT[s]
else:
retur... | python | def _encode_str(self, obj, escape_quotes=True):
"""Return an ASCII-only JSON representation of a Python string"""
def replace(match):
s = match.group(0)
try:
if escape_quotes:
return ESCAPE_DCT[s]
else:
retur... | [
"def",
"_encode_str",
"(",
"self",
",",
"obj",
",",
"escape_quotes",
"=",
"True",
")",
":",
"def",
"replace",
"(",
"match",
")",
":",
"s",
"=",
"match",
".",
"group",
"(",
"0",
")",
"try",
":",
"if",
"escape_quotes",
":",
"return",
"ESCAPE_DCT",
"[",... | Return an ASCII-only JSON representation of a Python string | [
"Return",
"an",
"ASCII",
"-",
"only",
"JSON",
"representation",
"of",
"a",
"Python",
"string"
] | train | https://github.com/sprymix/metamagic.json/blob/c95d3cacd641d433af44f0774f51a085cb4888e6/metamagic/json/encoder.py#L156-L178 |
sprymix/metamagic.json | metamagic/json/encoder.py | Encoder._encode_numbers | def _encode_numbers(self, obj):
"""Returns a JSON representation of a Python number (int, float or Decimal)"""
# strict checks first - for speed
if obj.__class__ is int:
if abs(obj) > JAVASCRIPT_MAXINT:
raise ValueError('Number out of range: {!r}'.format(obj))
... | python | def _encode_numbers(self, obj):
"""Returns a JSON representation of a Python number (int, float or Decimal)"""
# strict checks first - for speed
if obj.__class__ is int:
if abs(obj) > JAVASCRIPT_MAXINT:
raise ValueError('Number out of range: {!r}'.format(obj))
... | [
"def",
"_encode_numbers",
"(",
"self",
",",
"obj",
")",
":",
"# strict checks first - for speed",
"if",
"obj",
".",
"__class__",
"is",
"int",
":",
"if",
"abs",
"(",
"obj",
")",
">",
"JAVASCRIPT_MAXINT",
":",
"raise",
"ValueError",
"(",
"'Number out of range: {!r... | Returns a JSON representation of a Python number (int, float or Decimal) | [
"Returns",
"a",
"JSON",
"representation",
"of",
"a",
"Python",
"number",
"(",
"int",
"float",
"or",
"Decimal",
")"
] | train | https://github.com/sprymix/metamagic.json/blob/c95d3cacd641d433af44f0774f51a085cb4888e6/metamagic/json/encoder.py#L180-L214 |
sprymix/metamagic.json | metamagic/json/encoder.py | Encoder._encode_list | def _encode_list(self, obj):# do
"""Returns a JSON representation of a Python list"""
self._increment_nested_level()
buffer = []
for element in obj:
buffer.append(self._encode(element))
self._decrement_nested_level()
return '['+ ','.join(buffer) + ']' | python | def _encode_list(self, obj):# do
"""Returns a JSON representation of a Python list"""
self._increment_nested_level()
buffer = []
for element in obj:
buffer.append(self._encode(element))
self._decrement_nested_level()
return '['+ ','.join(buffer) + ']' | [
"def",
"_encode_list",
"(",
"self",
",",
"obj",
")",
":",
"# do",
"self",
".",
"_increment_nested_level",
"(",
")",
"buffer",
"=",
"[",
"]",
"for",
"element",
"in",
"obj",
":",
"buffer",
".",
"append",
"(",
"self",
".",
"_encode",
"(",
"element",
")",
... | Returns a JSON representation of a Python list | [
"Returns",
"a",
"JSON",
"representation",
"of",
"a",
"Python",
"list"
] | train | https://github.com/sprymix/metamagic.json/blob/c95d3cacd641d433af44f0774f51a085cb4888e6/metamagic/json/encoder.py#L216-L227 |
sprymix/metamagic.json | metamagic/json/encoder.py | Encoder._encode_dict | def _encode_dict(self, obj):
"""Returns a JSON representation of a Python dict"""
self._increment_nested_level()
buffer = []
for key in obj:
buffer.append(self._encode_key(key) + ':' + self._encode(obj[key]))
self._decrement_nested_level()
return '{'+ ','.... | python | def _encode_dict(self, obj):
"""Returns a JSON representation of a Python dict"""
self._increment_nested_level()
buffer = []
for key in obj:
buffer.append(self._encode_key(key) + ':' + self._encode(obj[key]))
self._decrement_nested_level()
return '{'+ ','.... | [
"def",
"_encode_dict",
"(",
"self",
",",
"obj",
")",
":",
"self",
".",
"_increment_nested_level",
"(",
")",
"buffer",
"=",
"[",
"]",
"for",
"key",
"in",
"obj",
":",
"buffer",
".",
"append",
"(",
"self",
".",
"_encode_key",
"(",
"key",
")",
"+",
"':'"... | Returns a JSON representation of a Python dict | [
"Returns",
"a",
"JSON",
"representation",
"of",
"a",
"Python",
"dict"
] | train | https://github.com/sprymix/metamagic.json/blob/c95d3cacd641d433af44f0774f51a085cb4888e6/metamagic/json/encoder.py#L229-L240 |
sprymix/metamagic.json | metamagic/json/encoder.py | Encoder._encode_key | def _encode_key(self, obj):
"""Encodes a dictionary key - a key can only be a string in std JSON"""
if obj.__class__ is str:
return self._encode_str(obj)
if obj.__class__ is UUID:
return '"' + str(obj) + '"'
# __mm_serialize__ is called before any isinstance ch... | python | def _encode_key(self, obj):
"""Encodes a dictionary key - a key can only be a string in std JSON"""
if obj.__class__ is str:
return self._encode_str(obj)
if obj.__class__ is UUID:
return '"' + str(obj) + '"'
# __mm_serialize__ is called before any isinstance ch... | [
"def",
"_encode_key",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
".",
"__class__",
"is",
"str",
":",
"return",
"self",
".",
"_encode_str",
"(",
"obj",
")",
"if",
"obj",
".",
"__class__",
"is",
"UUID",
":",
"return",
"'\"'",
"+",
"str",
"(",
"o... | Encodes a dictionary key - a key can only be a string in std JSON | [
"Encodes",
"a",
"dictionary",
"key",
"-",
"a",
"key",
"can",
"only",
"be",
"a",
"string",
"in",
"std",
"JSON"
] | train | https://github.com/sprymix/metamagic.json/blob/c95d3cacd641d433af44f0774f51a085cb4888e6/metamagic/json/encoder.py#L242-L277 |
sprymix/metamagic.json | metamagic/json/encoder.py | Encoder._encode | def _encode(self, obj):
"""Returns a JSON representation of a Python object - see dumps.
Accepts objects of any type, calls the appropriate type-specific encoder.
"""
if self._use_hook:
obj = self.encode_hook(obj)
# first try simple strict checks
_objtype =... | python | def _encode(self, obj):
"""Returns a JSON representation of a Python object - see dumps.
Accepts objects of any type, calls the appropriate type-specific encoder.
"""
if self._use_hook:
obj = self.encode_hook(obj)
# first try simple strict checks
_objtype =... | [
"def",
"_encode",
"(",
"self",
",",
"obj",
")",
":",
"if",
"self",
".",
"_use_hook",
":",
"obj",
"=",
"self",
".",
"encode_hook",
"(",
"obj",
")",
"# first try simple strict checks",
"_objtype",
"=",
"obj",
".",
"__class__",
"if",
"_objtype",
"is",
"str",
... | Returns a JSON representation of a Python object - see dumps.
Accepts objects of any type, calls the appropriate type-specific encoder. | [
"Returns",
"a",
"JSON",
"representation",
"of",
"a",
"Python",
"object",
"-",
"see",
"dumps",
".",
"Accepts",
"objects",
"of",
"any",
"type",
"calls",
"the",
"appropriate",
"type",
"-",
"specific",
"encoder",
"."
] | train | https://github.com/sprymix/metamagic.json/blob/c95d3cacd641d433af44f0774f51a085cb4888e6/metamagic/json/encoder.py#L279-L371 |
sprymix/metamagic.json | metamagic/json/encoder.py | Encoder.dumps | def dumps(self, obj, *, max_nested_level=100):
"""Returns a string representing a JSON-encoding of ``obj``.
The second optional ``max_nested_level`` argument controls the maximum
allowed recursion/nesting level.
See class description for details.
"""
self._max_... | python | def dumps(self, obj, *, max_nested_level=100):
"""Returns a string representing a JSON-encoding of ``obj``.
The second optional ``max_nested_level`` argument controls the maximum
allowed recursion/nesting level.
See class description for details.
"""
self._max_... | [
"def",
"dumps",
"(",
"self",
",",
"obj",
",",
"*",
",",
"max_nested_level",
"=",
"100",
")",
":",
"self",
".",
"_max_nested_level",
"=",
"max_nested_level",
"return",
"self",
".",
"_encode",
"(",
"obj",
")"
] | Returns a string representing a JSON-encoding of ``obj``.
The second optional ``max_nested_level`` argument controls the maximum
allowed recursion/nesting level.
See class description for details. | [
"Returns",
"a",
"string",
"representing",
"a",
"JSON",
"-",
"encoding",
"of",
"obj",
"."
] | train | https://github.com/sprymix/metamagic.json/blob/c95d3cacd641d433af44f0774f51a085cb4888e6/metamagic/json/encoder.py#L373-L382 |
sprymix/metamagic.json | metamagic/json/encoder.py | Encoder.dumpb | def dumpb(self, obj, *, max_nested_level=100):
"""Similar to ``dumps()``, but returns ``bytes`` instead of a ``string``"""
self._max_nested_level = max_nested_level
return self._encode(obj).encode('utf-8') | python | def dumpb(self, obj, *, max_nested_level=100):
"""Similar to ``dumps()``, but returns ``bytes`` instead of a ``string``"""
self._max_nested_level = max_nested_level
return self._encode(obj).encode('utf-8') | [
"def",
"dumpb",
"(",
"self",
",",
"obj",
",",
"*",
",",
"max_nested_level",
"=",
"100",
")",
":",
"self",
".",
"_max_nested_level",
"=",
"max_nested_level",
"return",
"self",
".",
"_encode",
"(",
"obj",
")",
".",
"encode",
"(",
"'utf-8'",
")"
] | Similar to ``dumps()``, but returns ``bytes`` instead of a ``string`` | [
"Similar",
"to",
"dumps",
"()",
"but",
"returns",
"bytes",
"instead",
"of",
"a",
"string"
] | train | https://github.com/sprymix/metamagic.json/blob/c95d3cacd641d433af44f0774f51a085cb4888e6/metamagic/json/encoder.py#L384-L387 |
guyzmo/pyparts | pyparts/parts.py | download_file | def download_file(url, filename=None, show_progress=draw_pbar):
'''
Download a file and show progress
url: the URL of the file to download
filename: the filename to download it to (if not given, uses the url's filename part)
show_progress: callback function to update a progress bar
the show_pr... | python | def download_file(url, filename=None, show_progress=draw_pbar):
'''
Download a file and show progress
url: the URL of the file to download
filename: the filename to download it to (if not given, uses the url's filename part)
show_progress: callback function to update a progress bar
the show_pr... | [
"def",
"download_file",
"(",
"url",
",",
"filename",
"=",
"None",
",",
"show_progress",
"=",
"draw_pbar",
")",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"url",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"r",
"=",
"requests",
... | Download a file and show progress
url: the URL of the file to download
filename: the filename to download it to (if not given, uses the url's filename part)
show_progress: callback function to update a progress bar
the show_progress function shall take two parameters: `seen` and `size`, and
return... | [
"Download",
"a",
"file",
"and",
"show",
"progress"
] | train | https://github.com/guyzmo/pyparts/blob/cc7f225e6f7f2e9f2edc42fbd02e5d49d3595a78/pyparts/parts.py#L104-L131 |
guyzmo/pyparts | pyparts/parts.py | main | def main():
'''
entry point of the application.
Parses the CLI commands and runs the actions.
'''
args = CLI.parse_args(__doc__)
if args['--verbose']:
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
logging.basicConfig(... | python | def main():
'''
entry point of the application.
Parses the CLI commands and runs the actions.
'''
args = CLI.parse_args(__doc__)
if args['--verbose']:
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
logging.basicConfig(... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"CLI",
".",
"parse_args",
"(",
"__doc__",
")",
"if",
"args",
"[",
"'--verbose'",
"]",
":",
"requests_log",
"=",
"logging",
".",
"getLogger",
"(",
"\"requests.packages.urllib3\"",
")",
"requests_log",
".",
"setLevel"... | entry point of the application.
Parses the CLI commands and runs the actions. | [
"entry",
"point",
"of",
"the",
"application",
"."
] | train | https://github.com/guyzmo/pyparts/blob/cc7f225e6f7f2e9f2edc42fbd02e5d49d3595a78/pyparts/parts.py#L361-L402 |
guyzmo/pyparts | pyparts/parts.py | PyPartsOctopart.part_search | def part_search(self, part_query):
'''
handles the part lookup/search for the given part query
part_query: part string to search as product name
outputs result on stdout
'''
limit = 100
results = self._e.parts_search(q=part_query,
... | python | def part_search(self, part_query):
'''
handles the part lookup/search for the given part query
part_query: part string to search as product name
outputs result on stdout
'''
limit = 100
results = self._e.parts_search(q=part_query,
... | [
"def",
"part_search",
"(",
"self",
",",
"part_query",
")",
":",
"limit",
"=",
"100",
"results",
"=",
"self",
".",
"_e",
".",
"parts_search",
"(",
"q",
"=",
"part_query",
",",
"limit",
"=",
"limit",
")",
"start",
"=",
"0",
"hits",
"=",
"results",
"[",... | handles the part lookup/search for the given part query
part_query: part string to search as product name
outputs result on stdout | [
"handles",
"the",
"part",
"lookup",
"/",
"search",
"for",
"the",
"given",
"part",
"query"
] | train | https://github.com/guyzmo/pyparts/blob/cc7f225e6f7f2e9f2edc42fbd02e5d49d3595a78/pyparts/parts.py#L170-L210 |
guyzmo/pyparts | pyparts/parts.py | PyPartsOctopart.part_specs | def part_specs(self, part):
'''
returns the specifications of the given part. If multiple parts are
matched, only the first one will be output.
part: the productname or sku
prints the results on stdout
'''
result = self._e.parts_match(
queries=[{'mpn... | python | def part_specs(self, part):
'''
returns the specifications of the given part. If multiple parts are
matched, only the first one will be output.
part: the productname or sku
prints the results on stdout
'''
result = self._e.parts_match(
queries=[{'mpn... | [
"def",
"part_specs",
"(",
"self",
",",
"part",
")",
":",
"result",
"=",
"self",
".",
"_e",
".",
"parts_match",
"(",
"queries",
"=",
"[",
"{",
"'mpn_or_sku'",
":",
"part",
"}",
"]",
",",
"exact_only",
"=",
"True",
",",
"show_mpn",
"=",
"True",
",",
... | returns the specifications of the given part. If multiple parts are
matched, only the first one will be output.
part: the productname or sku
prints the results on stdout | [
"returns",
"the",
"specifications",
"of",
"the",
"given",
"part",
".",
"If",
"multiple",
"parts",
"are",
"matched",
"only",
"the",
"first",
"one",
"will",
"be",
"output",
"."
] | train | https://github.com/guyzmo/pyparts/blob/cc7f225e6f7f2e9f2edc42fbd02e5d49d3595a78/pyparts/parts.py#L212-L289 |
guyzmo/pyparts | pyparts/parts.py | PyPartsOctopart.part_datasheet | def part_datasheet(self, part, command=None, path=None):
'''
downloads and/or shows the datasheet of a given part
command: if set will use it to open the datasheet.
path: if set will download the file under that path.
if path is given alone, the file will only get downloaded,
... | python | def part_datasheet(self, part, command=None, path=None):
'''
downloads and/or shows the datasheet of a given part
command: if set will use it to open the datasheet.
path: if set will download the file under that path.
if path is given alone, the file will only get downloaded,
... | [
"def",
"part_datasheet",
"(",
"self",
",",
"part",
",",
"command",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"result",
"=",
"self",
".",
"_e",
".",
"parts_match",
"(",
"queries",
"=",
"[",
"{",
"'mpn_or_sku'",
":",
"part",
"}",
"]",
",",
"ex... | downloads and/or shows the datasheet of a given part
command: if set will use it to open the datasheet.
path: if set will download the file under that path.
if path is given alone, the file will only get downloaded,
if command is given alone, the file will be downloaded in a temporary
... | [
"downloads",
"and",
"/",
"or",
"shows",
"the",
"datasheet",
"of",
"a",
"given",
"part"
] | train | https://github.com/guyzmo/pyparts/blob/cc7f225e6f7f2e9f2edc42fbd02e5d49d3595a78/pyparts/parts.py#L291-L330 |
guyzmo/pyparts | pyparts/parts.py | PyPartsOctopart.part_show | def part_show(self, part, printout=False):
'''
Opens/shows the aggregator's URI for the part.
printout: if set, only printout the URI, do not open the browser.
'''
result = self._e.parts_match(
queries=[{'mpn_or_sku': part}],
exact_only=True,
... | python | def part_show(self, part, printout=False):
'''
Opens/shows the aggregator's URI for the part.
printout: if set, only printout the URI, do not open the browser.
'''
result = self._e.parts_match(
queries=[{'mpn_or_sku': part}],
exact_only=True,
... | [
"def",
"part_show",
"(",
"self",
",",
"part",
",",
"printout",
"=",
"False",
")",
":",
"result",
"=",
"self",
".",
"_e",
".",
"parts_match",
"(",
"queries",
"=",
"[",
"{",
"'mpn_or_sku'",
":",
"part",
"}",
"]",
",",
"exact_only",
"=",
"True",
",",
... | Opens/shows the aggregator's URI for the part.
printout: if set, only printout the URI, do not open the browser. | [
"Opens",
"/",
"shows",
"the",
"aggregator",
"s",
"URI",
"for",
"the",
"part",
"."
] | train | https://github.com/guyzmo/pyparts/blob/cc7f225e6f7f2e9f2edc42fbd02e5d49d3595a78/pyparts/parts.py#L332-L356 |
justquick/django-native-tags | native_tags/contrib/_django.py | autoescape | def autoescape(context, nodelist, setting):
"""
Force autoescape behaviour for this block.
"""
old_setting = context.autoescape
context.autoescape = setting
output = nodelist.render(context)
context.autoescape = old_setting
if setting:
return mark_safe(output)
else:
r... | python | def autoescape(context, nodelist, setting):
"""
Force autoescape behaviour for this block.
"""
old_setting = context.autoescape
context.autoescape = setting
output = nodelist.render(context)
context.autoescape = old_setting
if setting:
return mark_safe(output)
else:
r... | [
"def",
"autoescape",
"(",
"context",
",",
"nodelist",
",",
"setting",
")",
":",
"old_setting",
"=",
"context",
".",
"autoescape",
"context",
".",
"autoescape",
"=",
"setting",
"output",
"=",
"nodelist",
".",
"render",
"(",
"context",
")",
"context",
".",
"... | Force autoescape behaviour for this block. | [
"Force",
"autoescape",
"behaviour",
"for",
"this",
"block",
"."
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_django.py#L19-L30 |
justquick/django-native-tags | native_tags/contrib/_django.py | debug | def debug(context):
"""
Outputs a whole load of debugging information, including the current
context and imported modules.
Sample usage::
<pre>
{% debug %}
</pre>
"""
from pprint import pformat
output = [pformat(val) for val in context]
output.append('\n\n'... | python | def debug(context):
"""
Outputs a whole load of debugging information, including the current
context and imported modules.
Sample usage::
<pre>
{% debug %}
</pre>
"""
from pprint import pformat
output = [pformat(val) for val in context]
output.append('\n\n'... | [
"def",
"debug",
"(",
"context",
")",
":",
"from",
"pprint",
"import",
"pformat",
"output",
"=",
"[",
"pformat",
"(",
"val",
")",
"for",
"val",
"in",
"context",
"]",
"output",
".",
"append",
"(",
"'\\n\\n'",
")",
"output",
".",
"append",
"(",
"pformat",... | Outputs a whole load of debugging information, including the current
context and imported modules.
Sample usage::
<pre>
{% debug %}
</pre> | [
"Outputs",
"a",
"whole",
"load",
"of",
"debugging",
"information",
"including",
"the",
"current",
"context",
"and",
"imported",
"modules",
"."
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_django.py#L68-L84 |
justquick/django-native-tags | native_tags/contrib/_django.py | filter | def filter(context, nodelist, filter_exp):
"""
Filters the contents of the block through variable filters.
Filters can also be piped through each other, and they can have
arguments -- just like in variable syntax.
Sample usage::
{% filter force_escape|lower %}
This text will b... | python | def filter(context, nodelist, filter_exp):
"""
Filters the contents of the block through variable filters.
Filters can also be piped through each other, and they can have
arguments -- just like in variable syntax.
Sample usage::
{% filter force_escape|lower %}
This text will b... | [
"def",
"filter",
"(",
"context",
",",
"nodelist",
",",
"filter_exp",
")",
":",
"output",
"=",
"nodelist",
".",
"render",
"(",
"context",
")",
"# Apply filters.",
"context",
".",
"update",
"(",
"{",
"'var'",
":",
"output",
"}",
")",
"filtered",
"=",
"filt... | Filters the contents of the block through variable filters.
Filters can also be piped through each other, and they can have
arguments -- just like in variable syntax.
Sample usage::
{% filter force_escape|lower %}
This text will be HTML-escaped, and will appear in lowercase.
{... | [
"Filters",
"the",
"contents",
"of",
"the",
"block",
"through",
"variable",
"filters",
"."
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_django.py#L87-L105 |
justquick/django-native-tags | native_tags/contrib/_django.py | regroup | def regroup(target, expression):
"""
Regroups a list of alike objects by a common attribute.
This complex tag is best illustrated by use of an example: say that
``people`` is a list of ``Person`` objects that have ``first_name``,
``last_name``, and ``gender`` attributes, and you'd like to display ... | python | def regroup(target, expression):
"""
Regroups a list of alike objects by a common attribute.
This complex tag is best illustrated by use of an example: say that
``people`` is a list of ``Person`` objects that have ``first_name``,
``last_name``, and ``gender`` attributes, and you'd like to display ... | [
"def",
"regroup",
"(",
"target",
",",
"expression",
")",
":",
"if",
"not",
"target",
":",
"return",
"''",
"return",
"[",
"# List of dictionaries in the format:",
"# {'grouper': 'key', 'list': [list of contents]}.",
"{",
"'grouper'",
":",
"key",
",",
"'list'",
":",
"... | Regroups a list of alike objects by a common attribute.
This complex tag is best illustrated by use of an example: say that
``people`` is a list of ``Person`` objects that have ``first_name``,
``last_name``, and ``gender`` attributes, and you'd like to display a list
that looks like:
* Male:
... | [
"Regroups",
"a",
"list",
"of",
"alike",
"objects",
"by",
"a",
"common",
"attribute",
"."
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_django.py#L147-L200 |
justquick/django-native-tags | native_tags/contrib/_django.py | now | def now(format_string):
"""
Displays the date, formatted according to the given string.
Uses the same format as PHP's ``date()`` function; see http://php.net/date
for all the possible values.
Sample usage::
It is {% now "jS F Y H:i" %}
"""
from datetime import datetime
from dj... | python | def now(format_string):
"""
Displays the date, formatted according to the given string.
Uses the same format as PHP's ``date()`` function; see http://php.net/date
for all the possible values.
Sample usage::
It is {% now "jS F Y H:i" %}
"""
from datetime import datetime
from dj... | [
"def",
"now",
"(",
"format_string",
")",
":",
"from",
"datetime",
"import",
"datetime",
"from",
"django",
".",
"utils",
".",
"dateformat",
"import",
"DateFormat",
"return",
"DateFormat",
"(",
"datetime",
".",
"now",
"(",
")",
")",
".",
"format",
"(",
"self... | Displays the date, formatted according to the given string.
Uses the same format as PHP's ``date()`` function; see http://php.net/date
for all the possible values.
Sample usage::
It is {% now "jS F Y H:i" %} | [
"Displays",
"the",
"date",
"formatted",
"according",
"to",
"the",
"given",
"string",
"."
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_django.py#L203-L216 |
justquick/django-native-tags | native_tags/contrib/_django.py | spaceless | def spaceless(context, nodelists):
"""
Removes whitespace between HTML tags, including tab and newline characters.
Example usage::
{% spaceless %}
<p>
<a href="foo/">Foo</a>
</p>
{% endspaceless %}
This example would return this HTML::
... | python | def spaceless(context, nodelists):
"""
Removes whitespace between HTML tags, including tab and newline characters.
Example usage::
{% spaceless %}
<p>
<a href="foo/">Foo</a>
</p>
{% endspaceless %}
This example would return this HTML::
... | [
"def",
"spaceless",
"(",
"context",
",",
"nodelists",
")",
":",
"from",
"django",
".",
"utils",
".",
"html",
"import",
"strip_spaces_between_tags",
"return",
"strip_spaces_between_tags",
"(",
"nodelist",
".",
"render",
"(",
"context",
")",
".",
"strip",
"(",
"... | Removes whitespace between HTML tags, including tab and newline characters.
Example usage::
{% spaceless %}
<p>
<a href="foo/">Foo</a>
</p>
{% endspaceless %}
This example would return this HTML::
<p><a href="foo/">Foo</a></p>
Only space b... | [
"Removes",
"whitespace",
"between",
"HTML",
"tags",
"including",
"tab",
"and",
"newline",
"characters",
"."
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_django.py#L219-L246 |
justquick/django-native-tags | native_tags/contrib/_django.py | widthratio | def widthratio(value, maxvalue, max_width):
"""
For creating bar charts and such, this tag calculates the ratio of a given
value to a maximum value, and then applies that ratio to a constant.
For example::
<img src='bar.gif' height='10' width='{% widthratio this_value max_value 100 %}' />
... | python | def widthratio(value, maxvalue, max_width):
"""
For creating bar charts and such, this tag calculates the ratio of a given
value to a maximum value, and then applies that ratio to a constant.
For example::
<img src='bar.gif' height='10' width='{% widthratio this_value max_value 100 %}' />
... | [
"def",
"widthratio",
"(",
"value",
",",
"maxvalue",
",",
"max_width",
")",
":",
"try",
":",
"max_width",
"=",
"int",
"(",
"max_width",
")",
"except",
"ValueError",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"widthratio final argument must be an number\"",
")",
"t... | For creating bar charts and such, this tag calculates the ratio of a given
value to a maximum value, and then applies that ratio to a constant.
For example::
<img src='bar.gif' height='10' width='{% widthratio this_value max_value 100 %}' />
Above, if ``this_value`` is 175 and ``max_value`` is 20... | [
"For",
"creating",
"bar",
"charts",
"and",
"such",
"this",
"tag",
"calculates",
"the",
"ratio",
"of",
"a",
"given",
"value",
"to",
"a",
"maximum",
"value",
"and",
"then",
"applies",
"that",
"ratio",
"to",
"a",
"constant",
"."
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_django.py#L249-L272 |
justquick/django-native-tags | native_tags/contrib/_django.py | with_ | def with_(context, nodelist, val):
"""
Adds a value to the context (inside of this block) for caching and easy
access.
For example::
{% with person.some_sql_method as total %}
{{ total }} object{{ total|pluralize }}
{% endwith %}
"""
context.push()
context[self.... | python | def with_(context, nodelist, val):
"""
Adds a value to the context (inside of this block) for caching and easy
access.
For example::
{% with person.some_sql_method as total %}
{{ total }} object{{ total|pluralize }}
{% endwith %}
"""
context.push()
context[self.... | [
"def",
"with_",
"(",
"context",
",",
"nodelist",
",",
"val",
")",
":",
"context",
".",
"push",
"(",
")",
"context",
"[",
"self",
".",
"name",
"]",
"=",
"val",
"output",
"=",
"nodelist",
".",
"render",
"(",
"context",
")",
"context",
".",
"pop",
"("... | Adds a value to the context (inside of this block) for caching and easy
access.
For example::
{% with person.some_sql_method as total %}
{{ total }} object{{ total|pluralize }}
{% endwith %} | [
"Adds",
"a",
"value",
"to",
"the",
"context",
"(",
"inside",
"of",
"this",
"block",
")",
"for",
"caching",
"and",
"easy",
"access",
"."
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_django.py#L275-L290 |
SetBased/py-etlt | etlt/helper/Type2JoinHelper.py | Type2JoinHelper._intersect | def _intersect(start1, end1, start2, end2):
"""
Returns the intersection of two intervals. Returns (None,None) if the intersection is empty.
:param int start1: The start date of the first interval.
:param int end1: The end date of the first interval.
:param int start2: The start... | python | def _intersect(start1, end1, start2, end2):
"""
Returns the intersection of two intervals. Returns (None,None) if the intersection is empty.
:param int start1: The start date of the first interval.
:param int end1: The end date of the first interval.
:param int start2: The start... | [
"def",
"_intersect",
"(",
"start1",
",",
"end1",
",",
"start2",
",",
"end2",
")",
":",
"start",
"=",
"max",
"(",
"start1",
",",
"start2",
")",
"end",
"=",
"min",
"(",
"end1",
",",
"end2",
")",
"if",
"start",
">",
"end",
":",
"return",
"None",
","... | Returns the intersection of two intervals. Returns (None,None) if the intersection is empty.
:param int start1: The start date of the first interval.
:param int end1: The end date of the first interval.
:param int start2: The start date of the second interval.
:param int end2: The end d... | [
"Returns",
"the",
"intersection",
"of",
"two",
"intervals",
".",
"Returns",
"(",
"None",
"None",
")",
"if",
"the",
"intersection",
"is",
"empty",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Type2JoinHelper.py#L18-L35 |
SetBased/py-etlt | etlt/helper/Type2JoinHelper.py | Type2JoinHelper._additional_rows_date2int | def _additional_rows_date2int(self, keys, rows):
"""
Replaces start and end dates of the additional date intervals in the row set with their integer representation
:param list[tuple[str,str]] keys: The other keys with start and end date.
:param list[dict[str,T]] rows: The list of rows.
... | python | def _additional_rows_date2int(self, keys, rows):
"""
Replaces start and end dates of the additional date intervals in the row set with their integer representation
:param list[tuple[str,str]] keys: The other keys with start and end date.
:param list[dict[str,T]] rows: The list of rows.
... | [
"def",
"_additional_rows_date2int",
"(",
"self",
",",
"keys",
",",
"rows",
")",
":",
"for",
"row",
"in",
"rows",
":",
"for",
"key_start_date",
",",
"key_end_date",
"in",
"keys",
":",
"if",
"key_start_date",
"not",
"in",
"[",
"self",
".",
"_key_start_date",
... | Replaces start and end dates of the additional date intervals in the row set with their integer representation
:param list[tuple[str,str]] keys: The other keys with start and end date.
:param list[dict[str,T]] rows: The list of rows.
:rtype: list[dict[str,T]] | [
"Replaces",
"start",
"and",
"end",
"dates",
"of",
"the",
"additional",
"date",
"intervals",
"in",
"the",
"row",
"set",
"with",
"their",
"integer",
"representation"
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Type2JoinHelper.py#L38-L52 |
SetBased/py-etlt | etlt/helper/Type2JoinHelper.py | Type2JoinHelper._intersection | def _intersection(self, keys, rows):
"""
Computes the intersection of the date intervals of two or more reference data sets. If the intersection is empty
the row is removed from the group.
:param list[tuple[str,str]] keys: The other keys with start and end date.
:param list[dict... | python | def _intersection(self, keys, rows):
"""
Computes the intersection of the date intervals of two or more reference data sets. If the intersection is empty
the row is removed from the group.
:param list[tuple[str,str]] keys: The other keys with start and end date.
:param list[dict... | [
"def",
"_intersection",
"(",
"self",
",",
"keys",
",",
"rows",
")",
":",
"# If there are no other keys with start and end date (i.e. nothing to merge) return immediately.",
"if",
"not",
"keys",
":",
"return",
"rows",
"ret",
"=",
"list",
"(",
")",
"for",
"row",
"in",
... | Computes the intersection of the date intervals of two or more reference data sets. If the intersection is empty
the row is removed from the group.
:param list[tuple[str,str]] keys: The other keys with start and end date.
:param list[dict[str,T]] rows: The list of rows.
:rtype: list[di... | [
"Computes",
"the",
"intersection",
"of",
"the",
"date",
"intervals",
"of",
"two",
"or",
"more",
"reference",
"data",
"sets",
".",
"If",
"the",
"intersection",
"is",
"empty",
"the",
"row",
"is",
"removed",
"from",
"the",
"group",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Type2JoinHelper.py#L55-L90 |
SetBased/py-etlt | etlt/helper/Type2JoinHelper.py | Type2JoinHelper.merge | def merge(self, keys):
"""
Merges the join on pseudo keys of two or more reference data sets.
:param list[tuple[str,str]] keys: For each data set the keys of the start and end date.
"""
deletes = []
for pseudo_key, rows in self._rows.items():
self._additional... | python | def merge(self, keys):
"""
Merges the join on pseudo keys of two or more reference data sets.
:param list[tuple[str,str]] keys: For each data set the keys of the start and end date.
"""
deletes = []
for pseudo_key, rows in self._rows.items():
self._additional... | [
"def",
"merge",
"(",
"self",
",",
"keys",
")",
":",
"deletes",
"=",
"[",
"]",
"for",
"pseudo_key",
",",
"rows",
"in",
"self",
".",
"_rows",
".",
"items",
"(",
")",
":",
"self",
".",
"_additional_rows_date2int",
"(",
"keys",
",",
"rows",
")",
"rows",
... | Merges the join on pseudo keys of two or more reference data sets.
:param list[tuple[str,str]] keys: For each data set the keys of the start and end date. | [
"Merges",
"the",
"join",
"on",
"pseudo",
"keys",
"of",
"two",
"or",
"more",
"reference",
"data",
"sets",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Type2JoinHelper.py#L93-L110 |
ionelmc/python-cogen | cogen/core/proactors/poll_impl.py | PollProactor.run | def run(self, timeout = 0):
"""
Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
"""
# poll timeout param is a integer number of miliseconds (seconds/1000).
ptimeout = int(
timeout.days * 864000... | python | def run(self, timeout = 0):
"""
Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
"""
# poll timeout param is a integer number of miliseconds (seconds/1000).
ptimeout = int(
timeout.days * 864000... | [
"def",
"run",
"(",
"self",
",",
"timeout",
"=",
"0",
")",
":",
"# poll timeout param is a integer number of miliseconds (seconds/1000).\r",
"ptimeout",
"=",
"int",
"(",
"timeout",
".",
"days",
"*",
"86400000",
"+",
"timeout",
".",
"microseconds",
"/",
"1000",
"+",... | Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None. | [
"Run",
"a",
"proactor",
"loop",
"and",
"return",
"new",
"socket",
"events",
".",
"Timeout",
"is",
"a",
"timedelta",
"object",
"0",
"if",
"active",
"coros",
"or",
"None",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/poll_impl.py#L38-L79 |
ionelmc/python-cogen | examples/cogen-irc/CogenIrcApp/cogenircapp/config/routing.py | make_map | def make_map():
"""Create, configure and return the routes Mapper"""
map = Mapper(directory=config['pylons.paths']['controllers'],
always_scan=config['debug'])
# The ErrorController route (handles 404/500 error pages); it should
# likely stay at the top, ensuring it can always be... | python | def make_map():
"""Create, configure and return the routes Mapper"""
map = Mapper(directory=config['pylons.paths']['controllers'],
always_scan=config['debug'])
# The ErrorController route (handles 404/500 error pages); it should
# likely stay at the top, ensuring it can always be... | [
"def",
"make_map",
"(",
")",
":",
"map",
"=",
"Mapper",
"(",
"directory",
"=",
"config",
"[",
"'pylons.paths'",
"]",
"[",
"'controllers'",
"]",
",",
"always_scan",
"=",
"config",
"[",
"'debug'",
"]",
")",
"# The ErrorController route (handles 404/500 error pages);... | Create, configure and return the routes Mapper | [
"Create",
"configure",
"and",
"return",
"the",
"routes",
"Mapper"
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/cogen-irc/CogenIrcApp/cogenircapp/config/routing.py#L10-L27 |
shimpe/pyvectortween | vectortween/PolarAnimation.py | PolarAnimation.make_frame | def make_frame(self, frame, birthframe, startframe, stopframe, deathframe, noiseframe=None):
"""
:param frame: current frame
:param birthframe: frame where this animation starts returning something other than None
:param startframe: frame where animation starts to evolve
:param ... | python | def make_frame(self, frame, birthframe, startframe, stopframe, deathframe, noiseframe=None):
"""
:param frame: current frame
:param birthframe: frame where this animation starts returning something other than None
:param startframe: frame where animation starts to evolve
:param ... | [
"def",
"make_frame",
"(",
"self",
",",
"frame",
",",
"birthframe",
",",
"startframe",
",",
"stopframe",
",",
"deathframe",
",",
"noiseframe",
"=",
"None",
")",
":",
"return",
"self",
".",
"anim",
".",
"make_frame",
"(",
"frame",
",",
"birthframe",
",",
"... | :param frame: current frame
:param birthframe: frame where this animation starts returning something other than None
:param startframe: frame where animation starts to evolve
:param stopframe: frame where animation is completed
:param deathframe: frame where animation starts to return N... | [
":",
"param",
"frame",
":",
"current",
"frame",
":",
"param",
"birthframe",
":",
"frame",
"where",
"this",
"animation",
"starts",
"returning",
"something",
"other",
"than",
"None",
":",
"param",
"startframe",
":",
"frame",
"where",
"animation",
"starts",
"to",... | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/PolarAnimation.py#L151-L160 |
seibert-media/Highton | highton/fields/object_field.py | ObjectField.to_serializable_value | def to_serializable_value(self):
"""
Run through all fields of the object and parse the values
:return:
:rtype: dict
"""
return {
name: field.to_serializable_value()
for name, field in self.value.__dict__.items()
if isinstance(field, F... | python | def to_serializable_value(self):
"""
Run through all fields of the object and parse the values
:return:
:rtype: dict
"""
return {
name: field.to_serializable_value()
for name, field in self.value.__dict__.items()
if isinstance(field, F... | [
"def",
"to_serializable_value",
"(",
"self",
")",
":",
"return",
"{",
"name",
":",
"field",
".",
"to_serializable_value",
"(",
")",
"for",
"name",
",",
"field",
"in",
"self",
".",
"value",
".",
"__dict__",
".",
"items",
"(",
")",
"if",
"isinstance",
"(",... | Run through all fields of the object and parse the values
:return:
:rtype: dict | [
"Run",
"through",
"all",
"fields",
"of",
"the",
"object",
"and",
"parse",
"the",
"values"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/fields/object_field.py#L26-L37 |
seibert-media/Highton | highton/fields/list_field.py | ListField.encode | def encode(self):
"""
Just iterate over the child elements and append them to the current element
:return: the encoded element
:rtype: xml.etree.ElementTree.Element
"""
element = ElementTree.Element(
self.name,
attrib={'type': FieldConstants.ARRAY... | python | def encode(self):
"""
Just iterate over the child elements and append them to the current element
:return: the encoded element
:rtype: xml.etree.ElementTree.Element
"""
element = ElementTree.Element(
self.name,
attrib={'type': FieldConstants.ARRAY... | [
"def",
"encode",
"(",
"self",
")",
":",
"element",
"=",
"ElementTree",
".",
"Element",
"(",
"self",
".",
"name",
",",
"attrib",
"=",
"{",
"'type'",
":",
"FieldConstants",
".",
"ARRAY",
"}",
",",
")",
"for",
"item",
"in",
"self",
".",
"value",
":",
... | Just iterate over the child elements and append them to the current element
:return: the encoded element
:rtype: xml.etree.ElementTree.Element | [
"Just",
"iterate",
"over",
"the",
"child",
"elements",
"and",
"append",
"them",
"to",
"the",
"current",
"element"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/fields/list_field.py#L18-L31 |
kennknowles/python-rightarrow | rightarrow/constraintgen.py | constraints_stmt | def constraints_stmt(stmt, env=None):
"""
Since a statement may define new names or return an expression ,
the constraints that result are in a
ConstrainedEnv mapping names to types, with constraints, and maybe
having a return type (which is a constrained type)
"""
env = env or {}
... | python | def constraints_stmt(stmt, env=None):
"""
Since a statement may define new names or return an expression ,
the constraints that result are in a
ConstrainedEnv mapping names to types, with constraints, and maybe
having a return type (which is a constrained type)
"""
env = env or {}
... | [
"def",
"constraints_stmt",
"(",
"stmt",
",",
"env",
"=",
"None",
")",
":",
"env",
"=",
"env",
"or",
"{",
"}",
"if",
"isinstance",
"(",
"stmt",
",",
"ast",
".",
"FunctionDef",
")",
":",
"arg_env",
"=",
"fn_env",
"(",
"stmt",
".",
"args",
")",
"body_... | Since a statement may define new names or return an expression ,
the constraints that result are in a
ConstrainedEnv mapping names to types, with constraints, and maybe
having a return type (which is a constrained type) | [
"Since",
"a",
"statement",
"may",
"define",
"new",
"names",
"or",
"return",
"an",
"expression",
"the",
"constraints",
"that",
"result",
"are",
"in",
"a",
"ConstrainedEnv",
"mapping",
"names",
"to",
"types",
"with",
"constraints",
"and",
"maybe",
"having",
"a",... | train | https://github.com/kennknowles/python-rightarrow/blob/86c83bde9d2fba6d54744eac9abedd1c248b7e73/rightarrow/constraintgen.py#L104-L159 |
henzk/django-productline | django_productline/tasks.py | requires_product_environment | def requires_product_environment(func, *args, **kws):
"""
task decorator that makes sure that the product environment
of django_productline is activated:
-context is bound
-features have been composed
"""
from django_productline import startup
startup.select_product()
return func(*ar... | python | def requires_product_environment(func, *args, **kws):
"""
task decorator that makes sure that the product environment
of django_productline is activated:
-context is bound
-features have been composed
"""
from django_productline import startup
startup.select_product()
return func(*ar... | [
"def",
"requires_product_environment",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kws",
")",
":",
"from",
"django_productline",
"import",
"startup",
"startup",
".",
"select_product",
"(",
")",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kws",
... | task decorator that makes sure that the product environment
of django_productline is activated:
-context is bound
-features have been composed | [
"task",
"decorator",
"that",
"makes",
"sure",
"that",
"the",
"product",
"environment",
"of",
"django_productline",
"is",
"activated",
":",
"-",
"context",
"is",
"bound",
"-",
"features",
"have",
"been",
"composed"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L16-L25 |
henzk/django-productline | django_productline/tasks.py | set_site | def set_site():
"""
This method is part of the prepare_data helper.
Sets the site. Default implementation uses localhost.
For production settings refine this helper.
:return:
"""
from django.contrib.sites.models import Site
from django.conf import settings
# Initially set localhost a... | python | def set_site():
"""
This method is part of the prepare_data helper.
Sets the site. Default implementation uses localhost.
For production settings refine this helper.
:return:
"""
from django.contrib.sites.models import Site
from django.conf import settings
# Initially set localhost a... | [
"def",
"set_site",
"(",
")",
":",
"from",
"django",
".",
"contrib",
".",
"sites",
".",
"models",
"import",
"Site",
"from",
"django",
".",
"conf",
"import",
"settings",
"# Initially set localhost as default domain",
"#",
"site",
"=",
"Site",
".",
"objects",
"."... | This method is part of the prepare_data helper.
Sets the site. Default implementation uses localhost.
For production settings refine this helper.
:return: | [
"This",
"method",
"is",
"part",
"of",
"the",
"prepare_data",
"helper",
".",
"Sets",
"the",
"site",
".",
"Default",
"implementation",
"uses",
"localhost",
".",
"For",
"production",
"settings",
"refine",
"this",
"helper",
".",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L107-L121 |
henzk/django-productline | django_productline/tasks.py | djpl_compilemessages | def djpl_compilemessages():
"""
Compile messages hook for django_productline, this task checks for the activated languages
in settings.LANGUAGES. It runs the standard django compilemessages management command with the -l parameter.
Example language setting:
LANGUAGES = [
('en', 'Engl... | python | def djpl_compilemessages():
"""
Compile messages hook for django_productline, this task checks for the activated languages
in settings.LANGUAGES. It runs the standard django compilemessages management command with the -l parameter.
Example language setting:
LANGUAGES = [
('en', 'Engl... | [
"def",
"djpl_compilemessages",
"(",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"if",
"hasattr",
"(",
"settings",
",",
"'LANGUAGES'",
")",
"and",
"len",
"(",
"settings",
".",
"LANGUAGES",
")",
">",
"0",
":",
"# changing cwd to project root",... | Compile messages hook for django_productline, this task checks for the activated languages
in settings.LANGUAGES. It runs the standard django compilemessages management command with the -l parameter.
Example language setting:
LANGUAGES = [
('en', 'English'),
('de', 'Deutsch')
... | [
"Compile",
"messages",
"hook",
"for",
"django_productline",
"this",
"task",
"checks",
"for",
"the",
"activated",
"languages",
"in",
"settings",
".",
"LANGUAGES",
".",
"It",
"runs",
"the",
"standard",
"django",
"compilemessages",
"management",
"command",
"with",
"t... | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L137-L163 |
henzk/django-productline | django_productline/tasks.py | export_data | def export_data(target_path):
"""
Exports the data of an application - media files plus database,
:param: target_path:
:return: a zip archive
"""
tasks.export_data_dir(target_path)
tasks.export_database(target_path)
tasks.export_context(target_path)
return target_path | python | def export_data(target_path):
"""
Exports the data of an application - media files plus database,
:param: target_path:
:return: a zip archive
"""
tasks.export_data_dir(target_path)
tasks.export_database(target_path)
tasks.export_context(target_path)
return target_path | [
"def",
"export_data",
"(",
"target_path",
")",
":",
"tasks",
".",
"export_data_dir",
"(",
"target_path",
")",
"tasks",
".",
"export_database",
"(",
"target_path",
")",
"tasks",
".",
"export_context",
"(",
"target_path",
")",
"return",
"target_path"
] | Exports the data of an application - media files plus database,
:param: target_path:
:return: a zip archive | [
"Exports",
"the",
"data",
"of",
"an",
"application",
"-",
"media",
"files",
"plus",
"database",
":",
"param",
":",
"target_path",
":",
":",
"return",
":",
"a",
"zip",
"archive"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L168-L177 |
henzk/django-productline | django_productline/tasks.py | import_data | def import_data(target_zip):
"""
Import data from given zip-arc, this means database + __data__
:param target_zip:
:param backup_zip_path:
:return:
"""
from django_productline.context import PRODUCT_CONTEXT
tasks.import_data_dir(target_zip)
# product context is not reloaded if contex... | python | def import_data(target_zip):
"""
Import data from given zip-arc, this means database + __data__
:param target_zip:
:param backup_zip_path:
:return:
"""
from django_productline.context import PRODUCT_CONTEXT
tasks.import_data_dir(target_zip)
# product context is not reloaded if contex... | [
"def",
"import_data",
"(",
"target_zip",
")",
":",
"from",
"django_productline",
".",
"context",
"import",
"PRODUCT_CONTEXT",
"tasks",
".",
"import_data_dir",
"(",
"target_zip",
")",
"# product context is not reloaded if context file is changed",
"tasks",
".",
"import_datab... | Import data from given zip-arc, this means database + __data__
:param target_zip:
:param backup_zip_path:
:return: | [
"Import",
"data",
"from",
"given",
"zip",
"-",
"arc",
"this",
"means",
"database",
"+",
"__data__",
":",
"param",
"target_zip",
":",
":",
"param",
"backup_zip_path",
":",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L182-L192 |
henzk/django-productline | django_productline/tasks.py | export_data_dir | def export_data_dir(target_path):
"""
Exports the media files of the application and bundles a zip archive
:return: the target path of the zip archive
"""
from django_productline import utils
from django.conf import settings
utils.zipdir(settings.PRODUCT_CONTEXT.DATA_DIR, target_path, wrapd... | python | def export_data_dir(target_path):
"""
Exports the media files of the application and bundles a zip archive
:return: the target path of the zip archive
"""
from django_productline import utils
from django.conf import settings
utils.zipdir(settings.PRODUCT_CONTEXT.DATA_DIR, target_path, wrapd... | [
"def",
"export_data_dir",
"(",
"target_path",
")",
":",
"from",
"django_productline",
"import",
"utils",
"from",
"django",
".",
"conf",
"import",
"settings",
"utils",
".",
"zipdir",
"(",
"settings",
".",
"PRODUCT_CONTEXT",
".",
"DATA_DIR",
",",
"target_path",
",... | Exports the media files of the application and bundles a zip archive
:return: the target path of the zip archive | [
"Exports",
"the",
"media",
"files",
"of",
"the",
"application",
"and",
"bundles",
"a",
"zip",
"archive",
":",
"return",
":",
"the",
"target",
"path",
"of",
"the",
"zip",
"archive"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L197-L207 |
henzk/django-productline | django_productline/tasks.py | import_data_dir | def import_data_dir(target_zip):
"""
Imports the data specified by param <target_zip>. Renames the data dir if it already exists and
unpacks the zip sub dir __data__ directly within the current active product.
:param target_zip: string path to the zip file.
"""
from django_productline.context im... | python | def import_data_dir(target_zip):
"""
Imports the data specified by param <target_zip>. Renames the data dir if it already exists and
unpacks the zip sub dir __data__ directly within the current active product.
:param target_zip: string path to the zip file.
"""
from django_productline.context im... | [
"def",
"import_data_dir",
"(",
"target_zip",
")",
":",
"from",
"django_productline",
".",
"context",
"import",
"PRODUCT_CONTEXT",
"new_data_dir",
"=",
"'{data_dir}_before_import_{ts}'",
".",
"format",
"(",
"data_dir",
"=",
"PRODUCT_CONTEXT",
".",
"DATA_DIR",
",",
"ts"... | Imports the data specified by param <target_zip>. Renames the data dir if it already exists and
unpacks the zip sub dir __data__ directly within the current active product.
:param target_zip: string path to the zip file. | [
"Imports",
"the",
"data",
"specified",
"by",
"param",
"<target_zip",
">",
".",
"Renames",
"the",
"data",
"dir",
"if",
"it",
"already",
"exists",
"and",
"unpacks",
"the",
"zip",
"sub",
"dir",
"__data__",
"directly",
"within",
"the",
"current",
"active",
"prod... | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L212-L234 |
henzk/django-productline | django_productline/tasks.py | mv_data_dir | def mv_data_dir(target):
"""
Move data_dir to {target} location, refineable in case data_dir is a mounted volume or object storage and needs special treatments
:return:
"""
from django_productline.context import PRODUCT_CONTEXT
os.rename(PRODUCT_CONTEXT.DATA_DIR, target) | python | def mv_data_dir(target):
"""
Move data_dir to {target} location, refineable in case data_dir is a mounted volume or object storage and needs special treatments
:return:
"""
from django_productline.context import PRODUCT_CONTEXT
os.rename(PRODUCT_CONTEXT.DATA_DIR, target) | [
"def",
"mv_data_dir",
"(",
"target",
")",
":",
"from",
"django_productline",
".",
"context",
"import",
"PRODUCT_CONTEXT",
"os",
".",
"rename",
"(",
"PRODUCT_CONTEXT",
".",
"DATA_DIR",
",",
"target",
")"
] | Move data_dir to {target} location, refineable in case data_dir is a mounted volume or object storage and needs special treatments
:return: | [
"Move",
"data_dir",
"to",
"{",
"target",
"}",
"location",
"refineable",
"in",
"case",
"data_dir",
"is",
"a",
"mounted",
"volume",
"or",
"object",
"storage",
"and",
"needs",
"special",
"treatments",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L239-L245 |
henzk/django-productline | django_productline/tasks.py | export_context | def export_context(target_zip):
"""
Append context.json to target_zip
"""
from django_productline import utils
context_file = tasks.get_context_path()
return utils.create_or_append_to_zip(context_file, target_zip, 'context.json') | python | def export_context(target_zip):
"""
Append context.json to target_zip
"""
from django_productline import utils
context_file = tasks.get_context_path()
return utils.create_or_append_to_zip(context_file, target_zip, 'context.json') | [
"def",
"export_context",
"(",
"target_zip",
")",
":",
"from",
"django_productline",
"import",
"utils",
"context_file",
"=",
"tasks",
".",
"get_context_path",
"(",
")",
"return",
"utils",
".",
"create_or_append_to_zip",
"(",
"context_file",
",",
"target_zip",
",",
... | Append context.json to target_zip | [
"Append",
"context",
".",
"json",
"to",
"target_zip"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L260-L266 |
henzk/django-productline | django_productline/tasks.py | import_context | def import_context(target_zip):
"""
Overwrite old context.json, use context.json from target_zip
:param target_zip:
:return:
"""
context_path = tasks.get_context_path()
with zipfile.ZipFile(target_zip) as unzipped_data:
with open(context_path, 'w') as context:
context.wri... | python | def import_context(target_zip):
"""
Overwrite old context.json, use context.json from target_zip
:param target_zip:
:return:
"""
context_path = tasks.get_context_path()
with zipfile.ZipFile(target_zip) as unzipped_data:
with open(context_path, 'w') as context:
context.wri... | [
"def",
"import_context",
"(",
"target_zip",
")",
":",
"context_path",
"=",
"tasks",
".",
"get_context_path",
"(",
")",
"with",
"zipfile",
".",
"ZipFile",
"(",
"target_zip",
")",
"as",
"unzipped_data",
":",
"with",
"open",
"(",
"context_path",
",",
"'w'",
")"... | Overwrite old context.json, use context.json from target_zip
:param target_zip:
:return: | [
"Overwrite",
"old",
"context",
".",
"json",
"use",
"context",
".",
"json",
"from",
"target_zip",
":",
"param",
"target_zip",
":",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L270-L279 |
henzk/django-productline | django_productline/tasks.py | get_context_template | def get_context_template():
"""
Features which require configuration parameters in the product context need to refine
this method and update the context with their own data.
"""
import random
return {
'SITE_ID': 1,
'SECRET_KEY': ''.join(
[random.SystemRandom().choice(... | python | def get_context_template():
"""
Features which require configuration parameters in the product context need to refine
this method and update the context with their own data.
"""
import random
return {
'SITE_ID': 1,
'SECRET_KEY': ''.join(
[random.SystemRandom().choice(... | [
"def",
"get_context_template",
"(",
")",
":",
"import",
"random",
"return",
"{",
"'SITE_ID'",
":",
"1",
",",
"'SECRET_KEY'",
":",
"''",
".",
"join",
"(",
"[",
"random",
".",
"SystemRandom",
"(",
")",
".",
"choice",
"(",
"'abcdefghijklmnopqrstuvwxyz0123456789!@... | Features which require configuration parameters in the product context need to refine
this method and update the context with their own data. | [
"Features",
"which",
"require",
"configuration",
"parameters",
"in",
"the",
"product",
"context",
"need",
"to",
"refine",
"this",
"method",
"and",
"update",
"the",
"context",
"with",
"their",
"own",
"data",
"."
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L303-L314 |
henzk/django-productline | django_productline/tasks.py | create_data_dir | def create_data_dir():
"""
Creates the DATA_DIR.
:return:
"""
from django_productline.context import PRODUCT_CONTEXT
if not os.path.exists(PRODUCT_CONTEXT.DATA_DIR):
os.mkdir(PRODUCT_CONTEXT.DATA_DIR)
print('*** Created DATA_DIR in %s' % PRODUCT_CONTEXT.DATA_DIR)
else:
... | python | def create_data_dir():
"""
Creates the DATA_DIR.
:return:
"""
from django_productline.context import PRODUCT_CONTEXT
if not os.path.exists(PRODUCT_CONTEXT.DATA_DIR):
os.mkdir(PRODUCT_CONTEXT.DATA_DIR)
print('*** Created DATA_DIR in %s' % PRODUCT_CONTEXT.DATA_DIR)
else:
... | [
"def",
"create_data_dir",
"(",
")",
":",
"from",
"django_productline",
".",
"context",
"import",
"PRODUCT_CONTEXT",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"PRODUCT_CONTEXT",
".",
"DATA_DIR",
")",
":",
"os",
".",
"mkdir",
"(",
"PRODUCT_CONTEXT",
... | Creates the DATA_DIR.
:return: | [
"Creates",
"the",
"DATA_DIR",
".",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L319-L329 |
henzk/django-productline | django_productline/tasks.py | generate_context | def generate_context(force_overwrite=False, drop_secret_key=False):
"""
Generates context.json
"""
print('... generating context')
context_fp = '%s/context.json' % os.environ['PRODUCT_DIR']
context = {}
if os.path.isfile(context_fp):
print('... augment existing context.json')
... | python | def generate_context(force_overwrite=False, drop_secret_key=False):
"""
Generates context.json
"""
print('... generating context')
context_fp = '%s/context.json' % os.environ['PRODUCT_DIR']
context = {}
if os.path.isfile(context_fp):
print('... augment existing context.json')
... | [
"def",
"generate_context",
"(",
"force_overwrite",
"=",
"False",
",",
"drop_secret_key",
"=",
"False",
")",
":",
"print",
"(",
"'... generating context'",
")",
"context_fp",
"=",
"'%s/context.json'",
"%",
"os",
".",
"environ",
"[",
"'PRODUCT_DIR'",
"]",
"context",... | Generates context.json | [
"Generates",
"context",
".",
"json"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L333-L368 |
henzk/django-productline | django_productline/tasks.py | clear_tables_for_loaddata | def clear_tables_for_loaddata(confirm=None):
"""
Clears al tables in order to loaddata properly.
:param string:
:return:
"""
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission
from django.contrib.sites.models import Site
if c... | python | def clear_tables_for_loaddata(confirm=None):
"""
Clears al tables in order to loaddata properly.
:param string:
:return:
"""
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission
from django.contrib.sites.models import Site
if c... | [
"def",
"clear_tables_for_loaddata",
"(",
"confirm",
"=",
"None",
")",
":",
"from",
"django",
".",
"contrib",
".",
"contenttypes",
".",
"models",
"import",
"ContentType",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"models",
"import",
"Permission",
"fro... | Clears al tables in order to loaddata properly.
:param string:
:return: | [
"Clears",
"al",
"tables",
"in",
"order",
"to",
"loaddata",
"properly",
".",
":",
"param",
"string",
":",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L373-L388 |
henzk/django-productline | django_productline/tasks.py | inject_context | def inject_context(context):
"""
Updates context.json with data from JSON-string given as param.
:param context:
:return:
"""
context_path = tasks.get_context_path()
try:
new_context = json.loads(context)
except ValueError:
print('Couldn\'t load context parameter')
... | python | def inject_context(context):
"""
Updates context.json with data from JSON-string given as param.
:param context:
:return:
"""
context_path = tasks.get_context_path()
try:
new_context = json.loads(context)
except ValueError:
print('Couldn\'t load context parameter')
... | [
"def",
"inject_context",
"(",
"context",
")",
":",
"context_path",
"=",
"tasks",
".",
"get_context_path",
"(",
")",
"try",
":",
"new_context",
"=",
"json",
".",
"loads",
"(",
"context",
")",
"except",
"ValueError",
":",
"print",
"(",
"'Couldn\\'t load context ... | Updates context.json with data from JSON-string given as param.
:param context:
:return: | [
"Updates",
"context",
".",
"json",
"with",
"data",
"from",
"JSON",
"-",
"string",
"given",
"as",
"param",
".",
":",
"param",
"context",
":",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L392-L412 |
henzk/django-productline | django_productline/tasks.py | write_composer_operation_log | def write_composer_operation_log(filename):
"""
Writes the composed operation log from featuremonkey's Composer to a json file.
:param filename:
:return:
"""
from featuremonkey.tracing import serializer
from featuremonkey.tracing.logger import OPERATION_LOG
ol = copy.deepcopy(OPERATION_L... | python | def write_composer_operation_log(filename):
"""
Writes the composed operation log from featuremonkey's Composer to a json file.
:param filename:
:return:
"""
from featuremonkey.tracing import serializer
from featuremonkey.tracing.logger import OPERATION_LOG
ol = copy.deepcopy(OPERATION_L... | [
"def",
"write_composer_operation_log",
"(",
"filename",
")",
":",
"from",
"featuremonkey",
".",
"tracing",
"import",
"serializer",
"from",
"featuremonkey",
".",
"tracing",
".",
"logger",
"import",
"OPERATION_LOG",
"ol",
"=",
"copy",
".",
"deepcopy",
"(",
"OPERATIO... | Writes the composed operation log from featuremonkey's Composer to a json file.
:param filename:
:return: | [
"Writes",
"the",
"composed",
"operation",
"log",
"from",
"featuremonkey",
"s",
"Composer",
"to",
"a",
"json",
"file",
".",
":",
"param",
"filename",
":",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/tasks.py#L417-L428 |
seibert-media/Highton | highton/call_mixins/search_call_mixin.py | SearchCallMixin.search | def search(cls, term=None, page=0, **criteria):
"""
Search a list of the model
If you use "term":
- Returns a collection of people that have a name matching the term passed in through the URL.
If you use "criteria":
- returns people who match your search criteria.
... | python | def search(cls, term=None, page=0, **criteria):
"""
Search a list of the model
If you use "term":
- Returns a collection of people that have a name matching the term passed in through the URL.
If you use "criteria":
- returns people who match your search criteria.
... | [
"def",
"search",
"(",
"cls",
",",
"term",
"=",
"None",
",",
"page",
"=",
"0",
",",
"*",
"*",
"criteria",
")",
":",
"assert",
"(",
"term",
"or",
"criteria",
"and",
"not",
"(",
"term",
"and",
"criteria",
")",
")",
"params",
"=",
"{",
"'n'",
":",
... | Search a list of the model
If you use "term":
- Returns a collection of people that have a name matching the term passed in through the URL.
If you use "criteria":
- returns people who match your search criteria.
Search by any criteria you can on the Contacts tab, including cust... | [
"Search",
"a",
"list",
"of",
"the",
"model",
"If",
"you",
"use",
"term",
":",
"-",
"Returns",
"a",
"collection",
"of",
"people",
"that",
"have",
"a",
"name",
"matching",
"the",
"term",
"passed",
"in",
"through",
"the",
"URL",
"."
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/call_mixins/search_call_mixin.py#L14-L54 |
fhcrc/nestly | nestly/scripts/nestagg.py | _delim_accum | def _delim_accum(control_files, filename_template, keys=None,
exclude_keys=None, separator=DEFAULT_SEP, missing_action='fail'):
"""
Accumulator for delimited files
Combines each file with values from JSON dictionary in same directory
:param iterable control_files: Iterable of control files
... | python | def _delim_accum(control_files, filename_template, keys=None,
exclude_keys=None, separator=DEFAULT_SEP, missing_action='fail'):
"""
Accumulator for delimited files
Combines each file with values from JSON dictionary in same directory
:param iterable control_files: Iterable of control files
... | [
"def",
"_delim_accum",
"(",
"control_files",
",",
"filename_template",
",",
"keys",
"=",
"None",
",",
"exclude_keys",
"=",
"None",
",",
"separator",
"=",
"DEFAULT_SEP",
",",
"missing_action",
"=",
"'fail'",
")",
":",
"def",
"map_fn",
"(",
"d",
",",
"control"... | Accumulator for delimited files
Combines each file with values from JSON dictionary in same directory
:param iterable control_files: Iterable of control files
:param filename_template: A template for the file to nest_map
:param keys: List of keys to select from JSON dictionary. If ``None``, keep
... | [
"Accumulator",
"for",
"delimited",
"files"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestagg.py#L39-L75 |
fhcrc/nestly | nestly/scripts/nestagg.py | delim | def delim(arguments):
"""
Execute delim action.
:param arguments: Parsed command line arguments from :func:`main`
"""
if bool(arguments.control_files) == bool(arguments.directory):
raise ValueError(
'Exactly one of control_files and `-d` must be specified.')
if argumen... | python | def delim(arguments):
"""
Execute delim action.
:param arguments: Parsed command line arguments from :func:`main`
"""
if bool(arguments.control_files) == bool(arguments.directory):
raise ValueError(
'Exactly one of control_files and `-d` must be specified.')
if argumen... | [
"def",
"delim",
"(",
"arguments",
")",
":",
"if",
"bool",
"(",
"arguments",
".",
"control_files",
")",
"==",
"bool",
"(",
"arguments",
".",
"directory",
")",
":",
"raise",
"ValueError",
"(",
"'Exactly one of control_files and `-d` must be specified.'",
")",
"if",
... | Execute delim action.
:param arguments: Parsed command line arguments from :func:`main` | [
"Execute",
"delim",
"action",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestagg.py#L77-L100 |
fhcrc/nestly | nestly/scripts/nestagg.py | main | def main(args=sys.argv[1:]):
"""
Command-line interface for nestagg
"""
parser = argparse.ArgumentParser(description="""Aggregate results of
nestly runs""")
subparsers = parser.add_subparsers()
delim_parser = subparsers.add_parser('delim', help="""Combine control files
wi... | python | def main(args=sys.argv[1:]):
"""
Command-line interface for nestagg
"""
parser = argparse.ArgumentParser(description="""Aggregate results of
nestly runs""")
subparsers = parser.add_subparsers()
delim_parser = subparsers.add_parser('delim', help="""Combine control files
wi... | [
"def",
"main",
"(",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"\"\"Aggregate results of\n nestly runs\"\"\"",
")",
"subparsers",
"=",
"parser",
".",
"a... | Command-line interface for nestagg | [
"Command",
"-",
"line",
"interface",
"for",
"nestagg"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestagg.py#L106-L142 |
seibert-media/Highton | highton/call_mixins/delete_call_mixin.py | DeleteCallMixin.delete | def delete(self):
"""
Deletes the object
:return:
:rtype: None
"""
return self._delete_request(endpoint=self.ENDPOINT + '/' + str(self.id)) | python | def delete(self):
"""
Deletes the object
:return:
:rtype: None
"""
return self._delete_request(endpoint=self.ENDPOINT + '/' + str(self.id)) | [
"def",
"delete",
"(",
"self",
")",
":",
"return",
"self",
".",
"_delete_request",
"(",
"endpoint",
"=",
"self",
".",
"ENDPOINT",
"+",
"'/'",
"+",
"str",
"(",
"self",
".",
"id",
")",
")"
] | Deletes the object
:return:
:rtype: None | [
"Deletes",
"the",
"object"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/call_mixins/delete_call_mixin.py#L10-L17 |
shimpe/pyvectortween | vectortween/NumberAnimation.py | NumberAnimation.make_frame | def make_frame(self, frame, birthframe, startframe, stopframe, deathframe, noiseframe=None):
"""
animation happens between startframe and stopframe
the value is None before aliveframe, and after deathframe
* if aliveframe is not specified it defaults to startframe
* if deathfra... | python | def make_frame(self, frame, birthframe, startframe, stopframe, deathframe, noiseframe=None):
"""
animation happens between startframe and stopframe
the value is None before aliveframe, and after deathframe
* if aliveframe is not specified it defaults to startframe
* if deathfra... | [
"def",
"make_frame",
"(",
"self",
",",
"frame",
",",
"birthframe",
",",
"startframe",
",",
"stopframe",
",",
"deathframe",
",",
"noiseframe",
"=",
"None",
")",
":",
"if",
"birthframe",
"is",
"None",
":",
"birthframe",
"=",
"startframe",
"if",
"deathframe",
... | animation happens between startframe and stopframe
the value is None before aliveframe, and after deathframe
* if aliveframe is not specified it defaults to startframe
* if deathframe is not specified it defaults to stopframe
initial value is held from aliveframe to startframe
... | [
"animation",
"happens",
"between",
"startframe",
"and",
"stopframe",
"the",
"value",
"is",
"None",
"before",
"aliveframe",
"and",
"after",
"deathframe",
"*",
"if",
"aliveframe",
"is",
"not",
"specified",
"it",
"defaults",
"to",
"startframe",
"*",
"if",
"deathfra... | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/NumberAnimation.py#L32-L68 |
ionelmc/python-cogen | cogen/core/sockets.py | Socket.recv | def recv(self, bufsize, **kws):
"""Receive data from the socket. The return value is a string
representing the data received. The amount of data may be less than the
ammount specified by _bufsize_. """
return Recv(self, bufsize, timeout=self._timeout, **kws) | python | def recv(self, bufsize, **kws):
"""Receive data from the socket. The return value is a string
representing the data received. The amount of data may be less than the
ammount specified by _bufsize_. """
return Recv(self, bufsize, timeout=self._timeout, **kws) | [
"def",
"recv",
"(",
"self",
",",
"bufsize",
",",
"*",
"*",
"kws",
")",
":",
"return",
"Recv",
"(",
"self",
",",
"bufsize",
",",
"timeout",
"=",
"self",
".",
"_timeout",
",",
"*",
"*",
"kws",
")"
] | Receive data from the socket. The return value is a string
representing the data received. The amount of data may be less than the
ammount specified by _bufsize_. | [
"Receive",
"data",
"from",
"the",
"socket",
".",
"The",
"return",
"value",
"is",
"a",
"string",
"representing",
"the",
"data",
"received",
".",
"The",
"amount",
"of",
"data",
"may",
"be",
"less",
"than",
"the",
"ammount",
"specified",
"by",
"_bufsize_",
".... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/sockets.py#L79-L83 |
ionelmc/python-cogen | cogen/core/sockets.py | Socket.sendall | def sendall(self, data, **kws):
"""Send data to the socket. The socket must be connected to a remote
socket. All the data is guaranteed to be sent."""
return SendAll(self, data, timeout=self._timeout, **kws) | python | def sendall(self, data, **kws):
"""Send data to the socket. The socket must be connected to a remote
socket. All the data is guaranteed to be sent."""
return SendAll(self, data, timeout=self._timeout, **kws) | [
"def",
"sendall",
"(",
"self",
",",
"data",
",",
"*",
"*",
"kws",
")",
":",
"return",
"SendAll",
"(",
"self",
",",
"data",
",",
"timeout",
"=",
"self",
".",
"_timeout",
",",
"*",
"*",
"kws",
")"
] | Send data to the socket. The socket must be connected to a remote
socket. All the data is guaranteed to be sent. | [
"Send",
"data",
"to",
"the",
"socket",
".",
"The",
"socket",
"must",
"be",
"connected",
"to",
"a",
"remote",
"socket",
".",
"All",
"the",
"data",
"is",
"guaranteed",
"to",
"be",
"sent",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/sockets.py#L98-L101 |
cthoyt/onto2nx | src/onto2nx/owl_rdf.py | parse_owl_rdf | def parse_owl_rdf(iri):
"""Parses an OWL resource that's encoded in OWL/RDF into a NetworkX directional graph
:param str iri: The location of the OWL resource to be parsed by Ontospy
:type iri: str
:rtype: network.DiGraph
"""
g = nx.DiGraph(IRI=iri)
o = Ontospy(iri)
for cls in o.cl... | python | def parse_owl_rdf(iri):
"""Parses an OWL resource that's encoded in OWL/RDF into a NetworkX directional graph
:param str iri: The location of the OWL resource to be parsed by Ontospy
:type iri: str
:rtype: network.DiGraph
"""
g = nx.DiGraph(IRI=iri)
o = Ontospy(iri)
for cls in o.cl... | [
"def",
"parse_owl_rdf",
"(",
"iri",
")",
":",
"g",
"=",
"nx",
".",
"DiGraph",
"(",
"IRI",
"=",
"iri",
")",
"o",
"=",
"Ontospy",
"(",
"iri",
")",
"for",
"cls",
"in",
"o",
".",
"classes",
":",
"g",
".",
"add_node",
"(",
"cls",
".",
"locale",
",",... | Parses an OWL resource that's encoded in OWL/RDF into a NetworkX directional graph
:param str iri: The location of the OWL resource to be parsed by Ontospy
:type iri: str
:rtype: network.DiGraph | [
"Parses",
"an",
"OWL",
"resource",
"that",
"s",
"encoded",
"in",
"OWL",
"/",
"RDF",
"into",
"a",
"NetworkX",
"directional",
"graph",
":",
"param",
"str",
"iri",
":",
"The",
"location",
"of",
"the",
"OWL",
"resource",
"to",
"be",
"parsed",
"by",
"Ontospy"... | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/owl_rdf.py#L15-L35 |
shimpe/pyvectortween | vectortween/Mapping.py | Mapping.linlin | def linlin(value, in_min, in_max, out_min, out_max, clip=True):
"""
maps value \in [in_min,in_max] linearly to the corresponding value \in [out_min, out_max]
(extrapolating if needed)
e.g. linlin(0.3,0,1,10,20) = 13
:param value: value to be mapped
:param in... | python | def linlin(value, in_min, in_max, out_min, out_max, clip=True):
"""
maps value \in [in_min,in_max] linearly to the corresponding value \in [out_min, out_max]
(extrapolating if needed)
e.g. linlin(0.3,0,1,10,20) = 13
:param value: value to be mapped
:param in... | [
"def",
"linlin",
"(",
"value",
",",
"in_min",
",",
"in_max",
",",
"out_min",
",",
"out_max",
",",
"clip",
"=",
"True",
")",
":",
"if",
"in_min",
"==",
"in_max",
":",
"if",
"value",
"==",
"in_min",
"and",
"out_min",
"==",
"out_max",
":",
"return",
"ou... | maps value \in [in_min,in_max] linearly to the corresponding value \in [out_min, out_max]
(extrapolating if needed)
e.g. linlin(0.3,0,1,10,20) = 13
:param value: value to be mapped
:param in_min: input range minimum
:param in_max: input range maximum
:param ... | [
"maps",
"value",
"\\",
"in",
"[",
"in_min",
"in_max",
"]",
"linearly",
"to",
"the",
"corresponding",
"value",
"\\",
"in",
"[",
"out_min",
"out_max",
"]",
"(",
"extrapolating",
"if",
"needed",
")",
"e",
".",
"g",
".",
"linlin",
"(",
"0",
".",
"3",
"0"... | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/Mapping.py#L24-L49 |
shimpe/pyvectortween | vectortween/Mapping.py | Mapping.linexp | def linexp(value, in_min, in_max, out_min, out_max, clip=True):
"""
maps value \in linear range [in_min,in_max] corresponding value \in exponential range [out_min, out_max]
(extrapolating if needed)
:param value: value to be mapped
:param in_min: input range minimum
:pa... | python | def linexp(value, in_min, in_max, out_min, out_max, clip=True):
"""
maps value \in linear range [in_min,in_max] corresponding value \in exponential range [out_min, out_max]
(extrapolating if needed)
:param value: value to be mapped
:param in_min: input range minimum
:pa... | [
"def",
"linexp",
"(",
"value",
",",
"in_min",
",",
"in_max",
",",
"out_min",
",",
"out_max",
",",
"clip",
"=",
"True",
")",
":",
"if",
"out_min",
"==",
"0",
":",
"return",
"None",
"if",
"in_min",
"==",
"in_max",
":",
"if",
"value",
"==",
"in_min",
... | maps value \in linear range [in_min,in_max] corresponding value \in exponential range [out_min, out_max]
(extrapolating if needed)
:param value: value to be mapped
:param in_min: input range minimum
:param in_max: input range maximum
:param out_min: what input range minimum is ... | [
"maps",
"value",
"\\",
"in",
"linear",
"range",
"[",
"in_min",
"in_max",
"]",
"corresponding",
"value",
"\\",
"in",
"exponential",
"range",
"[",
"out_min",
"out_max",
"]",
"(",
"extrapolating",
"if",
"needed",
")"
] | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/Mapping.py#L52-L75 |
zetaops/pyoko | pyoko/db/schema_update.py | SchemaUpdater.find_models_and_delete_search_index | def find_models_and_delete_search_index(self, model, force, exec_models, check_only):
"""
Finds models to execute and these models' exist search indexes are deleted.
For other operations, necessary models are gathered to list(exec_models)
Args:
model: model to execute
... | python | def find_models_and_delete_search_index(self, model, force, exec_models, check_only):
"""
Finds models to execute and these models' exist search indexes are deleted.
For other operations, necessary models are gathered to list(exec_models)
Args:
model: model to execute
... | [
"def",
"find_models_and_delete_search_index",
"(",
"self",
",",
"model",
",",
"force",
",",
"exec_models",
",",
"check_only",
")",
":",
"ins",
"=",
"model",
"(",
"fake_context",
")",
"fields",
"=",
"self",
".",
"get_schema_fields",
"(",
"ins",
".",
"_collect_i... | Finds models to execute and these models' exist search indexes are deleted.
For other operations, necessary models are gathered to list(exec_models)
Args:
model: model to execute
force(bool): True or False if True, all given models are executed.
exec_models(list): if... | [
"Finds",
"models",
"to",
"execute",
"and",
"these",
"models",
"exist",
"search",
"indexes",
"are",
"deleted",
".",
"For",
"other",
"operations",
"necessary",
"models",
"are",
"gathered",
"to",
"list",
"(",
"exec_models",
")"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/schema_update.py#L130-L171 |
zetaops/pyoko | pyoko/db/schema_update.py | SchemaUpdater.creating_schema_and_index | def creating_schema_and_index(self, models, func):
"""
Executes given functions with given models.
Args:
models: models to execute
func: function name to execute
Returns:
"""
waiting_models = []
self.base_thread.do_with_submit(func, mode... | python | def creating_schema_and_index(self, models, func):
"""
Executes given functions with given models.
Args:
models: models to execute
func: function name to execute
Returns:
"""
waiting_models = []
self.base_thread.do_with_submit(func, mode... | [
"def",
"creating_schema_and_index",
"(",
"self",
",",
"models",
",",
"func",
")",
":",
"waiting_models",
"=",
"[",
"]",
"self",
".",
"base_thread",
".",
"do_with_submit",
"(",
"func",
",",
"models",
",",
"waiting_models",
",",
"threads",
"=",
"self",
".",
... | Executes given functions with given models.
Args:
models: models to execute
func: function name to execute
Returns: | [
"Executes",
"given",
"functions",
"with",
"given",
"models",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/schema_update.py#L173-L188 |
zetaops/pyoko | pyoko/db/schema_update.py | SchemaUpdater.create_schema | def create_schema(self, model, waiting_models):
"""
Creates search schemas.
Args:
model: model to execute
waiting_models: if riak can't return response immediately, model is taken to queue.
After first execution session, method is executed with waiting models... | python | def create_schema(self, model, waiting_models):
"""
Creates search schemas.
Args:
model: model to execute
waiting_models: if riak can't return response immediately, model is taken to queue.
After first execution session, method is executed with waiting models... | [
"def",
"create_schema",
"(",
"self",
",",
"model",
",",
"waiting_models",
")",
":",
"bucket_name",
"=",
"model",
".",
"_get_bucket_name",
"(",
")",
"index_name",
"=",
"\"%s_%s\"",
"%",
"(",
"settings",
".",
"DEFAULT_BUCKET_TYPE",
",",
"bucket_name",
")",
"ins"... | Creates search schemas.
Args:
model: model to execute
waiting_models: if riak can't return response immediately, model is taken to queue.
After first execution session, method is executed with waiting models and controlled.
And be ensured that all given models ar... | [
"Creates",
"search",
"schemas",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/schema_update.py#L190-L216 |
zetaops/pyoko | pyoko/db/schema_update.py | SchemaUpdater.create_index | def create_index(self, model, waiting_models):
"""
Creates search indexes.
Args:
model: model to execute
waiting_models: if riak can't return response immediately, model is taken to queue.
After first execution session, method is executed with waiting models ... | python | def create_index(self, model, waiting_models):
"""
Creates search indexes.
Args:
model: model to execute
waiting_models: if riak can't return response immediately, model is taken to queue.
After first execution session, method is executed with waiting models ... | [
"def",
"create_index",
"(",
"self",
",",
"model",
",",
"waiting_models",
")",
":",
"bucket_name",
"=",
"model",
".",
"_get_bucket_name",
"(",
")",
"bucket_type",
"=",
"client",
".",
"bucket_type",
"(",
"settings",
".",
"DEFAULT_BUCKET_TYPE",
")",
"index_name",
... | Creates search indexes.
Args:
model: model to execute
waiting_models: if riak can't return response immediately, model is taken to queue.
After first execution session, method is executed with waiting models and controlled.
And be ensured that all given models ar... | [
"Creates",
"search",
"indexes",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/schema_update.py#L218-L248 |
zetaops/pyoko | pyoko/db/schema_update.py | SchemaUpdater.create_report | def create_report(self):
"""
creates a text report for the human user
:return: str
"""
if self.report:
self.report += "\n Operation took %s secs" % round(
time.time() - self.t1)
else:
self.report = "Operation failed: %s \n" % self.... | python | def create_report(self):
"""
creates a text report for the human user
:return: str
"""
if self.report:
self.report += "\n Operation took %s secs" % round(
time.time() - self.t1)
else:
self.report = "Operation failed: %s \n" % self.... | [
"def",
"create_report",
"(",
"self",
")",
":",
"if",
"self",
".",
"report",
":",
"self",
".",
"report",
"+=",
"\"\\n Operation took %s secs\"",
"%",
"round",
"(",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"t1",
")",
"else",
":",
"self",
".",
"... | creates a text report for the human user
:return: str | [
"creates",
"a",
"text",
"report",
"for",
"the",
"human",
"user",
":",
"return",
":",
"str"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/schema_update.py#L250-L261 |
zetaops/pyoko | pyoko/db/schema_update.py | SchemaUpdater.compile_schema | def compile_schema(fields):
"""
joins schema fields with base solr schema
:param list[str] fields: field list
:return: compiled schema
:rtype: byte
"""
path = os.path.dirname(os.path.realpath(__file__))
# path = os.path.dirname(
# os.path.absp... | python | def compile_schema(fields):
"""
joins schema fields with base solr schema
:param list[str] fields: field list
:return: compiled schema
:rtype: byte
"""
path = os.path.dirname(os.path.realpath(__file__))
# path = os.path.dirname(
# os.path.absp... | [
"def",
"compile_schema",
"(",
"fields",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"# path = os.path.dirname(",
"# os.path.abspath(inspect.getfile(inspect.currentframe())))",
"wit... | joins schema fields with base solr schema
:param list[str] fields: field list
:return: compiled schema
:rtype: byte | [
"joins",
"schema",
"fields",
"with",
"base",
"solr",
"schema"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/schema_update.py#L279-L297 |
cknoll/ipydex | examples/example1.py | func2 | def func2(q1, q2):
"""
to demonstrate debugging on exception
"""
a = q1/q2
if q2 == 5:
z = 100
IPS() # start embedded ipython shell in the local scope
# -> explore global namespace
return a | python | def func2(q1, q2):
"""
to demonstrate debugging on exception
"""
a = q1/q2
if q2 == 5:
z = 100
IPS() # start embedded ipython shell in the local scope
# -> explore global namespace
return a | [
"def",
"func2",
"(",
"q1",
",",
"q2",
")",
":",
"a",
"=",
"q1",
"/",
"q2",
"if",
"q2",
"==",
"5",
":",
"z",
"=",
"100",
"IPS",
"(",
")",
"# start embedded ipython shell in the local scope",
"# -> explore global namespace",
"return",
"a"
] | to demonstrate debugging on exception | [
"to",
"demonstrate",
"debugging",
"on",
"exception"
] | train | https://github.com/cknoll/ipydex/blob/ca528ce4c97ee934e48efbd5983c1b7cd88bec9d/examples/example1.py#L22-L35 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.save_model | def save_model(self, model, meta_data=None, index_fields=None):
"""
saves the model instance to riak
Args:
meta (dict): JSON serializable meta data for logging of save operation.
{'lorem': 'ipsum', 'dolar': 5}
index_fields (list): Tuple list for secondary... | python | def save_model(self, model, meta_data=None, index_fields=None):
"""
saves the model instance to riak
Args:
meta (dict): JSON serializable meta data for logging of save operation.
{'lorem': 'ipsum', 'dolar': 5}
index_fields (list): Tuple list for secondary... | [
"def",
"save_model",
"(",
"self",
",",
"model",
",",
"meta_data",
"=",
"None",
",",
"index_fields",
"=",
"None",
")",
":",
"return",
"self",
".",
"adapter",
".",
"save_model",
"(",
"model",
",",
"meta_data",
",",
"index_fields",
")"
] | saves the model instance to riak
Args:
meta (dict): JSON serializable meta data for logging of save operation.
{'lorem': 'ipsum', 'dolar': 5}
index_fields (list): Tuple list for secondary indexing keys in riak (with 'bin' or 'int').
[('lorem','bin'),('dol... | [
"saves",
"the",
"model",
"instance",
"to",
"riak"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L145-L156 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet._make_model | def _make_model(self, data, key=None):
"""
Creates a model instance with the given data.
Args:
data: Model data returned from DB.
key: Object key
Returns:
pyoko.Model object.
"""
if data['deleted'] and not self.adapter.want_deleted:
... | python | def _make_model(self, data, key=None):
"""
Creates a model instance with the given data.
Args:
data: Model data returned from DB.
key: Object key
Returns:
pyoko.Model object.
"""
if data['deleted'] and not self.adapter.want_deleted:
... | [
"def",
"_make_model",
"(",
"self",
",",
"data",
",",
"key",
"=",
"None",
")",
":",
"if",
"data",
"[",
"'deleted'",
"]",
"and",
"not",
"self",
".",
"adapter",
".",
"want_deleted",
":",
"raise",
"ObjectDoesNotExist",
"(",
"'Deleted object returned'",
")",
"m... | Creates a model instance with the given data.
Args:
data: Model data returned from DB.
key: Object key
Returns:
pyoko.Model object. | [
"Creates",
"a",
"model",
"instance",
"with",
"the",
"given",
"data",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L158-L176 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.filter | def filter(self, all_records=False, **filters):
"""
Applies given query filters. If wanted result is more than specified size,
exception is raised about using all() method instead of filter.
Args:
all_records (bool):
**filters: Query filters as keyword arguments.... | python | def filter(self, all_records=False, **filters):
"""
Applies given query filters. If wanted result is more than specified size,
exception is raised about using all() method instead of filter.
Args:
all_records (bool):
**filters: Query filters as keyword arguments.... | [
"def",
"filter",
"(",
"self",
",",
"all_records",
"=",
"False",
",",
"*",
"*",
"filters",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"clone",
".",
"adapter",
".",
"add_query",
"(",
"filters",
".",
"items",
"(",
")",
")",
"cl... | Applies given query filters. If wanted result is more than specified size,
exception is raised about using all() method instead of filter.
Args:
all_records (bool):
**filters: Query filters as keyword arguments.
Returns:
Self. Queryset object.
Examp... | [
"Applies",
"given",
"query",
"filters",
".",
"If",
"wanted",
"result",
"is",
"more",
"than",
"specified",
"size",
"exception",
"is",
"raised",
"about",
"using",
"all",
"()",
"method",
"instead",
"of",
"filter",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L193-L224 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.exclude | def exclude(self, **filters):
"""
Applies query filters for excluding matching records from result set.
Args:
**filters: Query filters as keyword arguments.
Returns:
Self. Queryset object.
Examples:
>>> Person.objects.exclude(age=None)
... | python | def exclude(self, **filters):
"""
Applies query filters for excluding matching records from result set.
Args:
**filters: Query filters as keyword arguments.
Returns:
Self. Queryset object.
Examples:
>>> Person.objects.exclude(age=None)
... | [
"def",
"exclude",
"(",
"self",
",",
"*",
"*",
"filters",
")",
":",
"exclude",
"=",
"{",
"'-%s'",
"%",
"key",
":",
"value",
"for",
"key",
",",
"value",
"in",
"filters",
".",
"items",
"(",
")",
"}",
"return",
"self",
".",
"filter",
"(",
"*",
"*",
... | Applies query filters for excluding matching records from result set.
Args:
**filters: Query filters as keyword arguments.
Returns:
Self. Queryset object.
Examples:
>>> Person.objects.exclude(age=None)
>>> Person.objects.filter(name__startswith=... | [
"Applies",
"query",
"filters",
"for",
"excluding",
"matching",
"records",
"from",
"result",
"set",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L240-L255 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.get_or_create | def get_or_create(self, defaults=None, **kwargs):
"""
Looks up an object with the given kwargs, creating a new one if necessary.
Args:
defaults (dict): Used when we create a new object. Must map to fields
of the model.
\*\*kwargs: Used both for filtering ... | python | def get_or_create(self, defaults=None, **kwargs):
"""
Looks up an object with the given kwargs, creating a new one if necessary.
Args:
defaults (dict): Used when we create a new object. Must map to fields
of the model.
\*\*kwargs: Used both for filtering ... | [
"def",
"get_or_create",
"(",
"self",
",",
"defaults",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"self",
".",
"get",
"(",
"*",
"*",
"kwargs",
")",
",",
"False",
"except",
"ObjectDoesNotExist",
":",
"pass",
"data",
"=",
"def... | Looks up an object with the given kwargs, creating a new one if necessary.
Args:
defaults (dict): Used when we create a new object. Must map to fields
of the model.
\*\*kwargs: Used both for filtering and new object creation.
Returns:
A tuple of (obj... | [
"Looks",
"up",
"an",
"object",
"with",
"the",
"given",
"kwargs",
"creating",
"a",
"new",
"one",
"if",
"necessary",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L257-L291 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.delete_if_exists | def delete_if_exists(self, **kwargs):
"""
Deletes an object if it exists in database according to given query
parameters and returns True otherwise does nothing and returns False.
Args:
**kwargs: query parameters
Returns(bool): True or False
"""
... | python | def delete_if_exists(self, **kwargs):
"""
Deletes an object if it exists in database according to given query
parameters and returns True otherwise does nothing and returns False.
Args:
**kwargs: query parameters
Returns(bool): True or False
"""
... | [
"def",
"delete_if_exists",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"get",
"(",
"*",
"*",
"kwargs",
")",
".",
"blocking_delete",
"(",
")",
"return",
"True",
"except",
"ObjectDoesNotExist",
":",
"return",
"False"
] | Deletes an object if it exists in database according to given query
parameters and returns True otherwise does nothing and returns False.
Args:
**kwargs: query parameters
Returns(bool): True or False | [
"Deletes",
"an",
"object",
"if",
"it",
"exists",
"in",
"database",
"according",
"to",
"given",
"query",
"parameters",
"and",
"returns",
"True",
"otherwise",
"does",
"nothing",
"and",
"returns",
"False",
".",
"Args",
":",
"**",
"kwargs",
":",
"query",
"parame... | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L309-L324 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.update | def update(self, **kwargs):
"""
Updates the matching objects for specified fields.
Note:
Post/pre save hooks and signals will NOT triggered.
Unlike RDBMS systems, this method makes individual save calls
to backend DB store. So this is exists as more of a com... | python | def update(self, **kwargs):
"""
Updates the matching objects for specified fields.
Note:
Post/pre save hooks and signals will NOT triggered.
Unlike RDBMS systems, this method makes individual save calls
to backend DB store. So this is exists as more of a com... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"do_simple_update",
"=",
"kwargs",
".",
"get",
"(",
"'simple_update'",
",",
"True",
")",
"no_of_updates",
"=",
"0",
"for",
"model",
"in",
"self",
":",
"no_of_updates",
"+=",
"1",
"model",
... | Updates the matching objects for specified fields.
Note:
Post/pre save hooks and signals will NOT triggered.
Unlike RDBMS systems, this method makes individual save calls
to backend DB store. So this is exists as more of a comfortable
utility method and not a pe... | [
"Updates",
"the",
"matching",
"objects",
"for",
"specified",
"fields",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L326-L354 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.get | def get(self, key=None, **kwargs):
"""
Ensures that only one result is returned from DB and raises an exception otherwise.
Can work in 3 different way.
- If no argument is given, only does "ensuring about one and only object" job.
- If key given as only argument, retriev... | python | def get(self, key=None, **kwargs):
"""
Ensures that only one result is returned from DB and raises an exception otherwise.
Can work in 3 different way.
- If no argument is given, only does "ensuring about one and only object" job.
- If key given as only argument, retriev... | [
"def",
"get",
"(",
"self",
",",
"key",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"# If we are in a slice, adjust the start and rows",
"if",
"self",
".",
"_start",
":",
"clone",
".",
"adapter",
... | Ensures that only one result is returned from DB and raises an exception otherwise.
Can work in 3 different way.
- If no argument is given, only does "ensuring about one and only object" job.
- If key given as only argument, retrieves the object from DB.
- if query filters g... | [
"Ensures",
"that",
"only",
"one",
"result",
"is",
"returned",
"from",
"DB",
"and",
"raises",
"an",
"exception",
"otherwise",
".",
"Can",
"work",
"in",
"3",
"different",
"way",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L356-L382 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.delete | def delete(self):
"""
Deletes all objects that matches to the queryset.
Note:
Unlike RDBMS systems, this method makes individual save calls
to backend DB store. So this is exists as more of a comfortable
utility method and not a performance enhancement.
... | python | def delete(self):
"""
Deletes all objects that matches to the queryset.
Note:
Unlike RDBMS systems, this method makes individual save calls
to backend DB store. So this is exists as more of a comfortable
utility method and not a performance enhancement.
... | [
"def",
"delete",
"(",
"self",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"# clone.adapter.want_deleted = True",
"return",
"[",
"item",
".",
"delete",
"(",
")",
"and",
"item",
"for",
"item",
"in",
"clone",
"]"
] | Deletes all objects that matches to the queryset.
Note:
Unlike RDBMS systems, this method makes individual save calls
to backend DB store. So this is exists as more of a comfortable
utility method and not a performance enhancement.
Returns:
List of delet... | [
"Deletes",
"all",
"objects",
"that",
"matches",
"to",
"the",
"queryset",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L384-L402 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.values_list | def values_list(self, *args, **kwargs):
"""
Returns list of values for given fields.
Since this will implicitly use data() method,
it's more efficient than simply looping through model instances.
Args:
flatten (bool): True. Flatten if there is only one field name gi... | python | def values_list(self, *args, **kwargs):
"""
Returns list of values for given fields.
Since this will implicitly use data() method,
it's more efficient than simply looping through model instances.
Args:
flatten (bool): True. Flatten if there is only one field name gi... | [
"def",
"values_list",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"results",
"=",
"[",
"]",
"for",
"data",
",",
"key",
"in",
"self",
".",
"data",
"(",
")",
":",
"results",
".",
"append",
"(",
"[",
"data",
"[",
"val",
"]",
... | Returns list of values for given fields.
Since this will implicitly use data() method,
it's more efficient than simply looping through model instances.
Args:
flatten (bool): True. Flatten if there is only one field name given.
Returns ['one','two', 'three'] instead of
... | [
"Returns",
"list",
"of",
"values",
"for",
"given",
"fields",
".",
"Since",
"this",
"will",
"implicitly",
"use",
"data",
"()",
"method",
"it",
"s",
"more",
"efficient",
"than",
"simply",
"looping",
"through",
"model",
"instances",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L404-L428 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.values | def values(self, *args):
"""
Returns list of dicts (field names as keys) for given fields.
Args:
\*args: List of fields to be returned as dict.
Returns:
list of dicts for given fields.
Example:
>>> Person.objects.filter(age__gte=16, name__st... | python | def values(self, *args):
"""
Returns list of dicts (field names as keys) for given fields.
Args:
\*args: List of fields to be returned as dict.
Returns:
list of dicts for given fields.
Example:
>>> Person.objects.filter(age__gte=16, name__st... | [
"def",
"values",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"[",
"dict",
"(",
"zip",
"(",
"args",
",",
"values_list",
")",
")",
"for",
"values_list",
"in",
"self",
".",
"values_list",
"(",
"flatten",
"=",
"False",
",",
"*",
"args",
")",
"]"... | Returns list of dicts (field names as keys) for given fields.
Args:
\*args: List of fields to be returned as dict.
Returns:
list of dicts for given fields.
Example:
>>> Person.objects.filter(age__gte=16, name__startswith='jo').values('name', 'lastname') | [
"Returns",
"list",
"of",
"dicts",
"(",
"field",
"names",
"as",
"keys",
")",
"for",
"given",
"fields",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L430-L445 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.dump | def dump(self):
"""
Dump raw JSON output of matching queryset objects.
Returns:
List of dicts.
"""
results = []
for data in self.data():
results.append(data)
return results | python | def dump(self):
"""
Dump raw JSON output of matching queryset objects.
Returns:
List of dicts.
"""
results = []
for data in self.data():
results.append(data)
return results | [
"def",
"dump",
"(",
"self",
")",
":",
"results",
"=",
"[",
"]",
"for",
"data",
"in",
"self",
".",
"data",
"(",
")",
":",
"results",
".",
"append",
"(",
"data",
")",
"return",
"results"
] | Dump raw JSON output of matching queryset objects.
Returns:
List of dicts. | [
"Dump",
"raw",
"JSON",
"output",
"of",
"matching",
"queryset",
"objects",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L447-L458 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.or_filter | def or_filter(self, **filters):
"""
Works like "filter" but joins given filters with OR operator.
Args:
**filters: Query filters as keyword arguments.
Returns:
Self. Queryset object.
Example:
>>> Person.objects.or_filter(age__gte=16, name__s... | python | def or_filter(self, **filters):
"""
Works like "filter" but joins given filters with OR operator.
Args:
**filters: Query filters as keyword arguments.
Returns:
Self. Queryset object.
Example:
>>> Person.objects.or_filter(age__gte=16, name__s... | [
"def",
"or_filter",
"(",
"self",
",",
"*",
"*",
"filters",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"clone",
".",
"adapter",
".",
"add_query",
"(",
"[",
"(",
"\"OR_QRY\"",
",",
"filters",
")",
"]",
")",
"return",
"clone"
] | Works like "filter" but joins given filters with OR operator.
Args:
**filters: Query filters as keyword arguments.
Returns:
Self. Queryset object.
Example:
>>> Person.objects.or_filter(age__gte=16, name__startswith='jo') | [
"Works",
"like",
"filter",
"but",
"joins",
"given",
"filters",
"with",
"OR",
"operator",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L460-L476 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.OR | def OR(self):
"""
Switches default query joiner from " AND " to " OR "
Returns:
Self. Queryset object.
"""
clone = copy.deepcopy(self)
clone.adapter._QUERY_GLUE = ' OR '
return clone | python | def OR(self):
"""
Switches default query joiner from " AND " to " OR "
Returns:
Self. Queryset object.
"""
clone = copy.deepcopy(self)
clone.adapter._QUERY_GLUE = ' OR '
return clone | [
"def",
"OR",
"(",
"self",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"clone",
".",
"adapter",
".",
"_QUERY_GLUE",
"=",
"' OR '",
"return",
"clone"
] | Switches default query joiner from " AND " to " OR "
Returns:
Self. Queryset object. | [
"Switches",
"default",
"query",
"joiner",
"from",
"AND",
"to",
"OR"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L478-L487 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.search_on | def search_on(self, *fields, **query):
"""
Search for query on given fields.
Query modifier can be one of these:
* exact
* contains
* startswith
* endswith
* range
* lte
* gte
Args:
\*fields... | python | def search_on(self, *fields, **query):
"""
Search for query on given fields.
Query modifier can be one of these:
* exact
* contains
* startswith
* endswith
* range
* lte
* gte
Args:
\*fields... | [
"def",
"search_on",
"(",
"self",
",",
"*",
"fields",
",",
"*",
"*",
"query",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"clone",
".",
"adapter",
".",
"search_on",
"(",
"*",
"fields",
",",
"*",
"*",
"query",
")",
"return",
... | Search for query on given fields.
Query modifier can be one of these:
* exact
* contains
* startswith
* endswith
* range
* lte
* gte
Args:
\*fields (str): Field list to be searched on
\*\*query:... | [
"Search",
"for",
"query",
"on",
"given",
"fields",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L489-L516 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.order_by | def order_by(self, *args):
"""
Applies query ordering.
Args:
**args: Order by fields names.
Defaults to ascending, prepend with hypen (-) for desecending ordering.
Returns:
Self. Queryset object.
Examples:
>>> Person.objects.orde... | python | def order_by(self, *args):
"""
Applies query ordering.
Args:
**args: Order by fields names.
Defaults to ascending, prepend with hypen (-) for desecending ordering.
Returns:
Self. Queryset object.
Examples:
>>> Person.objects.orde... | [
"def",
"order_by",
"(",
"self",
",",
"*",
"args",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"clone",
".",
"adapter",
".",
"ordered",
"=",
"True",
"if",
"args",
":",
"clone",
".",
"adapter",
".",
"order_by",
"(",
"*",
"args"... | Applies query ordering.
Args:
**args: Order by fields names.
Defaults to ascending, prepend with hypen (-) for desecending ordering.
Returns:
Self. Queryset object.
Examples:
>>> Person.objects.order_by('-name', 'join_date') | [
"Applies",
"query",
"ordering",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L533-L551 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.set_params | def set_params(self, **params):
"""
add/update solr query parameters
"""
clone = copy.deepcopy(self)
clone.adapter.set_params(**params)
return clone | python | def set_params(self, **params):
"""
add/update solr query parameters
"""
clone = copy.deepcopy(self)
clone.adapter.set_params(**params)
return clone | [
"def",
"set_params",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"clone",
".",
"adapter",
".",
"set_params",
"(",
"*",
"*",
"params",
")",
"return",
"clone"
] | add/update solr query parameters | [
"add",
"/",
"update",
"solr",
"query",
"parameters"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L553-L559 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.data | def data(self):
"""
return (data_dict, key) tuple instead of models instances
"""
clone = copy.deepcopy(self)
clone._cfg['rtype'] = ReturnType.Object
return clone | python | def data(self):
"""
return (data_dict, key) tuple instead of models instances
"""
clone = copy.deepcopy(self)
clone._cfg['rtype'] = ReturnType.Object
return clone | [
"def",
"data",
"(",
"self",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"clone",
".",
"_cfg",
"[",
"'rtype'",
"]",
"=",
"ReturnType",
".",
"Object",
"return",
"clone"
] | return (data_dict, key) tuple instead of models instances | [
"return",
"(",
"data_dict",
"key",
")",
"tuple",
"instead",
"of",
"models",
"instances"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L561-L567 |
zetaops/pyoko | pyoko/db/queryset.py | QuerySet.raw | def raw(self, query):
"""
make a raw query
Args:
query (str): solr query
\*\*params: solr parameters
"""
clone = copy.deepcopy(self)
clone.adapter._pre_compiled_query = query
clone.adapter.compiled_query = query
return clone | python | def raw(self, query):
"""
make a raw query
Args:
query (str): solr query
\*\*params: solr parameters
"""
clone = copy.deepcopy(self)
clone.adapter._pre_compiled_query = query
clone.adapter.compiled_query = query
return clone | [
"def",
"raw",
"(",
"self",
",",
"query",
")",
":",
"clone",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"clone",
".",
"adapter",
".",
"_pre_compiled_query",
"=",
"query",
"clone",
".",
"adapter",
".",
"compiled_query",
"=",
"query",
"return",
"clone"... | make a raw query
Args:
query (str): solr query
\*\*params: solr parameters | [
"make",
"a",
"raw",
"query"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L569-L580 |
crypto101/merlyn | merlyn/auth.py | userForCert | def userForCert(store, cert):
"""Gets the user for the given certificate.
"""
return store.findUnique(User, User.email == emailForCert(cert)) | python | def userForCert(store, cert):
"""Gets the user for the given certificate.
"""
return store.findUnique(User, User.email == emailForCert(cert)) | [
"def",
"userForCert",
"(",
"store",
",",
"cert",
")",
":",
"return",
"store",
".",
"findUnique",
"(",
"User",
",",
"User",
".",
"email",
"==",
"emailForCert",
"(",
"cert",
")",
")"
] | Gets the user for the given certificate. | [
"Gets",
"the",
"user",
"for",
"the",
"given",
"certificate",
"."
] | train | https://github.com/crypto101/merlyn/blob/0f313210b9ea5385cc2e5b725dc766df9dc3284d/merlyn/auth.py#L115-L119 |
crypto101/merlyn | merlyn/auth.py | UserMixin.user | def user(self):
"""The current user.
This property is cached in the ``_user`` attribute.
"""
if self._user is not None:
return self._user
cert = self.transport.getPeerCertificate()
self._user = user = userForCert(self.store, cert)
return user | python | def user(self):
"""The current user.
This property is cached in the ``_user`` attribute.
"""
if self._user is not None:
return self._user
cert = self.transport.getPeerCertificate()
self._user = user = userForCert(self.store, cert)
return user | [
"def",
"user",
"(",
"self",
")",
":",
"if",
"self",
".",
"_user",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_user",
"cert",
"=",
"self",
".",
"transport",
".",
"getPeerCertificate",
"(",
")",
"self",
".",
"_user",
"=",
"user",
"=",
"userForCe... | The current user.
This property is cached in the ``_user`` attribute. | [
"The",
"current",
"user",
"."
] | train | https://github.com/crypto101/merlyn/blob/0f313210b9ea5385cc2e5b725dc766df9dc3284d/merlyn/auth.py#L30-L40 |
crypto101/merlyn | merlyn/auth.py | _TOFUContextFactory.getContext | def getContext(self):
"""Creates a context.
This will make contexts using ``SSLv23_METHOD``. This is
because OpenSSL thought it would be a good idea to have
``TLSv1_METHOD`` mean "only use TLSv1.0" -- specifically, it
disables TLSv1.2. Since we don't want to use SSLv2 and v3, we... | python | def getContext(self):
"""Creates a context.
This will make contexts using ``SSLv23_METHOD``. This is
because OpenSSL thought it would be a good idea to have
``TLSv1_METHOD`` mean "only use TLSv1.0" -- specifically, it
disables TLSv1.2. Since we don't want to use SSLv2 and v3, we... | [
"def",
"getContext",
"(",
"self",
")",
":",
"ctx",
"=",
"Context",
"(",
"SSLv23_METHOD",
")",
"ctx",
".",
"use_certificate_file",
"(",
"\"cert.pem\"",
")",
"ctx",
".",
"use_privatekey_file",
"(",
"\"key.pem\"",
")",
"ctx",
".",
"load_tmp_dh",
"(",
"\"dhparam.p... | Creates a context.
This will make contexts using ``SSLv23_METHOD``. This is
because OpenSSL thought it would be a good idea to have
``TLSv1_METHOD`` mean "only use TLSv1.0" -- specifically, it
disables TLSv1.2. Since we don't want to use SSLv2 and v3, we
set OP_NO_SSLv2|OP_NO_SS... | [
"Creates",
"a",
"context",
"."
] | train | https://github.com/crypto101/merlyn/blob/0f313210b9ea5385cc2e5b725dc766df9dc3284d/merlyn/auth.py#L49-L66 |
crypto101/merlyn | merlyn/auth.py | _TOFUContextFactory._verify | def _verify(self, connection, cert, errorNumber, errorDepth, returnCode):
"""Verify a certificate.
"""
try:
user = userForCert(self.store, cert)
except ItemNotFound:
log.msg("Connection attempt by {0!r}, but no user with that "
"e-mail address... | python | def _verify(self, connection, cert, errorNumber, errorDepth, returnCode):
"""Verify a certificate.
"""
try:
user = userForCert(self.store, cert)
except ItemNotFound:
log.msg("Connection attempt by {0!r}, but no user with that "
"e-mail address... | [
"def",
"_verify",
"(",
"self",
",",
"connection",
",",
"cert",
",",
"errorNumber",
",",
"errorDepth",
",",
"returnCode",
")",
":",
"try",
":",
"user",
"=",
"userForCert",
"(",
"self",
".",
"store",
",",
"cert",
")",
"except",
"ItemNotFound",
":",
"log",
... | Verify a certificate. | [
"Verify",
"a",
"certificate",
"."
] | train | https://github.com/crypto101/merlyn/blob/0f313210b9ea5385cc2e5b725dc766df9dc3284d/merlyn/auth.py#L69-L93 |
shaiguitar/snowclient.py | snowclient/snowrecord.py | SnowRecord.tablename_from_link | def tablename_from_link(klass, link):
"""
Helper method for URL's that look like /api/now/v1/table/FOO/sys_id etc.
"""
arr = link.split("/")
i = arr.index("table")
tn = arr[i+1]
return tn | python | def tablename_from_link(klass, link):
"""
Helper method for URL's that look like /api/now/v1/table/FOO/sys_id etc.
"""
arr = link.split("/")
i = arr.index("table")
tn = arr[i+1]
return tn | [
"def",
"tablename_from_link",
"(",
"klass",
",",
"link",
")",
":",
"arr",
"=",
"link",
".",
"split",
"(",
"\"/\"",
")",
"i",
"=",
"arr",
".",
"index",
"(",
"\"table\"",
")",
"tn",
"=",
"arr",
"[",
"i",
"+",
"1",
"]",
"return",
"tn"
] | Helper method for URL's that look like /api/now/v1/table/FOO/sys_id etc. | [
"Helper",
"method",
"for",
"URL",
"s",
"that",
"look",
"like",
"/",
"api",
"/",
"now",
"/",
"v1",
"/",
"table",
"/",
"FOO",
"/",
"sys_id",
"etc",
"."
] | train | https://github.com/shaiguitar/snowclient.py/blob/6bb513576d3b37612a7a4da225140d134f3e1c82/snowclient/snowrecord.py#L10-L17 |
shaiguitar/snowclient.py | snowclient/snowrecord.py | SnowRecord.links | def links(self):
"""
returns {attr1: href, attr2: href2}
"""
dlinks = {}
for key, value in self.__dict__.items():
if isinstance(value, dict) and value['link']:
dlinks[key] = value['link']
return dlinks | python | def links(self):
"""
returns {attr1: href, attr2: href2}
"""
dlinks = {}
for key, value in self.__dict__.items():
if isinstance(value, dict) and value['link']:
dlinks[key] = value['link']
return dlinks | [
"def",
"links",
"(",
"self",
")",
":",
"dlinks",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
"and",
"value",
"[",
"'link'",
"]",
":",
... | returns {attr1: href, attr2: href2} | [
"returns",
"{",
"attr1",
":",
"href",
"attr2",
":",
"href2",
"}"
] | train | https://github.com/shaiguitar/snowclient.py/blob/6bb513576d3b37612a7a4da225140d134f3e1c82/snowclient/snowrecord.py#L47-L55 |
pylava/pylava_pylint | pylava_pylint/main.py | Linter.run | def run(path, code, params=None, ignore=None, select=None, **meta):
"""Pylint code checking.
:return list: List of errors.
"""
logger.debug('Start pylint')
clear_cache = params.pop('clear_cache', False)
if clear_cache:
MANAGER.astroid_cache.clear()
... | python | def run(path, code, params=None, ignore=None, select=None, **meta):
"""Pylint code checking.
:return list: List of errors.
"""
logger.debug('Start pylint')
clear_cache = params.pop('clear_cache', False)
if clear_cache:
MANAGER.astroid_cache.clear()
... | [
"def",
"run",
"(",
"path",
",",
"code",
",",
"params",
"=",
"None",
",",
"ignore",
"=",
"None",
",",
"select",
"=",
"None",
",",
"*",
"*",
"meta",
")",
":",
"logger",
".",
"debug",
"(",
"'Start pylint'",
")",
"clear_cache",
"=",
"params",
".",
"pop... | Pylint code checking.
:return list: List of errors. | [
"Pylint",
"code",
"checking",
"."
] | train | https://github.com/pylava/pylava_pylint/blob/f8d3cb7c2256e664c025ff4d1a88673e96a6cebd/pylava_pylint/main.py#L24-L67 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.